mirror of
https://github.com/Viren070/tmdb-addon.git
synced 2025-12-01 23:18:11 +01:00
feat(security): add authentication to Swagger Stats UI
- feat(security): implement basic auth for /stats/ui endpoint - feat(security): add METRICS_USER and METRICS_PASSWORD env variables This change adds a layer of security to the metrics dashboard, requiring authentication to access the Swagger Stats UI.
This commit is contained in:
@@ -17,15 +17,15 @@ class Analytics {
|
||||
}
|
||||
|
||||
this.middleware = swaggerStats.getMiddleware({
|
||||
name: 'TMDB Addon',
|
||||
version: '3.1.3',
|
||||
name: packageJson.name,
|
||||
version: packageJson.version,
|
||||
timelineBucketDuration: 60000,
|
||||
uriPath: '/stats/ui',
|
||||
authentication: false,
|
||||
authentication: true,
|
||||
onAuthenticate: (req, username, password) => {
|
||||
return true;
|
||||
return username === process.env.METRICS_USER
|
||||
&& password === process.env.METRICS_PASSWORD
|
||||
},
|
||||
elasticsearch: false,
|
||||
mongodb: {
|
||||
uri: mongodbUri,
|
||||
collectionPrefix: 'stats_'
|
||||
@@ -33,7 +33,7 @@ class Analytics {
|
||||
swaggerSpec: {
|
||||
info: {
|
||||
title: 'TMDB Addon API',
|
||||
version: '3.1.3'
|
||||
version: packageJson.version
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user