如何使用PouchDB安全连接到Cloudant?

编程入门 行业动态 更新时间:2024-10-27 11:17:32
本文介绍了如何使用PouchDB安全连接到Cloudant?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用Cordova / PhoneGap为Android和iOS创建移动应用程序,并使用IBM的Cloudant数据库进行存储。我正在使用PouchDB javascript库来访问Cloudant数据库。目前我有这个代码来访问它...

I am creating a mobile app for Android and iOS using Cordova/PhoneGap and am using IBM's Cloudant database for storage. I am using the PouchDB javascript library to access the Cloudant database. Currently I have this code to access it...

db = new PouchDB('[myaccount].cloudant/[mydb]', { auth: { username: 'myusername', password: 'mypassword' } });

我知道这是非常不安全的,我想知道是否有更安全的连接方式从应用程序内部到我的数据库?

I am aware that this is extremely insecure, and am wondering if there is a more secure way to connect to my database from within the app?

推荐答案

您可能要考虑的一个选项是实施服务(例如在云端运行) )用于注册您的应用程序的新用户。注册逻辑可能如下所示:

One option you may like to consider is implementing a service (e.g. running in the cloud) for registering new users of your app. Registration logic could look something like this:

  • 手机代码与您的应用服务通信,请求注册用户
  • 该服务调用 Cloudant创建API密钥将返回到手机代码
  • 手机代码会在设备上保存API密钥用户名和密码。然后在 auth:{用户名:'myusername',密码:'mypassword'} 对象中使用这些凭据。
  • The handset code communicates with your application service requesting registration of the user
  • The service makes a call to Cloudant to create an API key which would is returned to the handset code
  • The handset code saves the API key 'username' and 'password' on the device. These credentials are then use in the auth: { username: 'myusername', password: 'mypassword' } object.
  • 更多推荐

    如何使用PouchDB安全连接到Cloudant?

    本文发布于:2023-10-30 03:52:01,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1541673.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:连接到   如何使用   PouchDB   Cloudant

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!