mirror of
https://github.com/verdaccio/verdaccio.git
synced 2025-02-17 23:45:29 -05:00
bugfixes for htpasswd authentication
This commit is contained in:
parent
9275b2cc85
commit
a528811e35
2 changed files with 9 additions and 4 deletions
|
@ -158,9 +158,9 @@ Config.prototype.get_package_setting = function(package, setting) {
|
|||
}
|
||||
|
||||
Config.prototype.authenticate = function(user, password, cb) {
|
||||
if (this.users != null) {
|
||||
if (this.users[user] == null) return cb(null, false)
|
||||
if (crypto.createHash('sha1').update(password).digest('hex') === this.users[user].password) return cb(null, true)
|
||||
if (this.users != null && this.users[user] != null) {
|
||||
// if user exists in this.users, verify password against it no matter what is in htpasswd
|
||||
return cb(null, crypto.createHash('sha1').update(password).digest('hex') === this.users[user].password)
|
||||
}
|
||||
|
||||
if (!this.HTPasswd) return cb(null, false)
|
||||
|
@ -170,6 +170,11 @@ Config.prototype.authenticate = function(user, password, cb) {
|
|||
}
|
||||
|
||||
Config.prototype.add_user = function(user, password, cb) {
|
||||
if (this.users && this.users[user]) return cb(new UError({
|
||||
status: 409,
|
||||
message: 'this user already exists',
|
||||
}))
|
||||
|
||||
if (this.HTPasswd) {
|
||||
if (this.max_users || this.max_users == null) {
|
||||
var max_users = Number(this.max_users || Infinity)
|
||||
|
|
|
@ -223,7 +223,7 @@ module.exports = function(config_hash) {
|
|||
|
||||
res.status(201)
|
||||
return res.send({
|
||||
ok: 'user "' + req.remoteUser + '" created',
|
||||
ok: 'user "' + req.body.name + '" created',
|
||||
})
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue