0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-12-16 21:56:25 -05:00

chore: add info to log when audit, htpasswd, theme are used (#4956)

* chore: add info to log when audit, htpasswd, theme are used

* fix

* fix

* fix logger
This commit is contained in:
Marc Bernard 2024-11-24 08:01:24 -05:00 committed by GitHub
parent 4a6a921ead
commit 9041b0f9ad
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 34 additions and 9 deletions

View file

@ -0,0 +1,8 @@
---
'@verdaccio/server': patch
'@verdaccio/store': patch
'@verdaccio/auth': patch
'@verdaccio/web': patch
---
chore: add info to log when audit, htpasswd, theme are used

View file

@ -94,6 +94,10 @@ class Auth implements IAuthMiddleware, TokenEncryption, pluginUtils.IBasicAuth {
{ file: './htpasswd' },
pluginOptions as any as pluginUtils.PluginOptions
);
this.logger.info(
{ name: 'verdaccio-htpasswd', pluginCategory: PLUGIN_CATEGORY.AUTHENTICATION },
'plugin @{name} successfully loaded (@{pluginCategory})'
);
} catch (error: any) {
debug('error on loading auth htpasswd plugin stack: %o', error);
this.logger.info({}, 'no auth plugin has been found');

View file

@ -78,9 +78,15 @@ const defineAPI = async function (config: IConfig, storage: Storage): Promise<Ex
);
if (plugins.length === 0) {
logger.info('none middleware plugins has been defined, adding audit middleware by default');
// @ts-ignore
plugins.push(new AuditMiddleware({ enabled: true, strict_ssl: true }, { config, logger }));
const auditPlugin = new AuditMiddleware(
{ enabled: true, strict_ssl: true },
{ config, logger }
);
logger.info(
{ name: 'verdaccio-audit', pluginCategory: PLUGIN_CATEGORY.MIDDLEWARE },
'plugin @{name} successfully loaded (@{pluginCategory})'
);
plugins.push(auditPlugin);
}
plugins.forEach((plugin: pluginUtils.ExpressMiddleware<IConfig, {}, Auth>) => {
@ -97,7 +103,7 @@ const defineAPI = async function (config: IConfig, storage: Storage): Promise<Ex
res.locals.app_version = version ?? '';
next();
});
const middleware = await webMiddleware(config, auth, storage);
const middleware = await webMiddleware(config, auth, storage, logger);
app.use(middleware);
} else {
app.get('/', function (req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer) {

View file

@ -62,8 +62,8 @@ class LocalStorage {
debug('no custom storage found, loading default storage @verdaccio/local-storage');
const localStorage = new LocalDatabase(config, logger);
logger.info(
{ pluginCategory: PLUGIN_CATEGORY.STORAGE },
'plugin @verdaccio/local-storage successfully loaded (@{pluginCategory})'
{ name: '@verdaccio/local-storage', pluginCategory: PLUGIN_CATEGORY.STORAGE },
'plugin @{name} successfully loaded (@{pluginCategory})'
);
return localStorage;
}

View file

@ -27,15 +27,22 @@ export async function loadTheme(config: any) {
PLUGIN_CATEGORY.THEME
);
if (plugin.length > 1) {
logger.warn('multiple ui themes are not supported , only the first plugin is used used');
logger.warn('multiple ui themes are not supported; only the first plugin is used');
}
return _.head(plugin);
}
}
export default async (config, auth, storage) => {
const pluginOptions = (await loadTheme(config)) || require('@verdaccio/ui-theme')(config.web);
export default async (config, auth, storage, logger) => {
let pluginOptions = await loadTheme(config);
if (!pluginOptions) {
pluginOptions = require('@verdaccio/ui-theme')(config.web);
logger.info(
{ name: '@verdaccio/ui-theme', pluginCategory: PLUGIN_CATEGORY.THEME },
'plugin @{name} successfully loaded (@{pluginCategory})'
);
}
// eslint-disable-next-line new-cap
const router = express.Router();