Created
July 26, 2010 12:37
-
-
Save lizconlan/490482 to your computer and use it in GitHub Desktop.
CouchDB security - prevent non-admins from editing
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
function(newDoc, oldDoc, userCtx) { | |
if (userCtx.roles.indexOf('_admin') !== -1) { | |
return; | |
} else { | |
throw({forbidden: 'Only admins may edit the database'}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
version 2 blocks everything, version 1 left a loophole where an unauthorised user could upload an attachment and break the security model