Updated Branches: refs/heads/1305-persistent-cookies [created] 78d5c6945
Allow persistent cookies Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/78d5c694 Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/78d5c694 Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/78d5c694 Branch: refs/heads/1305-persistent-cookies Commit: 78d5c69457e6b93b92452376e0c322802bc6adfe Parents: ca51333 Author: Robert Newson <[email protected]> Authored: Thu Jan 19 13:31:52 2012 +0000 Committer: Robert Newson <[email protected]> Committed: Thu Jan 19 13:31:52 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/78d5c694/etc/couchdb/default.ini.tpl.in ---------------------------------------------------------------------- diff --git a/etc/couchdb/default.ini.tpl.in b/etc/couchdb/default.ini.tpl.in index ef6bf97..398556d 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 +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/78d5c694/src/couchdb/couch_httpd_auth.erl ---------------------------------------------------------------------- diff --git a/src/couchdb/couch_httpd_auth.erl b/src/couchdb/couch_httpd_auth.erl index bdfc15f..32316f3 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", "persistent_cookie", "false") of + "false" -> + []; + "true" -> + Timeout = list_to_integer( + couch_config:get("couch_httpd_auth", "timeout", "600")), + [{max_age, Timeout}] + end.
