mirror of
https://github.com/verdaccio/verdaccio.git
synced 2024-12-16 21:56:25 -05:00
refactor: add generic time on load auth plugin
This commit is contained in:
parent
78d3364691
commit
73ab307260
1 changed files with 8 additions and 5 deletions
|
@ -1,17 +1,20 @@
|
||||||
// @flow
|
// @flow
|
||||||
|
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
|
||||||
|
import {API_ERROR, HTTP_STATUS, ROLES, TOKEN_BASIC, TOKEN_BEARER} from './constants';
|
||||||
import {loadPlugin} from '../lib/plugin-loader';
|
import {loadPlugin} from '../lib/plugin-loader';
|
||||||
import {buildBase64Buffer, ErrorCode} from './utils';
|
import {buildBase64Buffer, ErrorCode} from './utils';
|
||||||
import {aesDecrypt, aesEncrypt, signPayload, verifyPayload} from './crypto-utils';
|
import {aesDecrypt, aesEncrypt, signPayload, verifyPayload} from './crypto-utils';
|
||||||
|
import {getDefaultPlugins} from './auth-utils';
|
||||||
|
|
||||||
import type {Config, Logger, Callback} from '@verdaccio/types';
|
import {getMatchedPackagesSpec} from './config-utils';
|
||||||
|
|
||||||
|
import type {Config, Logger, Callback, IPluginAuth} from '@verdaccio/types';
|
||||||
import type {$Response, NextFunction} from 'express';
|
import type {$Response, NextFunction} from 'express';
|
||||||
import type {$RequestExtend, JWTPayload} from '../../types';
|
import type {$RequestExtend, JWTPayload} from '../../types';
|
||||||
import {API_ERROR, HTTP_STATUS, ROLES, TOKEN_BASIC, TOKEN_BEARER} from './constants';
|
|
||||||
import {getMatchedPackagesSpec} from './config-utils';
|
|
||||||
import type {IAuth} from '../../types';
|
import type {IAuth} from '../../types';
|
||||||
import {getDefaultPlugins} from './auth-utils';
|
|
||||||
|
|
||||||
const LoggerApi = require('./logger');
|
const LoggerApi = require('./logger');
|
||||||
|
|
||||||
|
@ -36,7 +39,7 @@ class Auth implements IAuth {
|
||||||
logger: this.logger,
|
logger: this.logger,
|
||||||
};
|
};
|
||||||
|
|
||||||
return loadPlugin(config, config.auth, pluginOptions, (plugin) => {
|
return loadPlugin<IPluginAuth>(config, config.auth, pluginOptions, (plugin: IPluginAuth) => {
|
||||||
const {authenticate, allow_access, allow_publish} = plugin;
|
const {authenticate, allow_access, allow_publish} = plugin;
|
||||||
|
|
||||||
return authenticate || allow_access || allow_publish;
|
return authenticate || allow_access || allow_publish;
|
||||||
|
|
Loading…
Reference in a new issue