You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by Apache Wiki <wi...@apache.org> on 2010/04/08 20:13:02 UTC
[Couchdb Wiki] Update of "Security_Features_Overview" by SebastianCohnen
Dear Wiki user,
You have subscribed to a wiki page or wiki category on "Couchdb Wiki" for change notification.
The "Security_Features_Overview" page has been changed by SebastianCohnen.
The comment on this change is: moved section to it's own page: Document_Update_Validation.
http://wiki.apache.org/couchdb/Security_Features_Overview?action=diff&rev1=7&rev2=8
--------------------------------------------------
CouchDB does not support other roles at this time. Support for read access restriction is planned for the 1.0 release.
=== Validation ===
- A design document may define a member function called "validate_doc_update". Requests to create or update a document are validated against every "validate_doc_update" function defined in the database. The validation functions are executed in an unspecified order. A design document can contain only one validation function. Errors are thrown as javascript objects.
- Example of a design document that validates the presence of an "address" field and returns :
+ See [[Document_Update_Validation]].
- {{{
- {
- _id: "_design/myview",
- validate_doc_update: "function(newDoc, oldDoc, userCtx) {
- if(newDoc.address === undefined) {
- throw {forbidden: 'Document must have an address.'};
- }"
- }
- }}}
-
- The result of a document update without the address field will look like this:
- {{{
- HTTP/1.1 403 Forbidden
- WWW-Authenticate: Basic realm="administrator"
- Server: CouchDB/0.9.0 (Erlang OTP/R12B)
- Date: Tue, 21 Apr 2009 00:02:32 GMT
- Content-Type: text/plain;charset=utf-8
- Content-Length: 57
- Cache-Control: must-revalidate
-
- {"error":"forbbiden","reason":"Document must have an address."}
- }}}
-
-
- The "validate_doc_update" function accepts three arguments:
- 1. newDoc - The document to be created or used for update.
- 1. oldDoc - The current document if document id was specified in the HTTP request
- 1. userCtx - User context object, which contains three properties:
- a. db - String name of database
- a. name - String user name
- a. roles - Array of roles to which user belongs. Currently only admin role is supported.
-