couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnew...@apache.org
Subject git commit: Allow persistent cookies
Date Thu, 19 Jan 2012 13:38:51 GMT
Updated Branches:
  refs/heads/1304-persistent-cookies 78d5c6945 -> b5c3f7201 (forced update)


Allow persistent cookies

COUCHDB-1304


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

Branch: refs/heads/1304-persistent-cookies
Commit: b5c3f72018d462638a56fe05b2d377b05324c61d
Parents: ca51333
Author: Robert Newson <rnewson@apache.org>
Authored: Thu Jan 19 13:31:52 2012 +0000
Committer: Robert Newson <rnewson@apache.org>
Committed: Thu Jan 19 13:38:33 2012 +0000

----------------------------------------------------------------------
 etc/couchdb/default.ini.tpl.in   |    1 +
 src/couchdb/couch_httpd_auth.erl |   12 +++++++++++-
 2 files changed, 12 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/b5c3f720/etc/couchdb/default.ini.tpl.in
----------------------------------------------------------------------
diff --git a/etc/couchdb/default.ini.tpl.in b/etc/couchdb/default.ini.tpl.in
index ef6bf97..2e84eab 100644
--- a/etc/couchdb/default.ini.tpl.in
+++ b/etc/couchdb/default.ini.tpl.in
@@ -64,6 +64,7 @@ authentication_redirect = /_utils/session.html
 require_valid_user = false
 timeout = 600 ; number of seconds before automatic logout
 auth_cache_size = 50 ; size is number of cache entries
+allow_persistent_cookie = false ; set to true to allow persistent cookies
 
 [couch_httpd_oauth]
 ; If set to 'true', oauth token and consumer secrets will be looked up

http://git-wip-us.apache.org/repos/asf/couchdb/blob/b5c3f720/src/couchdb/couch_httpd_auth.erl
----------------------------------------------------------------------
diff --git a/src/couchdb/couch_httpd_auth.erl b/src/couchdb/couch_httpd_auth.erl
index bdfc15f..635b1b7 100644
--- a/src/couchdb/couch_httpd_auth.erl
+++ b/src/couchdb/couch_httpd_auth.erl
@@ -232,7 +232,7 @@ cookie_auth_cookie(Req, User, Secret, TimeStamp) ->
     Hash = crypto:sha_mac(Secret, SessionData),
     mochiweb_cookies:cookie("AuthSession",
         couch_util:encodeBase64Url(SessionData ++ ":" ++ ?b2l(Hash)),
-        [{path, "/"}] ++ cookie_scheme(Req)).
+        [{path, "/"}] ++ cookie_scheme(Req) ++ max_age()).
 
 hash_password(Password, Salt) ->
     ?l2b(couch_util:to_hex(crypto:sha(<<Password/binary, Salt/binary>>))).
@@ -358,3 +358,13 @@ cookie_scheme(#httpd{mochi_req=MochiReq}) ->
         http -> [];
         https -> [{secure, true}]
     end.
+
+max_age() ->
+    case couch_config:get("couch_httpd_auth", "allow_persistent_cookie", "false") of
+        "false" ->
+            [];
+        "true" ->
+            Timeout = list_to_integer(
+                couch_config:get("couch_httpd_auth", "timeout", "600")),
+            [{max_age, Timeout}]
+    end.


Mime
View raw message