@routr/simpleauth 2.0.20 → 2.0.34
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 +2 -2
- package/dist/service.d.ts +3 -3
- package/dist/service.js +4 -4
- package/package.json +4 -4
- package/dist/healthcheck.d.ts +0 -2
- package/dist/healthcheck.js +0 -24
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
|
@@ -24,9 +24,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
24
24
|
*/
|
|
25
25
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
26
26
|
require("./tracer").init("simpleauth");
|
|
27
|
-
const service_1 = __importDefault(require("./service"));
|
|
28
27
|
const logger_1 = require("@fonoster/logger");
|
|
29
28
|
const envs_1 = require("./envs");
|
|
29
|
+
const service_1 = __importDefault(require("./service"));
|
|
30
30
|
const logger = (0, logger_1.getLogger)({ service: "simpleauth", filePath: __filename });
|
|
31
31
|
try {
|
|
32
32
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
@@ -34,7 +34,7 @@ try {
|
|
|
34
34
|
(0, service_1.default)({
|
|
35
35
|
users,
|
|
36
36
|
bindAddr: envs_1.BIND_ADDR,
|
|
37
|
-
|
|
37
|
+
allowlist: envs_1.ALLOWLIST,
|
|
38
38
|
methods: envs_1.METHODS
|
|
39
39
|
});
|
|
40
40
|
}
|
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.0.34",
|
|
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.0.31",
|
|
33
|
+
"@routr/processor": "^2.0.31",
|
|
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": "08d6e74366c68070d2b8812627eda6fbe61ee6fc"
|
|
50
50
|
}
|
package/dist/healthcheck.d.ts
DELETED
package/dist/healthcheck.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
/*
|
|
5
|
-
* Copyright (C) 2023 by Fonoster Inc (https://fonoster.com)
|
|
6
|
-
* http://github.com/fonoster
|
|
7
|
-
*
|
|
8
|
-
* This file is part of Routr.
|
|
9
|
-
*
|
|
10
|
-
* Licensed under the MIT License (the "License");
|
|
11
|
-
* you may not use this file except in compliance with
|
|
12
|
-
* the License. You may obtain a copy of the License at
|
|
13
|
-
*
|
|
14
|
-
* https://opensource.org/licenses/MIT
|
|
15
|
-
*
|
|
16
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
17
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
18
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
19
|
-
* See the License for the specific language governing permissions and
|
|
20
|
-
* limitations under the License.
|
|
21
|
-
*/
|
|
22
|
-
const common_1 = require("@routr/common");
|
|
23
|
-
const envs_1 = require("./envs");
|
|
24
|
-
common_1.HealthCheck.check(envs_1.BIND_ADDR);
|