【问题标题】:How to create a new Database per new user in CouchDB without application Tier如何在没有应用程序层的 CouchDB 中为每个新用户创建一个新数据库
【发布时间】:2012-04-09 08:41:08
【问题描述】:

我正面临“如何在 CouchDB 中保护私人用户数据的私密性”挑战。 couchdb wiki 上的详细介绍:http://wiki.apache.org/couchdb/PerDocumentAuthorization

我选择为每个用户创建一个新数据库,因为这最适合我正在创建的应用程序,而且社区有很多建议可以采用这种方式。

我无法弄清楚如何执行此操作。在 CouchDB 中有内置的方法吗?到目前为止,我对中间层或应用程序层没有其他需要,并且希望将其保留为纯粹的沙发 + htmll5 应用程序。这方面的最佳案例做法是什么?

【问题讨论】:

    标签: couchdb


    【解决方案1】:

    new feature 将添加对每个用户自动创建/删除数据库的支持。

    以下部分将添加到default.inilocal.ini

    [couch_peruser]
    ; If enabled, couch_peruser ensures that a private per-user database
    ; exists for each document in _users. These databases are writable only
    ; by the corresponding user. Databases are in the following form:
    ; userdb-{hex encoded username}
    enable = true
    
    ; If set to true and a user is deleted, the respective database gets
    ; deleted as well.
    delete_dbs = true
    

    【讨论】:

      【解决方案2】:

      我想下面这行是实现它的最简单方法:

      curl -X PUT http://127.0.0.1:5984/${user_name}
      

      PS:我在这里找到它http://guide.couchdb.org/draft/tour.html

      【讨论】:

      • 是的,就是这个想法,我只需要在新用户注册时(以编程方式)即时完成。有人描述的一件事是做一个小节点应用程序,它监听 _user 数据库上的 _changes 提要,但我什至不知道从哪里开始这样的事情。任何这些类型的解决方案都是我正在寻找的。希望这有助于澄清。
      • 我尝试通过邮递员在guide.couchdb.org/draft/security.html 上创建数据库,但失败了,然后我尝试了 curl 和瞧!有效 !邮递员中请求失败的原因是如果未明确指定 curl 默认使用“基本身份验证”。然而,邮递员需要明确选择“基本身份验证”! = 简而言之,标头中的身份验证是罪魁祸首!
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-07-19
      • 2014-03-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多