@axinom/mosaic-id-guard 0.9.2-rc.3 → 0.10.0
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/CHANGELOG.md +21 -0
- package/dist/common/guard-utils.d.ts +3 -3
- package/dist/common/guard-utils.d.ts.map +1 -1
- package/dist/common/guard-utils.js +4 -3
- package/dist/common/guard-utils.js.map +1 -1
- package/dist/common/parse-jwt-token.d.ts +13 -1
- package/dist/common/parse-jwt-token.d.ts.map +1 -1
- package/dist/common/parse-jwt-token.js +21 -1
- package/dist/common/parse-jwt-token.js.map +1 -1
- package/dist/graphql/enforce-strict-permissions.plugin.d.ts +2 -2
- package/dist/graphql/enforce-strict-permissions.plugin.d.ts.map +1 -1
- package/dist/graphql/enforce-strict-permissions.plugin.js +13 -10
- package/dist/graphql/enforce-strict-permissions.plugin.js.map +1 -1
- package/dist/graphql/guard.plugin.d.ts +2 -2
- package/dist/graphql/guard.plugin.js +4 -4
- package/dist/graphql/guard.plugin.js.map +1 -1
- package/dist/graphql/subscription-authorization-hook-factory.d.ts +1 -1
- package/dist/graphql/subscription-authorization-hook-factory.js +7 -7
- package/dist/graphql/subscription-authorization-hook-factory.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/message-bus/message-handler-authentication.d.ts.map +1 -1
- package/dist/message-bus/message-handler-authentication.js +2 -0
- package/dist/message-bus/message-handler-authentication.js.map +1 -1
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,27 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [0.10.0](https://dev.azure.com/axinom/CMS/_git/Navy/branchCompare?baseVersion=GT@axinom/mosaic-id-guard@0.9.1&targetVersion=GT@axinom/mosaic-id-guard@0.10.0) (2021-12-09)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* add new functions to jwt tokens ([80f68a6](https://dev.azure.com/axinom/CMS/_git/Navy/commit/80f68a64fc14108bc2feb4426573069cf31dcce4))
|
|
12
|
+
* change permission definition folder path ([1ea44e0](https://dev.azure.com/axinom/CMS/_git/Navy/commit/1ea44e0bb3bffe3df06ca511cb23df9b2b0fcbe3))
|
|
13
|
+
* fixed failed test cases ([def2783](https://dev.azure.com/axinom/CMS/_git/Navy/commit/def2783dbf0d07d7fa1cb43e2176dd376f95c57f))
|
|
14
|
+
* fixed PR commits ([a271b5c](https://dev.azure.com/axinom/CMS/_git/Navy/commit/a271b5ccb9dec8368a47932fa90d1f3fd07b449e))
|
|
15
|
+
* permission structure v2 changes all ([4ddff67](https://dev.azure.com/axinom/CMS/_git/Navy/commit/4ddff677d8a9d5f39a3cd15dc608d1fc4f06d419))
|
|
16
|
+
* permission structure v2 implement for api ([2db1f7c](https://dev.azure.com/axinom/CMS/_git/Navy/commit/2db1f7c90ae05786eaed49399ee943ef8687ff55))
|
|
17
|
+
* refactor permission table new columns ([9faa385](https://dev.azure.com/axinom/CMS/_git/Navy/commit/9faa3850035b6d62af9e65737b61931d570820c6))
|
|
18
|
+
* rename permission name in id service ([afa16b4](https://dev.azure.com/axinom/CMS/_git/Navy/commit/afa16b4d527532e7f72f30be3bae9dd2f1f6c700))
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Bug Fixes
|
|
22
|
+
|
|
23
|
+
* log improvements to id-guard ([a2d0290](https://dev.azure.com/axinom/CMS/_git/Navy/commit/a2d0290fae8ff8ec80f40430b22dc8262158ec9e))
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
6
27
|
### [0.9.1](https://dev.azure.com/axinom/CMS/_git/Navy/branchCompare?baseVersion=GT@axinom/mosaic-id-guard@0.9.0&targetVersion=GT@axinom/mosaic-id-guard@0.9.1) (2021-11-24)
|
|
7
28
|
|
|
8
29
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PermissionDefinition } from '@axinom/mosaic-id-utils';
|
|
2
2
|
import { AuthenticatedManagementSubject } from '.';
|
|
3
3
|
import { AxGuardErrorInfo } from './guard-error';
|
|
4
4
|
/**
|
|
@@ -14,9 +14,9 @@ export interface GqlAuthorizationOptions {
|
|
|
14
14
|
*/
|
|
15
15
|
serviceId: string;
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
17
|
+
* The permission definition contains a list of permissions and optionally, mappings of GQL operations to those permissions.
|
|
18
18
|
*/
|
|
19
|
-
|
|
19
|
+
permissionDefinition: PermissionDefinition;
|
|
20
20
|
}
|
|
21
21
|
export interface AxGuardOptions {
|
|
22
22
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guard-utils.d.ts","sourceRoot":"","sources":["../../src/common/guard-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL
|
|
1
|
+
{"version":3,"file":"guard-utils.d.ts","sourceRoot":"","sources":["../../src/common/guard-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,oBAAoB,EACrB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,8BAA8B,EAAE,MAAM,GAAG,CAAC;AAEnD,OAAO,EAAgB,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAC/D;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,oBAAoB,EAAE,oBAAoB,CAAC;CAC5C;AAED,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,wBAAwB,EAAE,OAAO,CAAC;IAElC;;OAEG;IACH,oBAAoB,EAAE,uBAAuB,CAAC;CAC/C;AAED,eAAO,MAAM,gBAAgB,SACrB,8BAA8B,GAAG,SAAS,WACvC,uBAAuB,aACrB,gBAAgB,GAAG,SAAS,KACtC,OAmDF,CAAC"}
|
|
@@ -5,8 +5,9 @@ const mosaic_id_utils_1 = require("@axinom/mosaic-id-utils");
|
|
|
5
5
|
const error_code_enum_1 = require("./error-code.enum");
|
|
6
6
|
const guard_error_1 = require("./guard-error");
|
|
7
7
|
const isUserAuthorized = (user, options, errorInfo) => {
|
|
8
|
-
|
|
9
|
-
const
|
|
8
|
+
var _a, _b;
|
|
9
|
+
const { serviceId, permissionDefinition, operation } = options;
|
|
10
|
+
const isAnonymousOperation = (_b = (_a = permissionDefinition.gqlOptions) === null || _a === void 0 ? void 0 : _a.anonymousGqlOperations) === null || _b === void 0 ? void 0 : _b.includes(operation);
|
|
10
11
|
if (isAnonymousOperation) {
|
|
11
12
|
return true;
|
|
12
13
|
}
|
|
@@ -35,7 +36,7 @@ const isUserAuthorized = (user, options, errorInfo) => {
|
|
|
35
36
|
// Not authorized to use this operation
|
|
36
37
|
if (user.permissions !== undefined && serviceId in user.permissions) {
|
|
37
38
|
const grantedPermissions = user.permissions[serviceId];
|
|
38
|
-
const requiredPermissions = mosaic_id_utils_1.getPermissionsForOperation(operation,
|
|
39
|
+
const requiredPermissions = mosaic_id_utils_1.getPermissionsForOperation(operation, permissionDefinition);
|
|
39
40
|
return grantedPermissions.some((permission) => requiredPermissions.includes(permission));
|
|
40
41
|
}
|
|
41
42
|
// Not authorized to use this service
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guard-utils.js","sourceRoot":"","sources":["../../src/common/guard-utils.ts"],"names":[],"mappings":";;;AAAA,6DAGiC;AAEjC,uDAA8C;AAC9C,+CAA+D;AAiCxD,MAAM,gBAAgB,GAAG,CAC9B,IAAgD,EAChD,OAAgC,EAChC,SAAuC,EAC9B,EAAE
|
|
1
|
+
{"version":3,"file":"guard-utils.js","sourceRoot":"","sources":["../../src/common/guard-utils.ts"],"names":[],"mappings":";;;AAAA,6DAGiC;AAEjC,uDAA8C;AAC9C,+CAA+D;AAiCxD,MAAM,gBAAgB,GAAG,CAC9B,IAAgD,EAChD,O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,CAAC,QAAQ,CAAC,UAAU,CAAC,CACzC,CAAC;KACH;IAED,qCAAqC;IACrC,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAvDW,QAAA,gBAAgB,oBAuD3B"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ConsumerAuthenticationContext, ManagementAuthenticationContext } from '.';
|
|
1
|
+
import { AuthenticatedConsumer, AuthenticatedManagementSubject, ConsumerAuthenticationContext, ManagementAuthenticationContext } from '.';
|
|
2
2
|
import { AuthenticationConfig } from './authentication-config.interface';
|
|
3
3
|
/**
|
|
4
4
|
* Parses a JWT token to produce an ManagementAuthenticationContext or a ConsumeAuthenticationContext with subject information and error information, if some error occurred during token processing.
|
|
@@ -7,4 +7,16 @@ import { AuthenticationConfig } from './authentication-config.interface';
|
|
|
7
7
|
* @param authType The type of Token that's being passed. Should be either `MANAGEMENT` or `CONSUMER`.
|
|
8
8
|
*/
|
|
9
9
|
export declare const parseJwtToken: (token: string | undefined, authConfig: string | AuthenticationConfig, authType?: "MANAGEMENT" | "CONSUMER" | undefined) => Promise<ManagementAuthenticationContext | ConsumerAuthenticationContext>;
|
|
10
|
+
/**
|
|
11
|
+
*
|
|
12
|
+
* @param token The raw JWT which should be decoded
|
|
13
|
+
* @returns An object of type `AuthenticatedManagementSubject`
|
|
14
|
+
*/
|
|
15
|
+
export declare const decodeManagementAccessToken: (token: string) => AuthenticatedManagementSubject;
|
|
16
|
+
/**
|
|
17
|
+
*
|
|
18
|
+
* @param token The raw JWT which should be decoded
|
|
19
|
+
* @returns An object of type `AuthenticatedConsumer`
|
|
20
|
+
*/
|
|
21
|
+
export declare const decodeConsumerAccessToken: (token: string) => AuthenticatedConsumer;
|
|
10
22
|
//# sourceMappingURL=parse-jwt-token.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-jwt-token.d.ts","sourceRoot":"","sources":["../../src/common/parse-jwt-token.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"parse-jwt-token.d.ts","sourceRoot":"","sources":["../../src/common/parse-jwt-token.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,qBAAqB,EACrB,8BAA8B,EAC9B,6BAA6B,EAK7B,+BAA+B,EAChC,MAAM,GAAG,CAAC;AACX,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAGzE;;;;;GAKG;AACH,eAAO,MAAM,aAAa,UACjB,MAAM,GAAG,SAAS,cACb,MAAM,GAAG,oBAAoB,uDAExC,QAAQ,+BAA+B,GAAG,6BAA6B,CAkFzE,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,2BAA2B,UAC/B,MAAM,KACZ,8BAEF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,UAC7B,MAAM,KACZ,qBAEF,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseJwtToken = void 0;
|
|
3
|
+
exports.decodeConsumerAccessToken = exports.decodeManagementAccessToken = exports.parseJwtToken = void 0;
|
|
4
|
+
const mosaic_service_common_1 = require("@axinom/mosaic-service-common");
|
|
4
5
|
const fs = require("fs");
|
|
5
6
|
const jwt = require("jsonwebtoken");
|
|
6
7
|
const jwks = require("jwks-rsa");
|
|
@@ -48,6 +49,7 @@ const parseJwtToken = async (token, authConfig, authType) => {
|
|
|
48
49
|
}
|
|
49
50
|
}
|
|
50
51
|
catch (err) {
|
|
52
|
+
mosaic_service_common_1.assertError(err);
|
|
51
53
|
if (err instanceof jwt.TokenExpiredError) {
|
|
52
54
|
code = _1.ErrorCode.AccessTokenExpired;
|
|
53
55
|
message = 'Access Token is expired';
|
|
@@ -91,4 +93,22 @@ const parseJwtToken = async (token, authConfig, authType) => {
|
|
|
91
93
|
}
|
|
92
94
|
};
|
|
93
95
|
exports.parseJwtToken = parseJwtToken;
|
|
96
|
+
/**
|
|
97
|
+
*
|
|
98
|
+
* @param token The raw JWT which should be decoded
|
|
99
|
+
* @returns An object of type `AuthenticatedManagementSubject`
|
|
100
|
+
*/
|
|
101
|
+
const decodeManagementAccessToken = (token) => {
|
|
102
|
+
return jwt.decode(token);
|
|
103
|
+
};
|
|
104
|
+
exports.decodeManagementAccessToken = decodeManagementAccessToken;
|
|
105
|
+
/**
|
|
106
|
+
*
|
|
107
|
+
* @param token The raw JWT which should be decoded
|
|
108
|
+
* @returns An object of type `AuthenticatedConsumer`
|
|
109
|
+
*/
|
|
110
|
+
const decodeConsumerAccessToken = (token) => {
|
|
111
|
+
return jwt.decode(token);
|
|
112
|
+
};
|
|
113
|
+
exports.decodeConsumerAccessToken = decodeConsumerAccessToken;
|
|
94
114
|
//# sourceMappingURL=parse-jwt-token.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-jwt-token.js","sourceRoot":"","sources":["../../src/common/parse-jwt-token.ts"],"names":[],"mappings":";;;AAAA,yBAAyB;AACzB,oCAAoC;AACpC,iCAAiC;AACjC,wBASW;AAEX,+CAAiD;AAEjD;;;;;GAKG;AACI,MAAM,aAAa,GAAG,KAAK,EAChC,KAAyB,EACzB,UAAyC,EACzC,QAAoC,EACsC,EAAE;IAC5E,IAAI,IAA2B,CAAC;IAChC,IAAI,OAA2B,CAAC;IAChC,IAAI,aAAgC,CAAC;IACrC,IAAI,OAGS,CAAC;IACd,IAAI,aAA2C,CAAC;IAEhD,IAAI;QACF,IAAI,KAAK,KAAK,SAAS,EAAE;YACvB,yIAAyI;YACzI,IAAI,OAAO,UAAU,KAAK,QAAQ,EAAE;gBAClC,MAAM,aAAa,GAAG,UAAoB,CAAC;gBAC3C,MAAM,SAAS,GAAG,EAAE,CAAC,YAAY,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;gBACzD,MAAM,OAAO,GAAG,GAAG,CAAC,MAAM,CAAC,KAAK,EAAE,SAAS,EAAE,sBAAmB,EAAE,CAAC,CAAC;gBACpE,OAAO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E;IAED,gDAAgD;IAChD,IAAI,OAAO,UAAU,KAAK,QAAQ,IAAI,QAAQ,KAAK,YAAY,EAAE;QAC/D,OAAO;YACL,OAAO,EAAE,OAAyC;YAClD,aAAa;SACd,CAAC;KACH;SAAM;QACL,OAAO;YACL,OAAO,EAAE,OAAgC;YACzC,aAAa;SACd,CAAC;KACH;AACH,CAAC,CAAC;AAtFW,QAAA,aAAa,iBAsFxB;AAEF;;;;GAIG;AACI,MAAM,2BAA2B,GAAG,CACzC,KAAa,EACmB,EAAE;IAClC,OAAO,GAAG,CAAC,MAAM,CAAC,KAAK,CAAmC,CAAC;AAC7D,CAAC,CAAC;AAJW,QAAA,2BAA2B,+BAItC;AAEF;;;;GAIG;AACI,MAAM,yBAAyB,GAAG,CACvC,KAAa,EACU,EAAE;IACzB,OAAO,GAAG,CAAC,MAAM,CAAC,KAAK,CAA0B,CAAC;AACpD,CAAC,CAAC;AAJW,QAAA,yBAAyB,6BAIpC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Plugin } from 'graphile-build';
|
|
2
2
|
/**
|
|
3
|
-
* This will omit any
|
|
3
|
+
* This will omit any operations currently not having any permission mappings for it.
|
|
4
4
|
*
|
|
5
|
-
* @param graphileBuildOptions should be of type `Partial<Options> & {
|
|
5
|
+
* @param graphileBuildOptions should be of type `Partial<Options> & { permissionDefinition: PermissionDefinition, logger: (log: string | LogMessage, type: LogType) => void }`
|
|
6
6
|
*/
|
|
7
7
|
export declare const EnforceStrictPermissionsPlugin: Plugin;
|
|
8
8
|
//# sourceMappingURL=enforce-strict-permissions.plugin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enforce-strict-permissions.plugin.d.ts","sourceRoot":"","sources":["../../src/graphql/enforce-strict-permissions.plugin.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAQxC;;;;GAIG;AACH,eAAO,MAAM,8BAA8B,EAAE,
|
|
1
|
+
{"version":3,"file":"enforce-strict-permissions.plugin.d.ts","sourceRoot":"","sources":["../../src/graphql/enforce-strict-permissions.plugin.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAQxC;;;;GAIG;AACH,eAAO,MAAM,8BAA8B,EAAE,MA0F5C,CAAC"}
|
|
@@ -5,20 +5,23 @@ const mosaic_id_utils_1 = require("@axinom/mosaic-id-utils");
|
|
|
5
5
|
const mosaic_service_common_1 = require("@axinom/mosaic-service-common");
|
|
6
6
|
const object_helpers_1 = require("../common/object.helpers");
|
|
7
7
|
/**
|
|
8
|
-
* This will omit any
|
|
8
|
+
* This will omit any operations currently not having any permission mappings for it.
|
|
9
9
|
*
|
|
10
|
-
* @param graphileBuildOptions should be of type `Partial<Options> & {
|
|
10
|
+
* @param graphileBuildOptions should be of type `Partial<Options> & { permissionDefinition: PermissionDefinition, logger: (log: string | LogMessage, type: LogType) => void }`
|
|
11
11
|
*/
|
|
12
|
-
const EnforceStrictPermissionsPlugin = (builder, {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
const EnforceStrictPermissionsPlugin = (builder, { permissionDefinition = {
|
|
13
|
+
gqlOptions: {
|
|
14
|
+
anonymousGqlOperations: [],
|
|
15
|
+
ignoredGqlOperations: [],
|
|
16
|
+
additionalGqlOperations: [],
|
|
17
|
+
},
|
|
18
|
+
permissions: [],
|
|
16
19
|
},
|
|
17
20
|
// eslint-disable-next-line no-console
|
|
18
|
-
logger = new mosaic_service_common_1.Logger(), }) => {
|
|
19
|
-
const mappedOperations = mosaic_id_utils_1.getMappedOperations(
|
|
20
|
-
const additionalOperations = mosaic_id_utils_1.getAdditionalOperations(
|
|
21
|
-
const ignoredOperations = mosaic_id_utils_1.getIgnoredOperations(
|
|
21
|
+
logger = new mosaic_service_common_1.Logger({ context: exports.EnforceStrictPermissionsPlugin.name }), }) => {
|
|
22
|
+
const mappedOperations = mosaic_id_utils_1.getMappedOperations(permissionDefinition).concat('query');
|
|
23
|
+
const additionalOperations = mosaic_id_utils_1.getAdditionalOperations(permissionDefinition) || new Array();
|
|
24
|
+
const ignoredOperations = mosaic_id_utils_1.getIgnoredOperations(permissionDefinition) || new Array();
|
|
22
25
|
let potentialSurplusOperations;
|
|
23
26
|
/* Whenever an additional field is added to the schema this hook is being called.
|
|
24
27
|
In this context, condition in lines 51-57 ensures that whenever this hook is being called,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enforce-strict-permissions.plugin.js","sourceRoot":"","sources":["../../src/graphql/enforce-strict-permissions.plugin.ts"],"names":[],"mappings":";;;AAAA,6DAKiC;AACjC,yEAAuD;AAEvD,6DAA4D;AAO5D;;;;GAIG;AACI,MAAM,8BAA8B,GAAW,CACpD,OAAO,EACP,EACE,
|
|
1
|
+
{"version":3,"file":"enforce-strict-permissions.plugin.js","sourceRoot":"","sources":["../../src/graphql/enforce-strict-permissions.plugin.ts"],"names":[],"mappings":";;;AAAA,6DAKiC;AACjC,yEAAuD;AAEvD,6DAA4D;AAO5D;;;;GAIG;AACI,MAAM,8BAA8B,GAAW,CACpD,OAAO,EACP,EACE,oBAAoB,GAAG;IACrB,UAAU,EAAE;QACV,sBAAsB,EAAE,EAAE;QAC1B,oBAAoB,EAAE,EAAE;QACxB,uBAAuB,EAAE,EAAE;KAC5B;IACD,WAAW,EAAE,EAAE;CAChB;AACD,sCAAsC;AACtC,MAAM,GAAG,IAAI,8BAAM,CAAC,EAAE,OAAO,EAAE,sCAA8B,CAAC,IAAI,EAAE,CAAC,GACvD,EAChB,EAAE;IACF,MAAM,gBAAgB,GACpB,qCAAmB,CAAC,oBAAoB,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAE5D,MAAM,oBAAoB,GACxB,yCAAuB,CAAC,oBAAoB,CAAC,IAAI,IAAI,KAAK,EAAU,CAAC;IACvE,MAAM,iBAAiB,GACrB,sCAAoB,CAAC,oBAAoB,CAAC,IAAI,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,2BAA2B;YAC3B,0BAA0B,GAAG,0BAA0B,CAAC,MAAM,CAC5D,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,aAAa,CAAC,QAAQ,CAAC,SAAS,CAAC,CAClD,CAAC;SACH;aAAM;YACL,8BAA8B;YAC9B,MAAM,iBAAiB,GAAG,0BAA0B,CAAC,MAAM,CACzD,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,aAAa,CAAC,QAAQ,CAAC,SAAS,CAAC,CAClD,CAAC;YAEF,IAAI,iBAAiB,CAAC,MAAM,EAAE;gBAC5B,MAAM,CAAC,IAAI,CAAC;oBACV,OAAO,EAAE,kDAAkD,iBAAiB,CAAC,MAAM,EAAE;oBACrF,OAAO,EAAE,EAAE,UAAU,EAAE,iBAAiB,EAAE;iBAC3C,CAAC,CAAC;aACJ;SACF;QAED,OAAO,iCAAgB,CAAC,MAAM,EAAE;YAC9B,GAAG,iBAAiB;YACpB,GAAG,iBAAiB;SACrB,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AA1FW,QAAA,8BAA8B,kCA0FzC"}
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* should be carried out as well.
|
|
5
5
|
* Error is thrown if request is not authorized. Applies to root and sub queries.
|
|
6
6
|
*
|
|
7
|
-
* @param additionalGraphQLContextFromRequest should be of type `Record<string, any> & { subject:
|
|
8
|
-
* @param graphileBuildOptions should be of type `Partial<Options> & {
|
|
7
|
+
* @param additionalGraphQLContextFromRequest should be of type `Record<string, any> & { subject: AuthenticatedSubject, authErrorInfo: AxGuardErrorInfo }`
|
|
8
|
+
* @param graphileBuildOptions should be of type `Partial<Options> & { permissionDefinition: PermissionDefinition, serviceId: string, ensureOnlyAuthentication: boolean }`
|
|
9
9
|
*/
|
|
10
10
|
export declare const AxGuardPlugin: import("graphile-build").Plugin;
|
|
11
11
|
//# sourceMappingURL=guard.plugin.d.ts.map
|
|
@@ -10,10 +10,10 @@ const guard_utils_1 = require("../common/guard-utils");
|
|
|
10
10
|
* should be carried out as well.
|
|
11
11
|
* Error is thrown if request is not authorized. Applies to root and sub queries.
|
|
12
12
|
*
|
|
13
|
-
* @param additionalGraphQLContextFromRequest should be of type `Record<string, any> & { subject:
|
|
14
|
-
* @param graphileBuildOptions should be of type `Partial<Options> & {
|
|
13
|
+
* @param additionalGraphQLContextFromRequest should be of type `Record<string, any> & { subject: AuthenticatedSubject, authErrorInfo: AxGuardErrorInfo }`
|
|
14
|
+
* @param graphileBuildOptions should be of type `Partial<Options> & { permissionDefinition: PermissionDefinition, serviceId: string, ensureOnlyAuthentication: boolean }`
|
|
15
15
|
*/
|
|
16
|
-
exports.AxGuardPlugin = graphile_utils_1.makeWrapResolversPlugin(({ scope }, build, config, { ensureOnlyAuthentication, serviceId,
|
|
16
|
+
exports.AxGuardPlugin = graphile_utils_1.makeWrapResolversPlugin(({ scope }, build, config, { ensureOnlyAuthentication, serviceId, permissionDefinition }) => {
|
|
17
17
|
const operationCanBeProtected = scope.fieldName !== 'query' &&
|
|
18
18
|
(scope.isRootQuery ||
|
|
19
19
|
scope.isRootMutation ||
|
|
@@ -26,7 +26,7 @@ exports.AxGuardPlugin = graphile_utils_1.makeWrapResolversPlugin(({ scope }, bui
|
|
|
26
26
|
authorizationOptions: {
|
|
27
27
|
operation: scope.fieldName,
|
|
28
28
|
serviceId,
|
|
29
|
-
|
|
29
|
+
permissionDefinition,
|
|
30
30
|
},
|
|
31
31
|
};
|
|
32
32
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guard.plugin.js","sourceRoot":"","sources":["../../src/graphql/guard.plugin.ts"],"names":[],"mappings":";;;AAAA,mDAAyD;AACzD,sCAMmB;AACnB,uDAAyE;AAEzE;;;;;;;;GAQG;AACU,QAAA,aAAa,GAAG,wCAAuB,CAClD,CACE,EAAE,KAAK,EAAE,EACT,KAAK,EACL,MAAM,EACN,EAAE,wBAAwB,EAAE,SAAS,EAAE,
|
|
1
|
+
{"version":3,"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,EAAE,kBAAS,CAAC,iBAAiB;gBACjC,OAAO,EAAE;oBACP,IAAI,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,GAAG;oBAClB,SAAS,EAAE,OAAO,CAAC,oBAAoB,CAAC,SAAS;iBAClD;aACF,CAAC,CAAC;SACJ;KACF;SAAM;QACL;;;;;WAKG;QACH,IAAI,aAAa,KAAK,SAAS,EAAE;YAC/B,MAAM,IAAI,qBAAY,CAAC,aAAa,CAAC,CAAC;SACvC;aAAM;YACL,OAAO,QAAQ,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC;SACrD;KACF;AACH,CAAC,CACJ,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Request, Response } from 'express';
|
|
2
2
|
import { PostGraphileOptions, PostGraphilePlugin } from 'postgraphile';
|
|
3
3
|
/**
|
|
4
|
-
* This is a hook plugin generator function that will use the
|
|
4
|
+
* This is a hook plugin generator function that will use the PermissionDefinition object in PostGraphileOptions
|
|
5
5
|
* to authorize the Subscription operation done over a web socket.
|
|
6
6
|
* It checks if the authenticated user which initiates the subscription has required permissions.
|
|
7
7
|
* The actual plugin is built using this function when the build() function is called in PostgraphileOptionsBuilder.
|
|
@@ -6,7 +6,7 @@ const graphql_ws_1 = require("graphql-ws");
|
|
|
6
6
|
const common_1 = require("../common");
|
|
7
7
|
const guard_utils_1 = require("../common/guard-utils");
|
|
8
8
|
/**
|
|
9
|
-
* This is a hook plugin generator function that will use the
|
|
9
|
+
* This is a hook plugin generator function that will use the PermissionDefinition object in PostGraphileOptions
|
|
10
10
|
* to authorize the Subscription operation done over a web socket.
|
|
11
11
|
* It checks if the authenticated user which initiates the subscription has required permissions.
|
|
12
12
|
* The actual plugin is built using this function when the build() function is called in PostgraphileOptionsBuilder.
|
|
@@ -27,11 +27,11 @@ const subscriptionAuthorizationHookFactory = (buildOptions) => {
|
|
|
27
27
|
if (buildOptions !== undefined &&
|
|
28
28
|
buildOptions.graphileBuildOptions !== undefined &&
|
|
29
29
|
subscription !== undefined) {
|
|
30
|
-
// Get
|
|
31
|
-
const
|
|
30
|
+
// Get permissionDefinition from graphileBuildOptions
|
|
31
|
+
const permissionDefinition = buildOptions === null || buildOptions === void 0 ? void 0 : buildOptions.graphileBuildOptions.permissionDefinition;
|
|
32
32
|
const options = {
|
|
33
33
|
operation: subscription.name.value,
|
|
34
|
-
|
|
34
|
+
permissionDefinition,
|
|
35
35
|
serviceId: params.context.config.serviceId,
|
|
36
36
|
};
|
|
37
37
|
const error = undefined;
|
|
@@ -67,11 +67,11 @@ const subscriptionAuthorizationHookFactory = (buildOptions) => {
|
|
|
67
67
|
if (buildOptions !== undefined &&
|
|
68
68
|
buildOptions.graphileBuildOptions !== undefined &&
|
|
69
69
|
subscription !== undefined) {
|
|
70
|
-
// Get
|
|
71
|
-
const
|
|
70
|
+
// Get permissionDefinition from graphileBuildOptions
|
|
71
|
+
const permissionDefinition = buildOptions === null || buildOptions === void 0 ? void 0 : buildOptions.graphileBuildOptions.permissionDefinition;
|
|
72
72
|
const options = {
|
|
73
73
|
operation: subscription.name.value,
|
|
74
|
-
|
|
74
|
+
permissionDefinition,
|
|
75
75
|
serviceId: args.contextValue.config.serviceId,
|
|
76
76
|
};
|
|
77
77
|
const error = undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscription-authorization-hook-factory.js","sourceRoot":"","sources":["../../src/graphql/subscription-authorization-hook-factory.ts"],"names":[],"mappings":";;;AAQA,6CAA8B;AAC9B,2CAAkE;AAQlE,sCAMmB;AACnB,uDAG+B;AAE/B;;;;;;;;GAQG;AACI,MAAM,oCAAoC,GAAG,CAClD,YAAgE,EAC5C,EAAE;IACtB,OAAO;QACL,qEAAqE;QACrE,6BAA6B,EAAE,CAAC,MAAuB,EAAE,EAAE;;YACzD,qCAAqC;YACrC,0DAA0D;YAC1D,MAAM,QAAQ,GAAG,qBAAG,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;YAC9C,MAAM,oBAAoB,GACxB,QAAQ,CAAC,WAAwC,CAAC;YAEpD,MAAM,YAAY,GAAG,eAAe,CAClC,oBAAoB,EACpB,MAAM,CAAC,aAAa,CACrB,CAAC;YAEF,IACE,YAAY,KAAK,SAAS;gBAC1B,YAAY,CAAC,oBAAoB,KAAK,SAAS;gBAC/C,YAAY,KAAK,SAAS,EAC1B;gBACA,
|
|
1
|
+
{"version":3,"file":"subscription-authorization-hook-factory.js","sourceRoot":"","sources":["../../src/graphql/subscription-authorization-hook-factory.ts"],"names":[],"mappings":";;;AAQA,6CAA8B;AAC9B,2CAAkE;AAQlE,sCAMmB;AACnB,uDAG+B;AAE/B;;;;;;;;GAQG;AACI,MAAM,oCAAoC,GAAG,CAClD,YAAgE,EAC5C,EAAE;IACtB,OAAO;QACL,qEAAqE;QACrE,6BAA6B,EAAE,CAAC,MAAuB,EAAE,EAAE;;YACzD,qCAAqC;YACrC,0DAA0D;YAC1D,MAAM,QAAQ,GAAG,qBAAG,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;YAC9C,MAAM,oBAAoB,GACxB,QAAQ,CAAC,WAAwC,CAAC;YAEpD,MAAM,YAAY,GAAG,eAAe,CAClC,oBAAoB,EACpB,MAAM,CAAC,aAAa,CACrB,CAAC;YAEF,IACE,YAAY,KAAK,SAAS;gBAC1B,YAAY,CAAC,oBAAoB,KAAK,SAAS;gBAC/C,YAAY,KAAK,SAAS,EAC1B;gBACA,qDAAqD;gBACrD,MAAM,oBAAoB,GAAG,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,oBAAoB,CAC5D,oBAA4C,CAAC;gBAEhD,MAAM,OAAO,GAA4B;oBACvC,SAAS,EAAE,YAAY,CAAC,IAAI,CAAC,KAAK;oBAClC,oBAAoB;oBACpB,SAAS,EAAE,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,SAAS;iBAC3C,CAAC;gBACF,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,CAAC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { getPermissionsForOperation,
|
|
1
|
+
export { getPermissionsForOperation, PermissionDefinition, } from '@axinom/mosaic-id-utils';
|
|
2
2
|
export * from './common';
|
|
3
3
|
export * from './graphql';
|
|
4
4
|
export * from './graphql/enforce-strict-permissions.plugin';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAC1B
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAC1B,oBAAoB,GACrB,MAAM,yBAAyB,CAAC;AACjC,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,6CAA6C,CAAC;AAC5D,cAAc,eAAe,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message-handler-authentication.d.ts","sourceRoot":"","sources":["../../src/message-bus/message-handler-authentication.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,WAAW,EACX,mBAAmB,EACpB,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"message-handler-authentication.d.ts","sourceRoot":"","sources":["../../src/message-bus/message-handler-authentication.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,WAAW,EACX,mBAAmB,EACpB,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EACL,qBAAqB,EACrB,8BAA8B,EAC9B,oBAAoB,EAErB,MAAM,WAAW,CAAC;AAEnB,MAAM,WAAW,yCAA0C,SAAQ,WAAW;IAC5E,OAAO,EAAE,8BAA8B,CAAC;CACzC;AAED,MAAM,WAAW,gCAAiC,SAAQ,WAAW;IACnE,OAAO,EAAE,qBAAqB,CAAC;CAChC;AAED;;;;GAIG;AACH,eAAO,MAAM,+BAA+B,YACjC,WAAW,KACnB,8BASF,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB,mCACvB,MAAM,GAAG,oBAAoB,mEAmC1C,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.authenticationMiddleware = exports.getMessageInfoManagementSubject = void 0;
|
|
4
|
+
const mosaic_service_common_1 = require("@axinom/mosaic-service-common");
|
|
4
5
|
const common_1 = require("../common");
|
|
5
6
|
/**
|
|
6
7
|
* Get the ManagementSubject that was extracted through the authenticationMiddleware. Throws an error if subject property is not present or empty.
|
|
@@ -36,6 +37,7 @@ const authenticationMiddleware = (authParams, enforceAuthentication = true) => {
|
|
|
36
37
|
subject;
|
|
37
38
|
}
|
|
38
39
|
catch (e) {
|
|
40
|
+
mosaic_service_common_1.assertError(e);
|
|
39
41
|
error = e;
|
|
40
42
|
}
|
|
41
43
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message-handler-authentication.js","sourceRoot":"","sources":["../../src/message-bus/message-handler-authentication.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"message-handler-authentication.js","sourceRoot":"","sources":["../../src/message-bus/message-handler-authentication.ts"],"names":[],"mappings":";;;AAKA,yEAA4D;AAE5D,sCAKmB;AAUnB;;;;GAIG;AACI,MAAM,+BAA+B,GAAG,CAC7C,OAAoB,EACY,EAAE;IAClC,MAAM,oBAAoB,GACxB,OAAoD,CAAC;IACvD,IAAI,oBAAoB,aAApB,oBAAoB,uBAApB,oBAAoB,CAAE,OAAO,EAAE;QACjC,OAAO,oBAAoB,CAAC,OAAO,CAAC;KACrC;IACD,MAAM,IAAI,KAAK,CACb,2IAA2I,CAC5I,CAAC;AACJ,CAAC,CAAC;AAXW,QAAA,+BAA+B,mCAW1C;AAEF;;;;;;GAMG;AACI,MAAM,wBAAwB,GAAG,CACtC,UAAyC,EACzC,qBAAqB,GAAG,IAAI,EACG,EAAE;IACjC,OAAO,KAAK,EACV,OAAkC,EAClC,OAA8B,EAC9B,SAAoB,EACpB,IAAoC,EACrB,EAAE;QACjB,IAAI,KAAK,GAAsB,SAAS,CAAC;QACzC,MAAM,KAAK,GAAG,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC;QAC1C,IAAI,KAAK,KAAK,SAAS,EAAE;YACvB,KAAK,GAAG,IAAI,KAAK,CACf,4EAA4E,CAC7E,CAAC;SACH;aAAM;YACL,IAAI;gBACF,MAAM,OAAO,GAAG,MAAM,0CAAiC,CACrD,KAAK,EACL,UAAU,CACX,CAAC;gBACD,OAAqD,CAAC,OAAO;oBAC5D,OAAO,CAAC;aACX;YAAC,OAAO,CAAC,EAAE;gBACV,mCAAW,CAAC,CAAC,CAAC,CAAC;gBACf,KAAK,GAAG,CAAC,CAAC;aACX;SACF;QAED,IAAI,qBAAqB,IAAI,KAAK,KAAK,SAAS,EAAE;YAChD,MAAM,KAAK,CAAC;SACb;QAED,MAAM,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAG,OAAO,EAAE,OAAO,EAAE,SAAS,CAAC,CAAA,CAAC;IAC5C,CAAC,CAAC;AACJ,CAAC,CAAC;AApCW,QAAA,wBAAwB,4BAoCnC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axinom/mosaic-id-guard",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "Authentication and authorization helpers for Axinom Mosaic services",
|
|
5
5
|
"author": "Axinom",
|
|
6
6
|
"license": "PROPRIETARY",
|
|
@@ -26,10 +26,10 @@
|
|
|
26
26
|
"test:ci": "jest --reporters=default --reporters=jest-junit --coverage --coverageReporters=cobertura --coverageReporters=html"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@axinom/mosaic-id-link-be": "^0.
|
|
30
|
-
"@axinom/mosaic-id-utils": "^0.
|
|
31
|
-
"@axinom/mosaic-message-bus": "^0.4.2
|
|
32
|
-
"@axinom/mosaic-service-common": "^0.10.0
|
|
29
|
+
"@axinom/mosaic-id-link-be": "^0.4.0",
|
|
30
|
+
"@axinom/mosaic-id-utils": "^0.4.0",
|
|
31
|
+
"@axinom/mosaic-message-bus": "^0.4.2",
|
|
32
|
+
"@axinom/mosaic-service-common": "^0.10.0",
|
|
33
33
|
"amqplib": "^0.6.0",
|
|
34
34
|
"express": "^4.17.1",
|
|
35
35
|
"express-bearer-token": "^2.4.0",
|
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"publishConfig": {
|
|
59
59
|
"access": "public"
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "de356e3d88414dc569d1291d00c21069c5e3556a"
|
|
62
62
|
}
|