Skip to content

Commit

Permalink
Validate password_scheme in user doc
Browse files Browse the repository at this point in the history
If `newDoc.password_scheme` provided validate that it is one
of the supported types.
  • Loading branch information
eiri committed Mar 23, 2018
1 parent 89a727b commit 45da9f3
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/couch/include/couch_js_functions.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,15 @@
});
}
var available_schemes = [\"simple\", \"pbkdf2\", \"bcrypt\"];
if (newDoc.password_scheme
&& available_schemes.indexOf(newDoc.password_scheme) == -1) {
throw({
forbidden: 'Password scheme `' + newDoc.password_scheme
+ '` not supported.'
});
}
if (newDoc.password_scheme === \"pbkdf2\") {
if (typeof(newDoc.iterations) !== \"number\") {
throw({forbidden: \"iterations must be a number.\"});
Expand Down

0 comments on commit 45da9f3

Please sign in to comment.