Created
August 11, 2011 12:42
-
-
Save abtris/1139549 to your computer and use it in GitHub Desktop.
CouchDB-login-test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ADMIN="admin:admin" | |
| DATABASE="test" | |
| USER="writer" | |
| PASSWORD="writer" | |
| READERUSER="reader" | |
| READERPASSWORD="reader" | |
| HOST="localhost" | |
| # Create Reader, Writer User | |
| SALT=`openssl rand 16 | openssl md5` | |
| READERSALT=`openssl rand 16 | openssl md5` | |
| PASSWORDHASH=`printf '%s%s' $PASSWORD $SALT | openssl sha1` | |
| READERPASSWORDHASH=`printf '%s%s' $READERPASSWORD $READERSALT | openssl sha1` | |
| curl -X PUT http://${HOST}:5984/${DATABASE}/_security -u "${ADMIN}" -d '{"admins":{"names":["'"$USER"'"], "roles":[]}, "readers":{"names":["'"$READERUSER"'"],"readers":[]}}' | |
| curl -X POST http://${HOST}:5984/_users -d '{"_id":"org.couchdb.user:'"$USER"'","type":"user","name":"'"$USER"'","roles":[],"password_sha":"'"${PASSWORDHASH}"'", "salt":"'"$SALT"'"}' -H "Content-Type: application/json" | |
| curl -X POST http://${HOST}:5984/_users -d '{"_id":"org.couchdb.user:'"$READERUSER"'","type":"user","name":"'"$READERUSER"'","roles":[],"password_sha":"'"${READERPASSWORDHASH}"'", "salt":"'"$READERSALT"'"}' -H "Content-Type: application/json" | |
| curl -X GET http://${HOST}:5984/${DATABASE} -u "${USER}:${PASSWORD}" | |
| curl -X GET http://${HOST}:5984/${DATABASE} -u "${READERUSER}:${READERPASSWORD}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment