@routr/simpleauth 2.0.31 → 2.1.0
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/dist/envs.d.ts +1 -1
- package/dist/envs.js +2 -2
- package/dist/runner.js +1 -1
- package/dist/service.d.ts +3 -3
- package/dist/service.js +4 -4
- package/package.json +4 -4
package/dist/envs.d.ts
CHANGED
package/dist/envs.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var _a, _b, _c, _d, _e;
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.PATH_TO_AUTH = exports.METHODS = exports.
|
|
4
|
+
exports.PATH_TO_AUTH = exports.METHODS = exports.ALLOWLIST = exports.BIND_ADDR = void 0;
|
|
5
5
|
/*
|
|
6
6
|
* Copyright (C) 2023 by Fonoster Inc (https://fonoster.com)
|
|
7
7
|
* http://github.com/fonoster
|
|
@@ -23,6 +23,6 @@ exports.PATH_TO_AUTH = exports.METHODS = exports.WHITELIST = exports.BIND_ADDR =
|
|
|
23
23
|
const common_1 = require("@routr/common");
|
|
24
24
|
common_1.Assertions.assertEnvsAreSet(["PATH_TO_AUTH", "METHODS"]);
|
|
25
25
|
exports.BIND_ADDR = (_a = process.env.BIND_ADDR) !== null && _a !== void 0 ? _a : "0.0.0.0:51903";
|
|
26
|
-
exports.
|
|
26
|
+
exports.ALLOWLIST = (_c = (_b = process.env.ALLOWLIST) === null || _b === void 0 ? void 0 : _b.split(",")) !== null && _c !== void 0 ? _c : [];
|
|
27
27
|
exports.METHODS = (_e = (_d = process.env.METHODS) === null || _d === void 0 ? void 0 : _d.split(",")) !== null && _e !== void 0 ? _e : [];
|
|
28
28
|
exports.PATH_TO_AUTH = process.env.PATH_TO_AUTH;
|
package/dist/runner.js
CHANGED
package/dist/service.d.ts
CHANGED
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
import { User } from "./types";
|
|
3
3
|
/**
|
|
4
4
|
* A simple authentication middleware that authenticates users based on a list of users
|
|
5
|
-
* or
|
|
5
|
+
* or allowlist endpoints paths.
|
|
6
6
|
*
|
|
7
7
|
* @param {MiddlewareConfig} config - configuration for the middleware
|
|
8
8
|
* @param {string} config.bindAddr - address to bind to
|
|
9
9
|
* @param {User[]} config.users - list of users
|
|
10
|
-
* @param {string[]} config.
|
|
10
|
+
* @param {string[]} config.allowlist - list of path that required no authentication
|
|
11
11
|
*/
|
|
12
12
|
export default function simpleAuthMiddleware(config: {
|
|
13
13
|
bindAddr: string;
|
|
14
14
|
users: User[];
|
|
15
|
-
|
|
15
|
+
allowlist: string[];
|
|
16
16
|
methods: string[];
|
|
17
17
|
}): void;
|
package/dist/service.js
CHANGED
|
@@ -29,15 +29,15 @@ const logger_1 = require("@fonoster/logger");
|
|
|
29
29
|
const logger = (0, logger_1.getLogger)({ service: "simpledata", filePath: __filename });
|
|
30
30
|
/**
|
|
31
31
|
* A simple authentication middleware that authenticates users based on a list of users
|
|
32
|
-
* or
|
|
32
|
+
* or allowlist endpoints paths.
|
|
33
33
|
*
|
|
34
34
|
* @param {MiddlewareConfig} config - configuration for the middleware
|
|
35
35
|
* @param {string} config.bindAddr - address to bind to
|
|
36
36
|
* @param {User[]} config.users - list of users
|
|
37
|
-
* @param {string[]} config.
|
|
37
|
+
* @param {string[]} config.allowlist - list of path that required no authentication
|
|
38
38
|
*/
|
|
39
39
|
function simpleAuthMiddleware(config) {
|
|
40
|
-
const { bindAddr, users,
|
|
40
|
+
const { bindAddr, users, allowlist, methods } = config;
|
|
41
41
|
new processor_1.default({ bindAddr, name: "simpleauth" }).listen((req, res) => {
|
|
42
42
|
const tracer = api_1.default.trace.getTracer("routr-tracer");
|
|
43
43
|
const currentSpan = api_1.default.trace.getSpan(api_1.default.context.active());
|
|
@@ -48,7 +48,7 @@ function simpleAuthMiddleware(config) {
|
|
|
48
48
|
if (!methods.includes(req.method)) {
|
|
49
49
|
return res.send(req);
|
|
50
50
|
}
|
|
51
|
-
if (
|
|
51
|
+
if (allowlist.includes(req.message.from.address.uri.user)) {
|
|
52
52
|
span.addEvent(`authenticated ${req.message.from.address.uri.user} from whitelist`);
|
|
53
53
|
span.end();
|
|
54
54
|
return res.send(req);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@routr/simpleauth",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "This middleware delegates authentication to an external service",
|
|
5
5
|
"author": "Pedro Sanders <psanders@fonoster.com>",
|
|
6
6
|
"homepage": "https://github.com/fonoster/routr#readme",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"@opentelemetry/sdk-trace-base": "^1.0.4",
|
|
30
30
|
"@opentelemetry/sdk-trace-node": "^1.0.4",
|
|
31
31
|
"@opentelemetry/semantic-conventions": "^1.0.4",
|
|
32
|
-
"@routr/common": "^2.0
|
|
33
|
-
"@routr/processor": "^2.0
|
|
32
|
+
"@routr/common": "^2.1.0",
|
|
33
|
+
"@routr/processor": "^2.1.0",
|
|
34
34
|
"google-protobuf": "^3.9.2"
|
|
35
35
|
},
|
|
36
36
|
"files": [
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"bugs": {
|
|
47
47
|
"url": "https://github.com/fonoster/routr/issues"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "0e75c7950157dcb7701082655259a87da322c29d"
|
|
50
50
|
}
|