@routr/simpleauth 2.0.5-alpha.10 → 2.0.5-alpha.13
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/runner.js +2 -1
- package/dist/service.d.ts +1 -0
- package/dist/service.js +17 -5
- package/package.json +5 -4
package/dist/runner.js
CHANGED
|
@@ -28,9 +28,10 @@ if (!process.env.PATH_TO_AUTH) {
|
|
|
28
28
|
logger_1.default.error("environment variable PATH_TO_AUTH is required but was not found");
|
|
29
29
|
process.exit(1);
|
|
30
30
|
}
|
|
31
|
+
const whiteList = process.env.WHITELIST ? process.env.WHITELIST.split(',') : [];
|
|
31
32
|
try {
|
|
32
33
|
const users = require(process.env.PATH_TO_AUTH);
|
|
33
|
-
service_1.default({ bindAddr: process.env.BIND_ADDR || "0.0.0.0:51903", users });
|
|
34
|
+
service_1.default({ bindAddr: process.env.BIND_ADDR || "0.0.0.0:51903", users, whiteList });
|
|
34
35
|
}
|
|
35
36
|
catch (e) {
|
|
36
37
|
if (e.code === "MODULE_NOT_FOUND") {
|
package/dist/service.d.ts
CHANGED
package/dist/service.js
CHANGED
|
@@ -26,14 +26,26 @@ const logger_1 = __importDefault(require("@fonoster/logger"));
|
|
|
26
26
|
const common_1 = require("@routr/common");
|
|
27
27
|
const utils_1 = require("./utils");
|
|
28
28
|
const processor_1 = __importDefault(require("@routr/processor"));
|
|
29
|
+
const api_1 = __importDefault(require("@opentelemetry/api"));
|
|
30
|
+
const common_2 = require("@routr/common");
|
|
31
|
+
const tracer = common_2.Tracer.init('simpleauth');
|
|
29
32
|
function SimpleAuthProcessor(config) {
|
|
30
|
-
const { bindAddr, users } = config;
|
|
33
|
+
const { bindAddr, users, whiteList } = config;
|
|
31
34
|
new processor_1.default({ bindAddr, name: "simpleauth" })
|
|
32
35
|
.listen((req, res) => {
|
|
33
|
-
logger_1.default.verbose(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
//
|
|
36
|
+
logger_1.default.verbose(`authenticating ${req.message.from.address.uri.user} endpoint with simpleauth`);
|
|
37
|
+
logger_1.default.silly(JSON.stringify(req, null, ' '));
|
|
38
|
+
const currentSpan = api_1.default.trace.getSpan(api_1.default.context.active());
|
|
39
|
+
// display traceid in the terminal
|
|
40
|
+
logger_1.default.verbose(`traceid: ${currentSpan.spanContext().traceId}`);
|
|
41
|
+
const span = tracer.startSpan('server.js:sayHello()', {
|
|
42
|
+
kind: 1,
|
|
43
|
+
attributes: { key: 'value' },
|
|
44
|
+
});
|
|
45
|
+
span.addEvent(`invoking sayHello() to...`);
|
|
46
|
+
if (whiteList.includes(req.message.from.address.uri.user)) {
|
|
47
|
+
return res.send(req);
|
|
48
|
+
}
|
|
37
49
|
// Calculate and return challenge
|
|
38
50
|
if (req.message.authorization) {
|
|
39
51
|
const auth = Object.assign({}, req.message.authorization);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@routr/simpleauth",
|
|
3
|
-
"version": "2.0.5-alpha.
|
|
3
|
+
"version": "2.0.5-alpha.13",
|
|
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",
|
|
@@ -20,8 +20,9 @@
|
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@fonoster/logger": "^0.3.3",
|
|
23
|
-
"@
|
|
24
|
-
"@routr/
|
|
23
|
+
"@opentelemetry/api": "^1.1.0",
|
|
24
|
+
"@routr/common": "^2.0.5-alpha.13",
|
|
25
|
+
"@routr/processor": "^2.0.5-alpha.13"
|
|
25
26
|
},
|
|
26
27
|
"files": [
|
|
27
28
|
"dist"
|
|
@@ -36,5 +37,5 @@
|
|
|
36
37
|
"bugs": {
|
|
37
38
|
"url": "https://github.com/fonoster/routr/issues"
|
|
38
39
|
},
|
|
39
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "6b2f1b6c1bd6b57ebc61189d6d198fe611790995"
|
|
40
41
|
}
|