2013-08-04 24 views
18

Tôi đang thiết lập với CouchDB trên Cloudant, và tôi bối rối vì Cloudant dường như làm auth khác với CouchDB thông thường. Cụ thể, Cloudant dường như thiếu cơ sở dữ liệu _users.Cloudant auth: thiếu cơ sở dữ liệu _users

tôi đọc Cloudant auth FAQ here, và nó cung cấp các hướng dẫn sau đây:

Can I use CouchDB security features (_users database, security objects, validation functions) on Cloudant?

Yes you can. If you want to use the _users database you must first turn off Cloudant's own security for the roles you want to manage via _users. To do this you need to PUT a JSON document like the following to the _security endpoint of the database (for example https://USERNAME.cloudant.com/DATABASE/_security):

{ "cloudant": { "nobody": ["_reader", "_writer", "_admin"] }, "readers": { "names":["demo"],"roles":[] } }

Những hướng dẫn làm việc tốt, và cho phép tôi để cập nhật các đối tượng _security của một cơ sở dữ liệu.

Điều không rõ ràng là cách thiết lập cơ sở dữ liệu _users. Nó không tồn tại tự động, vì vậy tôi cố gắng tạo ra nó bằng cách sử dụng thường xuyên:

curl -X PUT $COUCH/_users

này làm việc tốt, nhưng khi tôi cố gắng để thêm người dùng mới để _users như sau:

curl -HContent-Type:application/json \ 
    -vXPUT $COUCH/_users/org.couchdb.user:me \ 
    --data-binary '{"_id": "org.couchdb.user:me","name": "me","roles": [],"type": "user","password": "pwd"}' 

nó xuất hiện để tạo ra các tài liệu một cách chính xác:

{"ok":true,"id":"org.couchdb.user:me","rev":"3-86c3801fdb8c32331f5f2580e861a765"}

Nhưng người dùng mới trong _users trên Cloudant thiếu một mật khẩu băm:

{ 
    "_id": "org.couchdb.user:me", 
    "_rev": "3-86c3801fdb8c32331f5f2580e861a765", 
    "name": "me", 
    "roles": [ 
    ], 
    "type": "user", 
    "password": "pwd" 
} 

Vì vậy, khi tôi cố gắng để xác thực tại thành viên này, tôi nhận được lỗi sau:

{"error":"bad_request","reason":"missing password_sha property in user doc"}

Ngày cài đặt CouchDB địa phương của tôi, tạo ra một người dùng mới trong _users sẽ tự động tạo mật khẩu được băm:

{ 
    "_id": "org.couchdb.user:test", 
    "_rev": "1-9c1c4360eba168468a37d7f623782d23", 
    "password_scheme": "pbkdf2", 
    "iterations": 10, 
    "name": "test", 
    "roles": [ 
    ], 
    "type": "user", 
    "derived_key": "4a122a20c1a8fdddb5307c29078e2c4269abffa5", 
    "salt": "36c0c05cf2a3ee321eabd10c46a8aa2a" 
} 

Tôi đã cố sao chép tài liệu "_design/_auth" từ bản cài đặt CouchDB cục bộ của mình vào Cloudant, b ut kết quả là như nhau - không có mật khẩu băm.

Tôi dường như đã đi ra khỏi đường ray tại một số điểm, nhưng tôi không chắc chắn nơi điều này đã xảy ra. Làm thế nào tôi có thể thiết lập Cloudant để sử dụng cùng một loại auth như CouchDB thông thường?

Trả lời

12

Tôi tìm thấy câu trả lời qua #cloudant IRC:

09:59 <+kocolosk> creating _users was the right thing to do

09:59 <+kocolosk> the API matches an older version of CouchDB where the passwords needed to hashed client-side

10:00 < jbeard> oh, I see

10:00 <+kocolosk> we're addressing that lack of support for automatic hashing

10:01 < jbeard> I'm trying to find documentation on client-side hashing in Couch.

10:02 < jbeard> What version of Couch is Cloudant aiming to be compatible with for _users?

10:04 <+kocolosk> jbeard: http://wiki.apache.org/couchdb/Security_Features_Overview

10:04 <+kocolosk> see "Generating password_sha (only applicable for 1.1.x and earlier)"

10:04 <+kocolosk> jbeard: this particular feature is the last bit where we are compatible with 1.1.x but not newer version

10:05 < jbeard> Excellent

10:05 < jbeard> That's what I needed to know

+4

Bây giờ, 8 tháng sau, cloudant vẫn không đã băm mật khẩu. @ jbeard4 tại sao không chấp nhận câu trả lời của riêng bạn? :) – Wei

+0

Tháng 11? '{" _id ":" org.couchdb.user: me "," _ rev ":" 1-5a723e0fb15bb4e0d61e56797ebd8df7 "," tên ":" tôi "," vai trò ": []," loại ":" người dùng "," mật khẩu ":" pwd "}' – MrYellow

1

Trong thực tế, cloudant không hỗ trợ thế hệ giá trị băm. tôi thấy lựa chọn này giúp sử dụng _users db trong dịch vụ cloudant ...

https://github.com/doublerebel/cloudant-user

+0

Cảm ơn vì điều này. Tuy nhiên, tôi không thể bắt đầu với dự án. Bạn có biết câu trả lời cho vấn đề này không: https://github.com/doublerebel/cloudant-user/issues/1? –

+0

@ChrisSnow Tôi không sử dụng cà phê, vì vậy tôi đang sử dụng ý chính này trong dự án của tôi https://gist.github.com/weilu/10445007 –

Các vấn đề liên quan