summaryrefslogtreecommitdiff
path: root/src/couchdb/couch_httpd_auth.erl
diff options
context:
space:
mode:
authorFilipe David Borba Manana <fdmanana@apache.org>2010-09-27 19:14:37 +0000
committerFilipe David Borba Manana <fdmanana@apache.org>2010-09-27 19:14:37 +0000
commit6c6db011c2064597526c6f36878a282238dd2bf2 (patch)
tree9875a3237a385b3ff9d9f53be7642bafbabcbbfa /src/couchdb/couch_httpd_auth.erl
parentc4e2e1416bcedbe654d56c3851a0d08cddfc4bee (diff)
Replacing calls to couch_util:get_value with ?getv
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@1001879 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/couchdb/couch_httpd_auth.erl')
-rw-r--r--src/couchdb/couch_httpd_auth.erl26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/couchdb/couch_httpd_auth.erl b/src/couchdb/couch_httpd_auth.erl
index f76898e1..b16a439e 100644
--- a/src/couchdb/couch_httpd_auth.erl
+++ b/src/couchdb/couch_httpd_auth.erl
@@ -69,14 +69,14 @@ default_authentication_handler(Req) ->
nil ->
throw({unauthorized, <<"Name or password is incorrect.">>});
UserProps ->
- UserSalt = couch_util:get_value(<<"salt">>, UserProps, <<>>),
+ UserSalt = ?getv(<<"salt">>, UserProps, <<>>),
PasswordHash = hash_password(?l2b(Pass), UserSalt),
- ExpectedHash = couch_util:get_value(<<"password_sha">>, UserProps, nil),
+ ExpectedHash = ?getv(<<"password_sha">>, UserProps, nil),
case couch_util:verify(ExpectedHash, PasswordHash) of
true ->
Req#httpd{user_ctx=#user_ctx{
name=?l2b(User),
- roles=couch_util:get_value(<<"roles">>, UserProps, [])
+ roles=?getv(<<"roles">>, UserProps, [])
}};
_Else ->
throw({unauthorized, <<"Name or password is incorrect.">>})
@@ -180,7 +180,7 @@ cookie_authentication_handler(#httpd{mochi_req=MochiReq}=Req) ->
case couch_auth_cache:get_user_creds(User) of
nil -> Req;
UserProps ->
- UserSalt = couch_util:get_value(<<"salt">>, UserProps, <<"">>),
+ UserSalt = ?getv(<<"salt">>, UserProps, <<"">>),
FullSecret = <<Secret/binary, UserSalt/binary>>,
ExpectedHash = crypto:sha_mac(FullSecret, User ++ ":" ++ TimeStr),
Hash = ?l2b(string:join(HashParts, ":")),
@@ -194,7 +194,7 @@ cookie_authentication_handler(#httpd{mochi_req=MochiReq}=Req) ->
?LOG_DEBUG("Successful cookie auth as: ~p", [User]),
Req#httpd{user_ctx=#user_ctx{
name=?l2b(User),
- roles=couch_util:get_value(<<"roles">>, UserProps, [])
+ roles=?getv(<<"roles">>, UserProps, [])
}, auth={FullSecret, TimeLeft < Timeout*0.9}};
_Else ->
Req
@@ -215,9 +215,9 @@ cookie_auth_header(#httpd{user_ctx=#user_ctx{name=User}, auth={Secret, true}}, H
% or logout handler.
% The login and logout handlers need to set the AuthSession cookie
% themselves.
- CookieHeader = couch_util:get_value("Set-Cookie", Headers, ""),
+ CookieHeader = ?getv("Set-Cookie", Headers, ""),
Cookies = mochiweb_cookies:parse_cookie(CookieHeader),
- AuthSession = couch_util:get_value("AuthSession", Cookies),
+ AuthSession = ?getv("AuthSession", Cookies),
if AuthSession == undefined ->
TimeStamp = make_cookie_time(),
[cookie_auth_cookie(?b2l(User), Secret, TimeStamp)];
@@ -261,16 +261,16 @@ handle_session_req(#httpd{method='POST', mochi_req=MochiReq}=Req) ->
_ ->
[]
end,
- UserName = ?l2b(couch_util:get_value("name", Form, "")),
- Password = ?l2b(couch_util:get_value("password", Form, "")),
+ UserName = ?l2b(?getv("name", Form, "")),
+ Password = ?l2b(?getv("password", Form, "")),
?LOG_DEBUG("Attempt Login: ~s",[UserName]),
User = case couch_auth_cache:get_user_creds(UserName) of
nil -> [];
Result -> Result
end,
- UserSalt = couch_util:get_value(<<"salt">>, User, <<>>),
+ UserSalt = ?getv(<<"salt">>, User, <<>>),
PasswordHash = hash_password(Password, UserSalt),
- ExpectedHash = couch_util:get_value(<<"password_sha">>, User, nil),
+ ExpectedHash = ?getv(<<"password_sha">>, User, nil),
case couch_util:verify(ExpectedHash, PasswordHash) of
true ->
% setup the session cookie
@@ -287,8 +287,8 @@ handle_session_req(#httpd{method='POST', mochi_req=MochiReq}=Req) ->
send_json(Req#httpd{req_body=ReqBody}, Code, Headers,
{[
{ok, true},
- {name, couch_util:get_value(<<"name">>, User, null)},
- {roles, couch_util:get_value(<<"roles">>, User, [])}
+ {name, ?getv(<<"name">>, User, null)},
+ {roles, ?getv(<<"roles">>, User, [])}
]});
_Else ->
% clear the session