zyket 1.1.10 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zyket",
3
- "version": "1.1.10",
3
+ "version": "1.2.1",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -22,6 +22,7 @@
22
22
  "cors": "^2.8.6",
23
23
  "dotenv": "^17.3.1",
24
24
  "express": "^5.2.1",
25
+ "express-basic-auth": "^1.2.1",
25
26
  "fast-glob": "^3.3.3",
26
27
  "mariadb": "^3.5.2",
27
28
  "minio": "^8.0.7",
@@ -2,6 +2,7 @@ const Extension = require('../Extension');
2
2
  const { createBullBoard } = require('@bull-board/api')
3
3
  const { BullMQAdapter } = require('@bull-board/api/bullMQAdapter')
4
4
  const { ExpressAdapter } = require('@bull-board/express')
5
+ const basicAuth = require('express-basic-auth')
5
6
 
6
7
  module.exports = class BullBoardExtension extends Extension {
7
8
  path;
@@ -23,6 +24,15 @@ module.exports = class BullBoardExtension extends Extension {
23
24
  })
24
25
 
25
26
  const app = container.get('express').app()
26
- app.use(this.path, serverAdapter.getRouter())
27
+ const middlewares = []
28
+
29
+ if (process.env.BULLBOARD_ADMIN_PASSWORD) {
30
+ middlewares.push(basicAuth({
31
+ users: { admin: process.env.BULLBOARD_ADMIN_PASSWORD },
32
+ challenge: true,
33
+ }))
34
+ }
35
+
36
+ app.use(this.path, ...middlewares, serverAdapter.getRouter())
27
37
  }
28
38
  }
@@ -33,7 +33,7 @@ module.exports = class Express extends Service {
33
33
 
34
34
  const corsOptions = await this.#loadCorsOrCreateDefault();
35
35
 
36
- this.#app.use(cors(corsOptions));
36
+ if(corsOptions) this.#app.use(cors(corsOptions));
37
37
 
38
38
  // Swagger setup
39
39
  const swaggerOptions = {
@@ -171,7 +171,7 @@ module.exports = class Express extends Service {
171
171
  this.#container.get('logger').info("No CORS configuration found. Creating default config/cors.js");
172
172
  fs.mkdirSync(path.join(process.cwd(), "config"), { recursive: true });
173
173
  this.#container.get('template-manager').installFile('default/config/cors', corsConfigPath);
174
- corsOptions = { origin: '*' };
174
+ corsOptions = false;
175
175
  }
176
176
  return corsOptions;
177
177
  }