couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject [3/13] git commit: Set an auth secret in the Node.js environment
Date Wed, 13 Feb 2013 13:17:14 GMT
Set an auth secret in the Node.js environment


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/f3f00cad
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/f3f00cad
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/f3f00cad

Branch: refs/heads/nodejs_couchdb
Commit: f3f00caddd014cddf434aab5df130bfc857934a3
Parents: 7df7d97
Author: Jason Smith (work) <jhs@iriscouch.com>
Authored: Tue Feb 12 11:28:47 2013 +0000
Committer: Jason Smith (work) <jhs@iriscouch.com>
Committed: Tue Feb 12 11:28:47 2013 +0000

----------------------------------------------------------------------
 src/couchdb/couch_os_daemons.erl |   16 +++++++++++++++-
 1 files changed, 15 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/f3f00cad/src/couchdb/couch_os_daemons.erl
----------------------------------------------------------------------
diff --git a/src/couchdb/couch_os_daemons.erl b/src/couchdb/couch_os_daemons.erl
index 46fedd7..509655d 100644
--- a/src/couchdb/couch_os_daemons.erl
+++ b/src/couchdb/couch_os_daemons.erl
@@ -195,7 +195,21 @@ code_change(_OldVsn, State, _Extra) ->
 
 start_port(?NODEJS_EXTRA) ->
     Port = couch_config:get("httpd", "port"),
-    Env = [ {"_couchdb_port",Port} ],
+
+    % This is kind of bad. The environment variable is ok for the child,
+    % however it also sets for this process. The only reason is to
+    % communicate to couch_httpd_auth:nodejs_authentication_handler/1.
+    Key = "COUCHDB_NODEJS_PASSWORD",
+    Password = case os:getenv(Key) of
+        false ->
+            Uuid = ?b2l(couch_uuids:random()),
+            true = os:putenv(Key, Uuid),
+            Uuid;
+        Found ->
+            Found
+    end,
+
+    Env = [ {"_couchdb_port",Port}, {"_couchdb_password",Password} ],
     start_port(?NODEJS_EXTRA, Env);
 
 start_port(Command) ->


Mime
View raw message