Created
April 6, 2014 17:14
-
-
Save rnewson/10008876 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/couchdb/couch_httpd_auth.erl b/src/couchdb/couch_httpd_auth.erl | |
index 08841fb..91acc1d 100644 | |
--- a/src/couchdb/couch_httpd_auth.erl | |
+++ b/src/couchdb/couch_httpd_auth.erl | |
@@ -367,12 +367,21 @@ authenticate(Pass, UserProps) -> | |
{couch_passwords:simple(Pass, UserSalt), | |
couch_util:get_value(<<"password_sha">>, UserProps, nil)}; | |
<<"pbkdf2">> -> | |
- Iterations = couch_util:get_value(<<"iterations">>, UserProps, 10000), | |
+ Iterations = iterations(UserProps), | |
{couch_passwords:pbkdf2(Pass, UserSalt, Iterations), | |
couch_util:get_value(<<"derived_key">>, UserProps, nil)} | |
end, | |
couch_passwords:verify(PasswordHash, ExpectedHash). | |
+iterations(UserProps) -> | |
+ Default = 10000, | |
+ case couch_util:get_value(<<"iterations">>, UserProps, Default) of | |
+ Iterations when is_integer(Iterations) -> | |
+ Iterations; | |
+ _ -> | |
+ Default | |
+ end. | |
+ | |
auth_name(String) when is_list(String) -> | |
[_,_,_,_,_,Name|_] = re:split(String, "[\\W_]", [{return, list}]), | |
?l2b(Name). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment