技术控

    今日:59| 主题:49312
收藏本版 (1)
最新软件应用技术尽在掌握

[其他] Use curl to create a CouchDB admin user

[复制链接]
僞裝癡人說夢 发表于 2016-10-5 18:16:20
101 2

立即注册CoLaBug.com会员,免费获得投稿人的专业资料,享用更多功能,玩转个人品牌!

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
This too me longer to find than it should have done, so I'm writing it here for future me.
  When you install CouchDB, it is in a mode where anyone can do anything with the database including creating and deleting databases. This is called "Admin Party" mode which is a pretty cool name, but not what I want.
  Creating admin users

  To create a user in 1.6 (I've not used 2.0 yet, but assuming it's the same) you simply click on the "Fix This" link in Futon which is available at http://localhost:5984/_utils/ by default.
  As CouchDB's entire API is essentially a RESTFul API, to do this via the command line, you simply PUT a new user to into the    _configs/adminscollection like this:  
  1. curl -s -X PUT http://localhost:5984/_config/admins/rob -d '"123456"'
复制代码
This creates an admin user called    robwith a password of    123456. Note that the password within the body of the PUT request must be a quoted string. This caught me out for a while!  
  From this point on, we can then use basic authentication to do admin-y things, such as create a    bookshelf_apidatabase:  
  1. $ curl -s -X PUT http://rob:[email protected]:5984/bookshelf_api
  2. {"ok":true}
复制代码
Other users

  You can also set up per-database users which is handy for limiting what your application can do when connected to CouchDB. This is done creating users in the    /_users/collection and then assigning them to a class in the    _securitycollection of the database. There are two default classes: "members" and "admins" where members can modify data, but not design documents and admins can modify all documents including user roles on that database.
友荐云推荐




上一篇:神经网络与深度学习笔记(三)
下一篇:Unity 8 Desktop Session Arrives in Ubuntu 16.10
酷辣虫提示酷辣虫禁止发表任何与中华人民共和国法律有抵触的内容!所有内容由用户发布,并不代表酷辣虫的观点,酷辣虫无法对用户发布内容真实性提供任何的保证,请自行验证并承担风险与后果。如您有版权、违规等问题,请通过"联系我们"或"违规举报"告知我们处理。

天瑜 发表于 2016-10-6 01:06:07
终于看完了,很不错!
回复 支持 反对

使用道具 举报

syliuhui 发表于 2016-10-10 22:41:38
支持一下!
回复 支持 反对

使用道具 举报

*滑动验证:
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

我要投稿

推荐阅读

扫码访问 @iTTTTT瑞翔 的微博
回页顶回复上一篇下一篇回列表手机版
手机版/CoLaBug.com ( 粤ICP备05003221号 | 文网文[2010]257号 )|网站地图 酷辣虫

© 2001-2016 Comsenz Inc. Design: Dean. DiscuzFans.

返回顶部 返回列表