Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save lizconlan/490482 to your computer and use it in GitHub Desktop.
Save lizconlan/490482 to your computer and use it in GitHub Desktop.
CouchDB security - prevent non-admins from editing
function(newDoc, oldDoc, userCtx) {
if (userCtx.roles.indexOf('_admin') !== -1) {
return;
} else {
throw({forbidden: 'Only admins may edit the database'});
}
}
@lizconlan
Copy link
Author

version 2 blocks everything, version 1 left a loophole where an unauthorised user could upload an attachment and break the security model

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment