2013-08-04 13 views
18

Mi sto preparando con CouchDB su Cloudant, e sono confuso perché Cloudant sembra fare un'autenticazione in modo diverso rispetto al normale CouchDB. Nello specifico, Cloudant sembra privo di un database _users.auth cloudant: manca _users database

ho letto l'auth FAQ Cloudant here, ed ha fornito le seguenti istruzioni:

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":[] } }

Queste istruzioni funzionava bene, e mi ha permesso di aggiornare l'oggetto _Sicurezza di un database.

Ciò che non era chiaro era come impostare il database _users. Non esisteva automaticamente, così ho cercato di creare utilizzando un normale:

curl -X PUT $COUCH/_users

Questo ha funzionato bene, ma quando tento di aggiungere un nuovo utente al _users come segue:

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"}' 

sembra per creare il documento in modo corretto:

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

Ma il nuovo utente in _users su Cloudant manca una password hash:

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

Così, quando tento di autenticazione a questo utente, ho il seguente errore:

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

Sulla mia installazione CouchDB locali, la creazione di un nuovo utente in _users sarebbe automaticamente creare l'hash della password:

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

ho provato a copiare il "_auth _design /" documento dalla mia installazione CouchDB locale per Cloudant, b i risultati sono uguali - nessuna password hash.

A un certo punto, sembra che sia uscito dai binari, ma non sono sicuro di dove sia successo. Come posso configurare Cloudant per utilizzare lo stesso tipo di autenticazione di CouchDB regolare?

risposta

12

ho trovato la risposta via #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

la password Ora, 8 mesi più tardi, cloudant non ha ancora hash. @ jbeard4 perché non accettare la tua risposta? :) – Wei

+0

novembre? '{ "_id": "org.couchdb.user: me", "_ rev": "1-5a723e0fb15bb4e0d61e56797ebd8df7", "name": "me", "ruoli": [], "type": "utente"," password ":" pwd "}' – MrYellow

1

Infatti, cloudant non supporta la generazione di valore di hash. Ho trovato questa alternativa che aiuta a utilizzare le _users db nel servizio cloudant ...

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

+0

Grazie per questo. Tuttavia, non sono riuscito a iniziare il progetto. Conosci la risposta a questo problema: https://github.com/doublerebel/cloudant-user/issues/1? –

+0

@ChrisSnow Non uso il caffè, quindi sto usando questo succo nel mio progetto https://gist.github.com/weilu/10445007 –