summaryrefslogtreecommitdiff
path: root/src/couch/include
diff options
context:
space:
mode:
authorEric Avdey <eiri@eiri.ca>2018-03-22 13:55:52 -0300
committerEric Avdey <eiri@eiri.ca>2018-03-23 17:59:01 -0300
commit45da9f307a5fa3d390c44289f87ed640082e0d37 (patch)
tree5d6750f9b2e90a3b6b2be7f76709895895d2afec /src/couch/include
parent89a727b625e74f40fcf612bda18421b8fc21eead (diff)
downloadcouchdb-45da9f307a5fa3d390c44289f87ed640082e0d37.tar.gz
Validate password_scheme in user doc
If `newDoc.password_scheme` provided validate that it is one of the supported types.
Diffstat (limited to 'src/couch/include')
-rw-r--r--src/couch/include/couch_js_functions.hrl9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/couch/include/couch_js_functions.hrl b/src/couch/include/couch_js_functions.hrl
index 6851718ff..d969416d6 100644
--- a/src/couch/include/couch_js_functions.hrl
+++ b/src/couch/include/couch_js_functions.hrl
@@ -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.\"});