Skip to navigation
Create a public couchdb readonly database where only an admin can update
31.07.24
Create a public couchDB read-only database where only admin can update the docs ```console curl -X PUT http://admin:pass@cb.neriene.com/bw-coupon/_design/auth -d "{ \"language\": \"javascript\", \"validate_doc_update\": \"function(newDoc, oldDoc, userCtx) { if (userCtx.name === 'captain') { return; } else { throw ({ forbidden: 'Only admins can edit the database' }); } }\"}" ```` Create a View to check first the user ## Test Access without user ```console curl -X GET https://cb.neriene.com/bw-coupon/test ``` ## Test without user and password and Grab the _rev and change the the doc test with key foo ```console curl -X PUT https://cb.neriene.com/bw-coupon/test -d '{"foo": "I love gomes","_rev":"3-d1a62f918d8eb20e435125a98e1d13b0"}' ``` ## Test with user and password, and grab the _rev and change the the doc test with key foo ```console curl -X PUT https://admin:pass@cb.neriene.com/bw-coupon/test -d '{"foo": "I love foofighers","_rev":"3-d1a62f918d8eb20e435125a98e1d13b0"}' ``` using curl https://docs.couchdb.org/en/stable/intro/curl.html
https://githubissues.com/apache/couchdb/4646
Reply
Anonymous
Information Epoch 1735328199
Store numerical data in flat files.
Home
Notebook
Contact us