@lokalise/fastify-bullboard-plugin 1.1.1 → 1.1.3
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/README.md +17 -4
- package/dist/basicAuth.js +9 -4
- package/dist/basicAuth.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -30,12 +30,25 @@ await app.register(basicAuth, {
|
|
|
30
30
|
|
|
31
31
|
await app.register(bullBoard, {
|
|
32
32
|
queueConstructor: Queue, // can be QueuePro if bullmq-pro is used
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
redisConfigs: [
|
|
34
|
+
{
|
|
35
|
+
host: process.env.REDIS_HOST!,
|
|
36
|
+
port: Number(process.env.REDIS_PORT),
|
|
37
|
+
username: process.env.REDIS_USERNAME,
|
|
38
|
+
password: process.env.REDIS_PASSWORD,
|
|
39
|
+
keyPrefix: process.env.REDIS_KEY_PREFIX,
|
|
40
|
+
useTls: false,
|
|
41
|
+
} // any Redis config
|
|
37
42
|
],
|
|
38
43
|
basePath: '/bull',
|
|
39
44
|
refreshIntervalInSeconds: config.bullBoard.refreshIntervalInSeconds,
|
|
40
45
|
})
|
|
41
46
|
```
|
|
47
|
+
|
|
48
|
+
## Compatibility with existing fastify plugins
|
|
49
|
+
|
|
50
|
+
`@lokalise/fastify-bullboard-plugin/basicAuth` registers it own instance of `fastifyBasicAuth`, it will not work if you also have it installed in your fastify app.
|
|
51
|
+
|
|
52
|
+
It will also attempt registering `fastifyAuth` if it is not yet registered, so if you prefer to register it explicitly in your app, make sure that `@lokalise/fastify-bullboard-plugin/basicAuth` is registered after `fastifyAuth`.
|
|
53
|
+
|
|
54
|
+
`bullBoard` attempts to register `fastifySchedule` if it's not already registered, so if you are registering it explicitly in your app, make sure that `bullBoard` plugin is registered after `fastifySchedule`.
|
package/dist/basicAuth.js
CHANGED
|
@@ -14,17 +14,22 @@ function validate(config) {
|
|
|
14
14
|
}
|
|
15
15
|
function enableListAuthHandler(enableList) {
|
|
16
16
|
return (req, _res, done) => {
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
// If the route is NOT in enableList, allow through: skip auth
|
|
18
|
+
if (!req.routeOptions.url || !enableList.has(req.routeOptions.url)) {
|
|
19
|
+
return done(); // success: skip the rest of the handlers
|
|
19
20
|
}
|
|
20
|
-
|
|
21
|
+
// If the route IS in enableList, fail: go to next handler (basicAuth)
|
|
22
|
+
// String for performance, it also works
|
|
23
|
+
return done('Needs auth');
|
|
21
24
|
};
|
|
22
25
|
}
|
|
23
26
|
async function plugin(fastify, pluginOptions) {
|
|
24
27
|
if (!pluginOptions.config.isEnabled) {
|
|
25
28
|
return;
|
|
26
29
|
}
|
|
27
|
-
|
|
30
|
+
if (!fastify.auth) {
|
|
31
|
+
await fastify.register(fastifyAuth);
|
|
32
|
+
}
|
|
28
33
|
await fastify.register(fastifyBasicAuth, {
|
|
29
34
|
validate: validate(pluginOptions.config),
|
|
30
35
|
authenticate: true,
|
package/dist/basicAuth.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"basicAuth.js","sourceRoot":"","sources":["../src/basicAuth.ts"],"names":[],"mappings":"AACA,OAAO,WAAW,MAAM,eAAe,CAAA;AACvC,OAAO,gBAAgB,MAAM,qBAAqB,CAAA;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAErD,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAa/B,SAAS,QAAQ,CAAC,MAAkB;IAClC,OAAO,CACL,QAAgB,EAChB,QAAgB,EAChB,IAAoB,EACpB,MAAoB,EACpB,IAA2B,EAC3B,EAAE;QACF,IAAI,QAAQ,KAAK,MAAM,CAAC,QAAQ,IAAI,QAAQ,KAAK,MAAM,CAAC,QAAQ,EAAE,CAAC;YACjE,IAAI,EAAE,CAAA;QACR,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,IAAI,eAAe,EAAE,CAAC,CAAA;Q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