mirror of
https://github.com/verdaccio/verdaccio.git
synced 2024-12-30 22:34:10 -05:00
refactor(auth): remove deprecated add user logic
This commit is contained in:
parent
a5ac23ef14
commit
67c63892d3
2 changed files with 1 additions and 32 deletions
|
@ -1,14 +1,6 @@
|
||||||
# path to a directory with all packages
|
# path to a directory with all packages
|
||||||
storage: ./storage
|
storage: ./storage
|
||||||
|
|
||||||
# a list of users
|
|
||||||
#
|
|
||||||
# This is deprecated, use auth plugins instead (see htpasswd below).
|
|
||||||
# users:
|
|
||||||
# admin:
|
|
||||||
# crypto.createHash('sha1').update(pass).digest('hex')
|
|
||||||
# password: a94a8fe5ccb19ba61c4c0873d391e987982fbbd3
|
|
||||||
|
|
||||||
web:
|
web:
|
||||||
# WebUI is enabled as default, if you want disable it, just uncomment this line
|
# WebUI is enabled as default, if you want disable it, just uncomment this line
|
||||||
#enable: false
|
#enable: false
|
||||||
|
|
|
@ -37,30 +37,6 @@ class Auth {
|
||||||
return p.authenticate || p.allow_access || p.allow_publish;
|
return p.authenticate || p.allow_access || p.allow_publish;
|
||||||
});
|
});
|
||||||
|
|
||||||
this.plugins.unshift({
|
|
||||||
verdaccio_version: pkgJson.version,
|
|
||||||
|
|
||||||
authenticate: function(user, password, cb) {
|
|
||||||
if (config.users != null
|
|
||||||
&& config.users[user] != null
|
|
||||||
&& (Crypto.createHash('sha1').update(password).digest('hex')
|
|
||||||
=== config.users[user].password)
|
|
||||||
) {
|
|
||||||
return cb(null, [user]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return cb();
|
|
||||||
},
|
|
||||||
|
|
||||||
adduser: function(user, password, cb) {
|
|
||||||
if (config.users && config.users[user]) {
|
|
||||||
return cb(Error[403]('this user already exists'));
|
|
||||||
}
|
|
||||||
|
|
||||||
return cb();
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const allow_action = function(action) {
|
const allow_action = function(action) {
|
||||||
return function(user, pkg, cb) {
|
return function(user, pkg, cb) {
|
||||||
let ok = pkg[action].reduce(function(prev, curr) {
|
let ok = pkg[action].reduce(function(prev, curr) {
|
||||||
|
@ -138,6 +114,7 @@ class Auth {
|
||||||
if (typeof(p[n]) !== 'function') {
|
if (typeof(p[n]) !== 'function') {
|
||||||
next();
|
next();
|
||||||
} else {
|
} else {
|
||||||
|
// p.add_user() execution
|
||||||
p[n](user, password, function(err, ok) {
|
p[n](user, password, function(err, ok) {
|
||||||
if (err) return cb(err);
|
if (err) return cb(err);
|
||||||
if (ok) return self.authenticate(user, password, cb);
|
if (ok) return self.authenticate(user, password, cb);
|
||||||
|
|
Loading…
Reference in a new issue