@fonoster/authz 0.8.25 → 0.8.26
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.
|
@@ -6,7 +6,7 @@ import { ServerInterceptingCall } from "@grpc/grpc-js";
|
|
|
6
6
|
* @param {string} authzServer - The public key to validate the token
|
|
7
7
|
* @return {Function} - The gRPC interceptor
|
|
8
8
|
*/
|
|
9
|
-
declare function
|
|
9
|
+
declare function createCheckMethodAuthorized(authzServer: string, methods: string[]): (methodDefinition: {
|
|
10
10
|
path: string;
|
|
11
11
|
}, call: ServerInterceptingCall) => ServerInterceptingCall;
|
|
12
|
-
export {
|
|
12
|
+
export { createCheckMethodAuthorized };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.createCheckMethodAuthorized = createCheckMethodAuthorized;
|
|
4
4
|
/*
|
|
5
5
|
* Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
|
|
6
6
|
* http://github.com/fonoster/fonoster
|
|
@@ -23,7 +23,6 @@ const common_1 = require("@fonoster/common");
|
|
|
23
23
|
const logger_1 = require("@fonoster/logger");
|
|
24
24
|
const grpc_js_1 = require("@grpc/grpc-js");
|
|
25
25
|
const AuthzClient_1 = require("./client/AuthzClient");
|
|
26
|
-
const identity_1 = require("@fonoster/identity");
|
|
27
26
|
const logger = (0, logger_1.getLogger)({ service: "authz", filePath: __filename });
|
|
28
27
|
/**
|
|
29
28
|
* This function is a gRPC interceptor that checks if the request a method is authorized
|
|
@@ -32,7 +31,7 @@ const logger = (0, logger_1.getLogger)({ service: "authz", filePath: __filename
|
|
|
32
31
|
* @param {string} authzServer - The public key to validate the token
|
|
33
32
|
* @return {Function} - The gRPC interceptor
|
|
34
33
|
*/
|
|
35
|
-
function
|
|
34
|
+
function createCheckMethodAuthorized(authzServer, methods) {
|
|
36
35
|
logger.verbose("creating check method authorized interceptor", {
|
|
37
36
|
authzServer,
|
|
38
37
|
methods
|
|
@@ -46,14 +45,14 @@ function makeCheckMethodAuthorized(authzServer, methods) {
|
|
|
46
45
|
* @param {ServerInterceptingCall} call - The call object
|
|
47
46
|
* @return {ServerInterceptingCall} - The modified call object
|
|
48
47
|
*/
|
|
49
|
-
return (methodDefinition, call)
|
|
48
|
+
return function checkMethodAuthorized(methodDefinition, call) {
|
|
50
49
|
const { path: method } = methodDefinition;
|
|
51
50
|
if (!methods.includes(method)) {
|
|
52
51
|
// Ignore the check if the method is not in the list
|
|
53
52
|
logger.silly("method is not in the list", { method });
|
|
54
53
|
return call;
|
|
55
54
|
}
|
|
56
|
-
const accessKeyId = (0,
|
|
55
|
+
const accessKeyId = (0, common_1.getAccessKeyIdFromCall)(call);
|
|
57
56
|
logger.verbose("checking if method is authorized", { method, accessKeyId });
|
|
58
57
|
return new grpc_js_1.ServerInterceptingCall(call, {
|
|
59
58
|
start: async (next) => {
|
|
@@ -75,7 +74,7 @@ function makeCheckMethodAuthorized(authzServer, methods) {
|
|
|
75
74
|
(0, common_1.createInterceptingCall)({
|
|
76
75
|
call,
|
|
77
76
|
code: grpc_js_1.status.PERMISSION_DENIED,
|
|
78
|
-
details: `Method
|
|
77
|
+
details: `Method unauthorized`
|
|
79
78
|
});
|
|
80
79
|
return;
|
|
81
80
|
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -34,5 +34,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
34
34
|
*/
|
|
35
35
|
__exportStar(require("./server"), exports);
|
|
36
36
|
__exportStar(require("./client"), exports);
|
|
37
|
-
__exportStar(require("./
|
|
37
|
+
__exportStar(require("./createCheckMethodAuthorized"), exports);
|
|
38
38
|
__exportStar(require("./types"), exports);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fonoster/authz",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.26",
|
|
4
4
|
"description": "Authorization module for Fonoster",
|
|
5
5
|
"author": "Pedro Sanders <psanders@fonoster.com>",
|
|
6
6
|
"homepage": "https://github.com/fonoster/fonoster#readme",
|
|
@@ -26,9 +26,9 @@
|
|
|
26
26
|
"access": "public"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@fonoster/common": "^0.8.
|
|
30
|
-
"@fonoster/identity": "^0.8.
|
|
31
|
-
"@fonoster/logger": "^0.8.
|
|
29
|
+
"@fonoster/common": "^0.8.26",
|
|
30
|
+
"@fonoster/identity": "^0.8.26",
|
|
31
|
+
"@fonoster/logger": "^0.8.26",
|
|
32
32
|
"@grpc/grpc-js": "~1.10.6",
|
|
33
33
|
"deepmerge": "^4.3.1",
|
|
34
34
|
"grpc-health-check": "^2.0.2"
|
|
@@ -40,5 +40,5 @@
|
|
|
40
40
|
"bugs": {
|
|
41
41
|
"url": "https://github.com/fonoster/fonoster/issues"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "f01e634eca9a94b3a276369e998c6e75f8b75284"
|
|
44
44
|
}
|