@routr/simpleauth 2.0.5-alpha.11 → 2.0.5-alpha.14
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 +19 -7
- package/package.json +15 -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
|
@@ -22,24 +22,36 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
22
22
|
* See the License for the specific language governing permissions and
|
|
23
23
|
* limitations under the License.
|
|
24
24
|
*/
|
|
25
|
-
const logger_1 = __importDefault(require("@fonoster/logger"));
|
|
26
25
|
const common_1 = require("@routr/common");
|
|
26
|
+
const tracer = common_1.Tracer.init("simpleauth");
|
|
27
|
+
const api_1 = __importDefault(require("@opentelemetry/api"));
|
|
28
|
+
const logger_1 = __importDefault(require("@fonoster/logger"));
|
|
29
|
+
const common_2 = require("@routr/common");
|
|
27
30
|
const utils_1 = require("./utils");
|
|
28
31
|
const processor_1 = __importDefault(require("@routr/processor"));
|
|
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);
|
|
40
52
|
auth.method = req.method;
|
|
41
53
|
// Calculate response and compare with the one send by the endpoint
|
|
42
|
-
const calcRes =
|
|
54
|
+
const calcRes = common_2.calculateAuthResponse(auth, utils_1.getCredentials(auth.username, users));
|
|
43
55
|
if (calcRes !== auth.response) {
|
|
44
56
|
return res.send(utils_1.createUnauthorizedResponse(auth.realm));
|
|
45
57
|
}
|
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.14",
|
|
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,19 @@
|
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@fonoster/logger": "^0.3.3",
|
|
23
|
-
"@
|
|
24
|
-
"@
|
|
23
|
+
"@grpc/grpc-js": "^1.3.7",
|
|
24
|
+
"@opentelemetry/api": "^1.0.2",
|
|
25
|
+
"@opentelemetry/exporter-jaeger": "^1.0.1",
|
|
26
|
+
"@opentelemetry/exporter-zipkin": "^1.0.1",
|
|
27
|
+
"@opentelemetry/instrumentation": "^0.27.0",
|
|
28
|
+
"@opentelemetry/instrumentation-grpc": "^0.27.0",
|
|
29
|
+
"@opentelemetry/resources": "^1.0.1",
|
|
30
|
+
"@opentelemetry/sdk-trace-base": "^1.0.1",
|
|
31
|
+
"@opentelemetry/sdk-trace-node": "^1.0.1",
|
|
32
|
+
"@opentelemetry/semantic-conventions": "^1.0.1",
|
|
33
|
+
"@routr/common": "^2.0.5-alpha.14",
|
|
34
|
+
"@routr/processor": "^2.0.5-alpha.14",
|
|
35
|
+
"google-protobuf": "^3.9.2"
|
|
25
36
|
},
|
|
26
37
|
"files": [
|
|
27
38
|
"dist"
|
|
@@ -36,5 +47,5 @@
|
|
|
36
47
|
"bugs": {
|
|
37
48
|
"url": "https://github.com/fonoster/routr/issues"
|
|
38
49
|
},
|
|
39
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "6dd8fe8ce94c72a1d669c98466bead23400875ce"
|
|
40
51
|
}
|