2018-07-14 05:16:27 -05:00
|
|
|
// @flow
|
|
|
|
|
2018-07-15 12:26:58 -05:00
|
|
|
// this file is not aim to be tested, just to check flow definitions
|
|
|
|
|
2018-07-14 05:16:27 -05:00
|
|
|
import Config from '../../../../src/lib/config';
|
|
|
|
import LoggerApi from '../../../../src/lib/logger';
|
|
|
|
|
|
|
|
import type {
|
|
|
|
Config as AppConfig,
|
2018-07-15 12:26:58 -05:00
|
|
|
IPluginAuth,
|
2018-07-14 05:16:27 -05:00
|
|
|
Logger,
|
|
|
|
PluginOptions
|
|
|
|
} from '@verdaccio/types';
|
|
|
|
|
2018-07-15 12:26:58 -05:00
|
|
|
class ExampleAuthPlugin implements IPluginAuth {
|
2018-07-14 05:16:27 -05:00
|
|
|
config: AppConfig;
|
|
|
|
logger: Logger;
|
|
|
|
|
|
|
|
constructor(config: AppConfig, options: PluginOptions) {
|
|
|
|
this.config = config;
|
|
|
|
this.logger = options.logger;
|
|
|
|
}
|
|
|
|
|
|
|
|
authenticate(user: string, password: string, cb: verdaccio$Callback): void {
|
|
|
|
cb();
|
|
|
|
}
|
|
|
|
|
|
|
|
allow_access(packageName: string, user: string, cb: verdaccio$Callback): void {
|
|
|
|
cb();
|
|
|
|
}
|
|
|
|
|
|
|
|
allow_publish(packageName: string, user: string, cb: verdaccio$Callback): void {
|
|
|
|
cb();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const config1: AppConfig = new Config({
|
|
|
|
storage: './storage',
|
|
|
|
self_path: '/home/sotrage'
|
|
|
|
});
|
|
|
|
|
|
|
|
const options: PluginOptions = {
|
|
|
|
config: config1,
|
|
|
|
logger: LoggerApi.logger.child()
|
|
|
|
}
|
|
|
|
|
2018-07-15 12:26:58 -05:00
|
|
|
const auth = new ExampleAuthPlugin(config1, options);
|
|
|
|
|
|
|
|
auth.authenticate('user', 'pass', () => {});
|
|
|
|
auth.allow_access('packageName', 'user', () => {});
|
|
|
|
auth.allow_publish('packageName', 'user', () => {});
|