2017-04-19 14:15:28 -05:00
|
|
|
'use strict';
|
2015-04-11 08:09:19 -05:00
|
|
|
|
2017-04-19 14:15:28 -05:00
|
|
|
module.exports = Plugin;
|
2015-04-11 08:09:19 -05:00
|
|
|
|
2017-07-01 17:05:58 -05:00
|
|
|
function Plugin(config) {
|
2017-04-19 14:15:28 -05:00
|
|
|
let self = Object.create(Plugin.prototype);
|
|
|
|
self._config = config;
|
|
|
|
return self;
|
2015-04-11 08:09:19 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// plugin is expected to be compatible with...
|
2017-04-19 14:15:28 -05:00
|
|
|
Plugin.prototype.verdaccio_version = '1.1.0';
|
2015-04-11 08:09:19 -05:00
|
|
|
|
|
|
|
Plugin.prototype.authenticate = function(user, password, cb) {
|
2017-07-01 17:05:58 -05:00
|
|
|
if (user !== this._config.accept_user) {
|
2015-04-11 08:09:19 -05:00
|
|
|
// delegate to next plugin
|
2017-04-19 14:15:28 -05:00
|
|
|
return cb(null, false);
|
2015-04-11 08:09:19 -05:00
|
|
|
}
|
2017-07-01 17:05:58 -05:00
|
|
|
if (password !== this._config.with_password) {
|
|
|
|
const err = Error('i don\'t like your password');
|
2017-04-19 14:15:28 -05:00
|
|
|
err.status = 403;
|
|
|
|
return cb(err);
|
2015-04-11 08:09:19 -05:00
|
|
|
}
|
2017-04-19 14:15:28 -05:00
|
|
|
return cb(null, [user]);
|
|
|
|
};
|