From commits-return-5987-apmail-couchdb-commits-archive=couchdb.apache.org@couchdb.apache.org Wed Feb 23 18:42:51 2011 Return-Path: Delivered-To: apmail-couchdb-commits-archive@www.apache.org Received: (qmail 76587 invoked from network); 23 Feb 2011 18:42:51 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 23 Feb 2011 18:42:51 -0000 Received: (qmail 79170 invoked by uid 500); 23 Feb 2011 18:42:51 -0000 Delivered-To: apmail-couchdb-commits-archive@couchdb.apache.org Received: (qmail 79036 invoked by uid 500); 23 Feb 2011 18:42:49 -0000 Mailing-List: contact commits-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list commits@couchdb.apache.org Received: (qmail 79029 invoked by uid 500); 23 Feb 2011 18:42:48 -0000 Delivered-To: apmail-incubator-couchdb-commits@incubator.apache.org Received: (qmail 79025 invoked by uid 99); 23 Feb 2011 18:42:48 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 23 Feb 2011 18:42:48 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,NORMAL_HTTP_TO_IP,WEIRD_PORT X-Spam-Check-By: apache.org Received: from [140.211.11.131] (HELO eos.apache.org) (140.211.11.131) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 23 Feb 2011 18:42:46 +0000 Received: from eosnew.apache.org (localhost [127.0.0.1]) by eos.apache.org (Postfix) with ESMTP id 517ED1D1 for ; Wed, 23 Feb 2011 18:42:13 +0000 (UTC) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable From: Apache Wiki To: Apache Wiki Date: Wed, 23 Feb 2011 18:42:13 -0000 Message-ID: <20110223184213.40488.83961@eosnew.apache.org> Subject: =?utf-8?q?=5BCouchdb_Wiki=5D_Trivial_Update_of_=22Security=5FFeatures=5FO?= =?utf-8?q?verview=22_by_MattAdams?= X-Virus-Checked: Checked by ClamAV on apache.org Dear Wiki user, You have subscribed to a wiki page or wiki category on "Couchdb Wiki" for c= hange notification. The "Security_Features_Overview" page has been changed by MattAdams. http://wiki.apache.org/couchdb/Security_Features_Overview?action=3Ddiff&rev= 1=3D18&rev2=3D19 -------------------------------------------------- = The "_id" attribute value must be prefixed with the string "org.couchdb.u= ser:" and the rest must match the value of the attribute "name". The roles = attribute must be an array of roles (and each role is a string). The "passw= ord_sha" attribute is an hexadecimal representation of the SHA-1 hash compu= ted over a string that matches the user password concatenated with a salt (= ideally a random string). The salt attribute is the hexadecimal representat= ion of the salt used to generate the user's password hash. = - '''Note:''' you will need to use the [[https://github.com/apache/couchdb/= blob/trunk/share/www/script/sha1.js|sha1.js implementation of SHA-1]] to ge= nerate `password_sha`. The SHA-1 hex digest output by Open``SSL is not com= patible with Erlang's crypto:sha/1 -- MattAdams + '''Note:''' please see "Generating password_sha" below for more about the= SHA-1 hash. = Some rules regarding user documents: = @@ -108, +108 @@ = All these rules regarding authentication database documents are enforced = by the validate document update function stored in the design document with= ID "_design/_auth" found in the authentication database (it is automatical= ly created by CouchDB). = + =3D=3D=3D Generating password_sha =3D=3D=3D + = + `password_sha` can be generated a number of different ways. Open``SSL's = `sha` and `sha1` functions are not compatible. Below are some methods that= work: + = + Erlang + = + {{{ + Erlang R14B01 (erts-5.8.2) [source] [smp:2:2] [rq:2] [async-threads:4] [h= ipe] [kernel-poll:true] + = + Eshell V5.8.2 (abort with ^G) + 1> Apache CouchDB 1.2.0ab0c6e32-git (LogLevel=3Dinfo) is starting. + Apache CouchDB has started. Time to relax. + [info] [<0.37.0>] Apache CouchDB has started on http://127.0.0.1:5984/ + = + 1> couch_util:to_hex(crypto:sha("foobar")). + "8843d7f92416211de9ebb963ff4ce28125932878" + }}} + = + Ruby + = + {{{ + irb(main):001:0> require 'digest/sha1' + =3D> true + irb(main):002:0> Digest::SHA1.hexdigest 'foobar' + =3D> "8843d7f92416211de9ebb963ff4ce28125932878" + }}} + = + Python + = + {{{ + >>> import hashlib + >>> h =3D hashlib.sha1() + >>> h.update("foobar") + >>> h.digest() + '\x88C\xd7\xf9$\x16!\x1d\xe9\xeb\xb9c\xffL\xe2\x81%\x93(x' + >>> h.hexdigest() + '8843d7f92416211de9ebb963ff4ce28125932878' + }}} + = + sha1.js implementation (from [[https://github.com/apache/couchdb/blob/tru= nk/share/www/script/sha1.js|CouchDB]]) + = + {{{ + hex_sha1(foobar); + }}} + = =3D=3D Document Update Validation =3D=3D = See [[Document_Update_Validation]].