@mondaydotcomorg/monday-authorization 1.0.8 → 1.0.10
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.
|
@@ -25,7 +25,7 @@ function getAuthorizationMiddleware(action, resourceGetter, contextGetter) {
|
|
|
25
25
|
const isAuthorized = yield authorization_service_1.AuthorizationService.isAuthorized(accountId, userId, resources, action);
|
|
26
26
|
authorization_internal_service_1.AuthorizationInternalService.markAuthorized(request);
|
|
27
27
|
if (!isAuthorized) {
|
|
28
|
-
response.status(
|
|
28
|
+
response.status(403).json({ message: 'Access denied' });
|
|
29
29
|
return;
|
|
30
30
|
}
|
|
31
31
|
next();
|
|
@@ -41,7 +41,9 @@ exports.skipAuthorizationMiddleware = skipAuthorizationMiddleware;
|
|
|
41
41
|
function authorizationCheckMiddleware(request, response, next) {
|
|
42
42
|
if (process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test') {
|
|
43
43
|
on_headers_1.default(response, function () {
|
|
44
|
-
|
|
44
|
+
if (response.statusCode < 400) {
|
|
45
|
+
authorization_internal_service_1.AuthorizationInternalService.failIfNotCoveredByAuthorization(request);
|
|
46
|
+
}
|
|
45
47
|
});
|
|
46
48
|
}
|
|
47
49
|
next();
|
|
@@ -34,7 +34,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
34
34
|
exports.AuthorizationService = void 0;
|
|
35
35
|
const monday_jwt_1 = require("@mondaydotcomorg/monday-jwt");
|
|
36
36
|
const MondayLogger = __importStar(require("@mondaydotcomorg/monday-logger"));
|
|
37
|
-
const
|
|
37
|
+
const monday_fetch_1 = __importDefault(require("@mondaydotcomorg/monday-fetch"));
|
|
38
38
|
const INTERNAL_APP_NAME = 'internal_ms';
|
|
39
39
|
const URL = `${process.env.MONDAY_INTERNAL_URL}/internal_ms/authorization/authorize`;
|
|
40
40
|
const IS_DEV_ENV = process.env.NODE_ENV === 'development';
|
|
@@ -45,7 +45,7 @@ class AuthorizationService {
|
|
|
45
45
|
return __awaiter(this, void 0, void 0, function* () {
|
|
46
46
|
const internalAuthToken = monday_jwt_1.signAuthorizationHeader(INTERNAL_APP_NAME, accountId);
|
|
47
47
|
const params = createAuthorizationParams(resources, action);
|
|
48
|
-
const response = yield
|
|
48
|
+
const response = yield monday_fetch_1.default(URL, {
|
|
49
49
|
method: 'POST',
|
|
50
50
|
headers: { Authorization: internalAuthToken, 'Content-Type': 'application/json' },
|
|
51
51
|
timeout: REQUEST_TIMEOUT,
|
|
@@ -53,7 +53,7 @@ class AuthorizationService {
|
|
|
53
53
|
user_id: userId,
|
|
54
54
|
authorize_request_objects: params.authorizationObjects,
|
|
55
55
|
}),
|
|
56
|
-
});
|
|
56
|
+
}, { retries: 3, callback: logOnFetchFail });
|
|
57
57
|
if (!response.ok) {
|
|
58
58
|
logger.error({ status: response.status }, 'Authorization middleware: authorization request failed');
|
|
59
59
|
return false;
|
|
@@ -92,3 +92,6 @@ function createAuthorizationParams(resources, action) {
|
|
|
92
92
|
};
|
|
93
93
|
return params;
|
|
94
94
|
}
|
|
95
|
+
function logOnFetchFail(retries, error, response) {
|
|
96
|
+
logger.error({ attempt: retries, error }, 'Authorization attempt failed due to network issues');
|
|
97
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mondaydotcomorg/monday-authorization",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.10",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"license": "BSD-3-Clause",
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@mondaydotcomorg/monday-authentication": "^5.0.4",
|
|
13
|
+
"@mondaydotcomorg/monday-fetch": "^0.0.2",
|
|
13
14
|
"@mondaydotcomorg/monday-jwt": "^2.0.4",
|
|
14
15
|
"@mondaydotcomorg/monday-logger": "^2.1.2",
|
|
15
16
|
"@types/express": "^4.17.12",
|
|
@@ -30,5 +31,5 @@
|
|
|
30
31
|
"files": [
|
|
31
32
|
"dist/"
|
|
32
33
|
],
|
|
33
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "27da993cbc76e1787a3a006ee5f78df9a1192ff9"
|
|
34
35
|
}
|