@axinom/mosaic-id-guard 0.11.0-rc.3 → 0.11.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 +18 -0
- package/dist/common/assert-consumer-token-type.d.ts +14 -0
- package/dist/common/assert-consumer-token-type.d.ts.map +1 -0
- package/dist/common/assert-consumer-token-type.js +30 -0
- package/dist/common/assert-consumer-token-type.js.map +1 -0
- package/dist/common/authenticated-subject.interface.d.ts +8 -2
- package/dist/common/authenticated-subject.interface.d.ts.map +1 -1
- package/dist/common/authentication-request-context.interface.d.ts +3 -3
- package/dist/common/authentication-request-context.interface.d.ts.map +1 -1
- package/dist/common/error-code.enum.d.ts +1 -0
- package/dist/common/error-code.enum.d.ts.map +1 -1
- package/dist/common/error-code.enum.js +1 -0
- package/dist/common/error-code.enum.js.map +1 -1
- package/dist/common/get-authenticated-subject.d.ts +4 -4
- package/dist/common/get-authenticated-subject.d.ts.map +1 -1
- package/dist/common/get-authenticated-subject.js +14 -6
- package/dist/common/get-authenticated-subject.js.map +1 -1
- package/dist/common/guard-error.d.ts +1 -1
- package/dist/common/guard-error.d.ts.map +1 -1
- package/dist/common/guard-error.js.map +1 -1
- package/dist/common/helpers/parse-jwt-token-error-handler.d.ts +12 -0
- package/dist/common/helpers/parse-jwt-token-error-handler.d.ts.map +1 -0
- package/dist/common/helpers/parse-jwt-token-error-handler.js +97 -0
- package/dist/common/helpers/parse-jwt-token-error-handler.js.map +1 -0
- package/dist/common/index.d.ts +1 -0
- package/dist/common/index.d.ts.map +1 -1
- package/dist/common/index.js +1 -0
- package/dist/common/index.js.map +1 -1
- package/dist/common/parse-jwt-token.d.ts +1 -1
- package/dist/common/parse-jwt-token.d.ts.map +1 -1
- package/dist/common/parse-jwt-token.js +35 -41
- package/dist/common/parse-jwt-token.js.map +1 -1
- package/dist/common/subject-type.enum.d.ts +2 -1
- package/dist/common/subject-type.enum.d.ts.map +1 -1
- package/dist/common/subject-type.enum.js +1 -0
- package/dist/common/subject-type.enum.js.map +1 -1
- package/dist/graphql/guard.middleware.d.ts +4 -1
- package/dist/graphql/guard.middleware.d.ts.map +1 -1
- package/dist/graphql/guard.middleware.js +12 -9
- package/dist/graphql/guard.middleware.js.map +1 -1
- package/dist/graphql/index.d.ts +1 -1
- package/dist/graphql/index.d.ts.map +1 -1
- package/dist/graphql/index.js +8 -1
- package/dist/graphql/index.js.map +1 -1
- package/package.json +8 -6
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,24 @@
|
|
|
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.11.0](https://dev.azure.com/axinom/CMS/_git/Navy/branchCompare?baseVersion=GT@axinom/mosaic-id-guard@0.10.1&targetVersion=GT@axinom/mosaic-id-guard@0.11.0) (2022-02-02)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* add new endpoint to generate Consumer Application token ([79e1123](https://dev.azure.com/axinom/CMS/_git/Navy/commit/79e11239b21bad8876a3ee0c173d0d043b32ab5e))
|
|
12
|
+
* anonymous consumer token WIP ([280a075](https://dev.azure.com/axinom/CMS/_git/Navy/commit/280a075d4da97b24915c6a2c6a71158a1f4c03c5))
|
|
13
|
+
* rebase with master branch ([fe969fa](https://dev.azure.com/axinom/CMS/_git/Navy/commit/fe969fac8a5e64c98174faefd61288907e10eefd))
|
|
14
|
+
* remove additionalGqlOperations from permission definition ([305b448](https://dev.azure.com/axinom/CMS/_git/Navy/commit/305b4487db5292b41cbe6792abbbb4401bb2f9ee))
|
|
15
|
+
* set default ts version ([16ce926](https://dev.azure.com/axinom/CMS/_git/Navy/commit/16ce92627bec279b93f5b21fe6ae830361f201a8))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* update unit test for permission ([7b21914](https://dev.azure.com/axinom/CMS/_git/Navy/commit/7b2191419ffc11aec9579b7c2b0057a5c1427424))
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
6
24
|
### [0.10.1](https://dev.azure.com/axinom/CMS/_git/Navy/branchCompare?baseVersion=GT@axinom/mosaic-id-guard@0.10.0&targetVersion=GT@axinom/mosaic-id-guard@0.10.1) (2022-01-19)
|
|
7
25
|
|
|
8
26
|
**Note:** Version bump only for package @axinom/mosaic-id-guard
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AuthenticatedConsumer, AuthenticatedConsumerApplication } from './authenticated-subject.interface';
|
|
2
|
+
/**
|
|
3
|
+
* Asserts if the passed subject object is of type AuthenticatedConsumer.
|
|
4
|
+
*
|
|
5
|
+
* @param subject subject object of type unknown
|
|
6
|
+
*/
|
|
7
|
+
export declare const assertAuthenticatedConsumer: (subject: unknown) => asserts subject is AuthenticatedConsumer;
|
|
8
|
+
/**
|
|
9
|
+
* Asserts if the passed subject object is of type AuthenticatedConsumerApplication.
|
|
10
|
+
*
|
|
11
|
+
* @param subject subject object of type unknown
|
|
12
|
+
*/
|
|
13
|
+
export declare const assertConsumerApplication: (subject: unknown) => asserts subject is AuthenticatedConsumerApplication;
|
|
14
|
+
//# sourceMappingURL=assert-consumer-token-type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assert-consumer-token-type.d.ts","sourceRoot":"","sources":["../../src/common/assert-consumer-token-type.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,qBAAqB,EACrB,gCAAgC,EACjC,MAAM,mCAAmC,CAAC;AAE3C;;;;GAIG;AACH,eAAO,MAAM,2BAA2B,EAAE,CACxC,OAAO,EAAE,OAAO,KACb,OAAO,CAAC,OAAO,IAAI,qBASvB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,EAAE,CACtC,OAAO,EAAE,OAAO,KACb,OAAO,CAAC,OAAO,IAAI,gCASvB,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.assertConsumerApplication = exports.assertAuthenticatedConsumer = void 0;
|
|
4
|
+
const mosaic_service_common_1 = require("@axinom/mosaic-service-common");
|
|
5
|
+
const _1 = require(".");
|
|
6
|
+
/**
|
|
7
|
+
* Asserts if the passed subject object is of type AuthenticatedConsumer.
|
|
8
|
+
*
|
|
9
|
+
* @param subject subject object of type unknown
|
|
10
|
+
*/
|
|
11
|
+
const assertAuthenticatedConsumer = (subject) => {
|
|
12
|
+
if (subject.subjectType !==
|
|
13
|
+
_1.SubjectType.ConsumerAccount) {
|
|
14
|
+
throw new mosaic_service_common_1.GeneralError(`The token is not an Authenticated Consumer`);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
exports.assertAuthenticatedConsumer = assertAuthenticatedConsumer;
|
|
18
|
+
/**
|
|
19
|
+
* Asserts if the passed subject object is of type AuthenticatedConsumerApplication.
|
|
20
|
+
*
|
|
21
|
+
* @param subject subject object of type unknown
|
|
22
|
+
*/
|
|
23
|
+
const assertConsumerApplication = (subject) => {
|
|
24
|
+
if (subject.subjectType !==
|
|
25
|
+
_1.SubjectType.ConsumerApplication) {
|
|
26
|
+
throw new mosaic_service_common_1.GeneralError(`The token is not an Consumer Application`);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
exports.assertConsumerApplication = assertConsumerApplication;
|
|
30
|
+
//# sourceMappingURL=assert-consumer-token-type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assert-consumer-token-type.js","sourceRoot":"","sources":["../../src/common/assert-consumer-token-type.ts"],"names":[],"mappings":";;;AAAA,yEAA6D;AAC7D,wBAAgC;AAMhC;;;;GAIG;AACI,MAAM,2BAA2B,GAEQ,CAC9C,OAAgB,EAC0B,EAAE;IAC5C,IACG,OAAiC,CAAC,WAAW;QAC9C,cAAW,CAAC,eAAe,EAC3B;QACA,MAAM,IAAI,oCAAY,CAAC,4CAA4C,CAAC,CAAC;KACtE;AACH,CAAC,CAAC;AAXW,QAAA,2BAA2B,+BAWtC;AAEF;;;;GAIG;AACI,MAAM,yBAAyB,GAEqB,CACzD,OAAgB,EACqC,EAAE;IACvD,IACG,OAA4C,CAAC,WAAW;QACzD,cAAW,CAAC,mBAAmB,EAC/B;QACA,MAAM,IAAI,oCAAY,CAAC,0CAA0C,CAAC,CAAC;KACpE;AACH,CAAC,CAAC;AAXW,QAAA,yBAAyB,6BAWpC"}
|
|
@@ -39,11 +39,17 @@ export interface AuthenticatedManagementSubject extends GenericAuthenticatedSubj
|
|
|
39
39
|
[key: string]: unknown;
|
|
40
40
|
}
|
|
41
41
|
/**
|
|
42
|
-
* Represents an
|
|
42
|
+
* Represents an authenticated Consumer Application created to access consumer-facing APIs for a specific tenant + environment + application.
|
|
43
43
|
* This will be created using a token issued by the ax-user-service.
|
|
44
44
|
*/
|
|
45
|
-
export interface
|
|
45
|
+
export interface AuthenticatedConsumerApplication extends GenericAuthenticatedSubject {
|
|
46
46
|
applicationId: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Represents an Authenticated Consumer, created to be used in Consumer Applications.
|
|
50
|
+
* This will be created using a token issued by the ax-user-service.
|
|
51
|
+
*/
|
|
52
|
+
export interface AuthenticatedConsumer extends AuthenticatedConsumerApplication {
|
|
47
53
|
sessionId: string;
|
|
48
54
|
profileId: string;
|
|
49
55
|
extensions: unknown;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authenticated-subject.interface.d.ts","sourceRoot":"","sources":["../../src/common/authenticated-subject.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD,qFAAqF;AACrF,MAAM,WAAW,eAAe;IAC9B,gBAAgB;IAChB,QAAQ,EAAE,MAAM,CAAC;IAEjB,qBAAqB;IACrB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,qEAAqE;AACrE,UAAU,2BAA4B,SAAQ,eAAe;IAC3D,2CAA2C;IAC3C,GAAG,EAAE,MAAM,CAAC;IAEZ,iDAAiD;IACjD,GAAG,EAAE,MAAM,CAAC;IAEZ,4BAA4B;IAC5B,GAAG,EAAE,MAAM,CAAC;IAEZ,0BAA0B;IAC1B,GAAG,EAAE,MAAM,CAAC;IAEZ,yBAAyB;IACzB,GAAG,EAAE,MAAM,CAAC;IAEZ,mBAAmB;IACnB,IAAI,EAAE,MAAM,CAAC;IAEb,oBAAoB;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,0BAA0B;IAC1B,WAAW,EAAE,WAAW,CAAC;CAC1B;AAED;;;GAGG;AACH,MAAM,WAAW,8BACf,SAAQ,2BAA2B;IACnC,0CAA0C;IAC1C,WAAW,EAAE;QACX,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;KACzB,CAAC;IAEF,mCAAmC;IACnC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAEhB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;;GAGG;AACH,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"authenticated-subject.interface.d.ts","sourceRoot":"","sources":["../../src/common/authenticated-subject.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD,qFAAqF;AACrF,MAAM,WAAW,eAAe;IAC9B,gBAAgB;IAChB,QAAQ,EAAE,MAAM,CAAC;IAEjB,qBAAqB;IACrB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,qEAAqE;AACrE,UAAU,2BAA4B,SAAQ,eAAe;IAC3D,2CAA2C;IAC3C,GAAG,EAAE,MAAM,CAAC;IAEZ,iDAAiD;IACjD,GAAG,EAAE,MAAM,CAAC;IAEZ,4BAA4B;IAC5B,GAAG,EAAE,MAAM,CAAC;IAEZ,0BAA0B;IAC1B,GAAG,EAAE,MAAM,CAAC;IAEZ,yBAAyB;IACzB,GAAG,EAAE,MAAM,CAAC;IAEZ,mBAAmB;IACnB,IAAI,EAAE,MAAM,CAAC;IAEb,oBAAoB;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,0BAA0B;IAC1B,WAAW,EAAE,WAAW,CAAC;CAC1B;AAED;;;GAGG;AACH,MAAM,WAAW,8BACf,SAAQ,2BAA2B;IACnC,0CAA0C;IAC1C,WAAW,EAAE;QACX,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;KACzB,CAAC;IAEF,mCAAmC;IACnC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAEhB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;;GAGG;AACH,MAAM,WAAW,gCACf,SAAQ,2BAA2B;IACnC,aAAa,EAAE,MAAM,CAAC;CACvB;AAED;;;GAGG;AACH,MAAM,WAAW,qBACf,SAAQ,gCAAgC;IACxC,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,OAAO,CAAC;CACrB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Request } from 'express';
|
|
2
|
-
import { AuthenticatedConsumer, AuthenticatedManagementSubject } from '.';
|
|
2
|
+
import { AuthenticatedConsumer, AuthenticatedConsumerApplication, AuthenticatedManagementSubject } from '.';
|
|
3
3
|
import { AxGuardErrorInfo } from './guard-error';
|
|
4
4
|
/** Authenticated Subject and error information for Management Tokens */
|
|
5
5
|
export interface ManagementAuthenticationContext {
|
|
@@ -8,10 +8,10 @@ export interface ManagementAuthenticationContext {
|
|
|
8
8
|
/** Authentication error information */
|
|
9
9
|
authErrorInfo?: AxGuardErrorInfo;
|
|
10
10
|
}
|
|
11
|
-
/** Authenticated Consumer and error information for Consumer Tokens */
|
|
11
|
+
/** Authenticated Consumer/Application and error information for Consumer Tokens */
|
|
12
12
|
export interface ConsumerAuthenticationContext {
|
|
13
13
|
/** Authenticated End User information */
|
|
14
|
-
subject?: AuthenticatedConsumer;
|
|
14
|
+
subject?: AuthenticatedConsumer | AuthenticatedConsumerApplication;
|
|
15
15
|
/** Authentication error information */
|
|
16
16
|
authErrorInfo?: AxGuardErrorInfo;
|
|
17
17
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authentication-request-context.interface.d.ts","sourceRoot":"","sources":["../../src/common/authentication-request-context.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,
|
|
1
|
+
{"version":3,"file":"authentication-request-context.interface.d.ts","sourceRoot":"","sources":["../../src/common/authentication-request-context.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EACL,qBAAqB,EACrB,gCAAgC,EAChC,8BAA8B,EAC/B,MAAM,GAAG,CAAC;AACX,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEjD,wEAAwE;AACxE,MAAM,WAAW,+BAA+B;IAC9C,mDAAmD;IACnD,OAAO,CAAC,EAAE,8BAA8B,CAAC;IAEzC,uCAAuC;IACvC,aAAa,CAAC,EAAE,gBAAgB,CAAC;CAClC;AAED,mFAAmF;AACnF,MAAM,WAAW,6BAA6B;IAC5C,yCAAyC;IACzC,OAAO,CAAC,EAAE,qBAAqB,GAAG,gCAAgC,CAAC;IAEnE,uCAAuC;IACvC,aAAa,CAAC,EAAE,gBAAgB,CAAC;CAClC;AAED,8DAA8D;AAC9D,MAAM,WAAW,8BAA+B,SAAQ,OAAO;IAC7D,kDAAkD;IAClD,WAAW,EAAE,+BAA+B,CAAC;CAC9C;AAED,4DAA4D;AAC5D,MAAM,WAAW,4BAA6B,SAAQ,OAAO;IAC3D,kDAAkD;IAClD,WAAW,EAAE,6BAA6B,CAAC;CAC5C"}
|
|
@@ -7,6 +7,7 @@ export declare enum ErrorCode {
|
|
|
7
7
|
JwksError = "JWKS_ERROR",
|
|
8
8
|
AccessTokenVerificationFailed = "ACCESS_TOKEN_VERIFICATION_FAILED",
|
|
9
9
|
IdentityServiceNotAccessible = "IDENTITY_SERVICE_NOT_ACCESSIBLE",
|
|
10
|
+
UserServiceNotAccessible = "USER_SERVICE_NOT_ACCESSIBLE",
|
|
10
11
|
AuthConfigInvalid = "AUTH_CONFIG_INVALID"
|
|
11
12
|
}
|
|
12
13
|
//# sourceMappingURL=error-code.enum.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-code.enum.d.ts","sourceRoot":"","sources":["../../src/common/error-code.enum.ts"],"names":[],"mappings":"AAAA,oBAAY,SAAS;IACnB,mBAAmB,0BAA0B;IAC7C,kBAAkB,yBAAyB;IAC3C,kBAAkB,yBAAyB;IAC3C,iBAAiB,wBAAwB;IACzC,kBAAkB,0BAA0B;IAC5C,SAAS,eAAe;IACxB,6BAA6B,qCAAqC;IAClE,4BAA4B,oCAAoC;IAChE,iBAAiB,wBAAwB;CAC1C"}
|
|
1
|
+
{"version":3,"file":"error-code.enum.d.ts","sourceRoot":"","sources":["../../src/common/error-code.enum.ts"],"names":[],"mappings":"AAAA,oBAAY,SAAS;IACnB,mBAAmB,0BAA0B;IAC7C,kBAAkB,yBAAyB;IAC3C,kBAAkB,yBAAyB;IAC3C,iBAAiB,wBAAwB;IACzC,kBAAkB,0BAA0B;IAC5C,SAAS,eAAe;IACxB,6BAA6B,qCAAqC;IAClE,4BAA4B,oCAAoC;IAChE,wBAAwB,gCAAgC;IACxD,iBAAiB,wBAAwB;CAC1C"}
|
|
@@ -11,6 +11,7 @@ var ErrorCode;
|
|
|
11
11
|
ErrorCode["JwksError"] = "JWKS_ERROR";
|
|
12
12
|
ErrorCode["AccessTokenVerificationFailed"] = "ACCESS_TOKEN_VERIFICATION_FAILED";
|
|
13
13
|
ErrorCode["IdentityServiceNotAccessible"] = "IDENTITY_SERVICE_NOT_ACCESSIBLE";
|
|
14
|
+
ErrorCode["UserServiceNotAccessible"] = "USER_SERVICE_NOT_ACCESSIBLE";
|
|
14
15
|
ErrorCode["AuthConfigInvalid"] = "AUTH_CONFIG_INVALID";
|
|
15
16
|
})(ErrorCode = exports.ErrorCode || (exports.ErrorCode = {}));
|
|
16
17
|
//# sourceMappingURL=error-code.enum.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-code.enum.js","sourceRoot":"","sources":["../../src/common/error-code.enum.ts"],"names":[],"mappings":";;;AAAA,IAAY,
|
|
1
|
+
{"version":3,"file":"error-code.enum.js","sourceRoot":"","sources":["../../src/common/error-code.enum.ts"],"names":[],"mappings":";;;AAAA,IAAY,SAWX;AAXD,WAAY,SAAS;IACnB,0DAA6C,CAAA;IAC7C,wDAA2C,CAAA;IAC3C,wDAA2C,CAAA;IAC3C,sDAAyC,CAAA;IACzC,yDAA4C,CAAA;IAC5C,qCAAwB,CAAA;IACxB,+EAAkE,CAAA;IAClE,6EAAgE,CAAA;IAChE,qEAAwD,CAAA;IACxD,sDAAyC,CAAA;AAC3C,CAAC,EAXW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAWpB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AuthenticatedConsumer, AuthenticatedManagementSubject } from '.';
|
|
1
|
+
import { AuthenticatedConsumer, AuthenticatedConsumerApplication, AuthenticatedManagementSubject } from '.';
|
|
2
2
|
import { AuthenticationConfig } from './authentication-config.interface';
|
|
3
3
|
/**
|
|
4
4
|
* Parses a JWT token to produce an `AuthenticatedManagementSubject`.
|
|
@@ -10,12 +10,12 @@ import { AuthenticationConfig } from './authentication-config.interface';
|
|
|
10
10
|
*/
|
|
11
11
|
export declare const getAuthenticatedManagementSubject: (token: string, authParams: string | AuthenticationConfig) => Promise<AuthenticatedManagementSubject>;
|
|
12
12
|
/**
|
|
13
|
-
* Parses a JWT token to produce an `AuthenticatedConsumer`.
|
|
13
|
+
* Parses a JWT token to produce an `AuthenticatedConsumer` or an `AuthenticatedConsumerApplication`.
|
|
14
14
|
* This function is intended to be used by any service which works with Consumer Applications.
|
|
15
15
|
*
|
|
16
16
|
* @param {string} token JWT token without `Bearer ` prefix.
|
|
17
17
|
* @param {string | AuthenticationConfig} authParams This could be either a string containing the Auth Endpoint for the User Service or an instance of `AuthenticationConfig`.
|
|
18
|
-
* @returns {Promise<AuthenticatedConsumer>} AuthenticatedConsumer
|
|
18
|
+
* @returns {Promise<AuthenticatedConsumer | AuthenticatedConsumerApplication>} AuthenticatedConsumer/AuthenticatedConsumerApplication
|
|
19
19
|
*/
|
|
20
|
-
export declare const getAuthenticatedConsumer: (token: string, authParams: string | AuthenticationConfig) => Promise<AuthenticatedConsumer>;
|
|
20
|
+
export declare const getAuthenticatedConsumer: (token: string, authParams: string | AuthenticationConfig) => Promise<AuthenticatedConsumer | AuthenticatedConsumerApplication>;
|
|
21
21
|
//# sourceMappingURL=get-authenticated-subject.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-authenticated-subject.d.ts","sourceRoot":"","sources":["../../src/common/get-authenticated-subject.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,qBAAqB,EACrB,8BAA8B,EAE/B,MAAM,GAAG,CAAC;AACX,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAOzE;;;;;;;GAOG;AACH,eAAO,MAAM,iCAAiC,UACrC,MAAM,cACD,MAAM,GAAG,oBAAoB,KACxC,QAAQ,8BAA8B,CAsDxC,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,wBAAwB,UAC5B,MAAM,cACD,MAAM,GAAG,oBAAoB,KACxC,QAAQ,qBAAqB,
|
|
1
|
+
{"version":3,"file":"get-authenticated-subject.d.ts","sourceRoot":"","sources":["../../src/common/get-authenticated-subject.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,qBAAqB,EACrB,gCAAgC,EAChC,8BAA8B,EAE/B,MAAM,GAAG,CAAC;AACX,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAOzE;;;;;;;GAOG;AACH,eAAO,MAAM,iCAAiC,UACrC,MAAM,cACD,MAAM,GAAG,oBAAoB,KACxC,QAAQ,8BAA8B,CAsDxC,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,wBAAwB,UAC5B,MAAM,cACD,MAAM,GAAG,oBAAoB,KACxC,QAAQ,qBAAqB,GAAG,gCAAgC,CAkDlE,CAAC"}
|
|
@@ -57,12 +57,12 @@ const getAuthenticatedManagementSubject = async (token, authParams) => {
|
|
|
57
57
|
};
|
|
58
58
|
exports.getAuthenticatedManagementSubject = getAuthenticatedManagementSubject;
|
|
59
59
|
/**
|
|
60
|
-
* Parses a JWT token to produce an `AuthenticatedConsumer`.
|
|
60
|
+
* Parses a JWT token to produce an `AuthenticatedConsumer` or an `AuthenticatedConsumerApplication`.
|
|
61
61
|
* This function is intended to be used by any service which works with Consumer Applications.
|
|
62
62
|
*
|
|
63
63
|
* @param {string} token JWT token without `Bearer ` prefix.
|
|
64
64
|
* @param {string | AuthenticationConfig} authParams This could be either a string containing the Auth Endpoint for the User Service or an instance of `AuthenticationConfig`.
|
|
65
|
-
* @returns {Promise<AuthenticatedConsumer>} AuthenticatedConsumer
|
|
65
|
+
* @returns {Promise<AuthenticatedConsumer | AuthenticatedConsumerApplication>} AuthenticatedConsumer/AuthenticatedConsumerApplication
|
|
66
66
|
*/
|
|
67
67
|
const getAuthenticatedConsumer = async (token, authParams) => {
|
|
68
68
|
let tenantId = '';
|
|
@@ -72,8 +72,7 @@ const getAuthenticatedConsumer = async (token, authParams) => {
|
|
|
72
72
|
const issuer = decoded.iss;
|
|
73
73
|
tenantId = decoded.tenantId;
|
|
74
74
|
environmentId = decoded.environmentId;
|
|
75
|
-
const applicationId =
|
|
76
|
-
.applicationId;
|
|
75
|
+
const applicationId = decoded.applicationId;
|
|
77
76
|
// If token is not issued by the User Service, the jwks URI will not be set, and the verification will fail.
|
|
78
77
|
if (issuer === jwt_verify_options_1.TOKEN_ISSUER_USER_SERVICE) {
|
|
79
78
|
if (typeof authParams === 'string') {
|
|
@@ -89,8 +88,14 @@ const getAuthenticatedConsumer = async (token, authParams) => {
|
|
|
89
88
|
jwksUri = new URL(`/${tenantId}/${environmentId}/${applicationId}/.well-known/jwks.json`, authParams.authEndpoint).href;
|
|
90
89
|
}
|
|
91
90
|
}
|
|
92
|
-
|
|
93
|
-
|
|
91
|
+
if (decoded.subjectType === _1.SubjectType.ConsumerApplication) {
|
|
92
|
+
// Verify access token using JWKS
|
|
93
|
+
return (await verifyTokenAndGetAuthenticatedSubject(token, jwksUri, 'CONSUMER_APPLICATION'));
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
// Verify access token using JWKS
|
|
97
|
+
return (await verifyTokenAndGetAuthenticatedSubject(token, jwksUri, 'CONSUMER'));
|
|
98
|
+
}
|
|
94
99
|
};
|
|
95
100
|
exports.getAuthenticatedConsumer = getAuthenticatedConsumer;
|
|
96
101
|
const verifyTokenAndGetAuthenticatedSubject = async (token, jwksUri, authType) => {
|
|
@@ -119,6 +124,9 @@ const verifyTokenAndGetAuthenticatedSubject = async (token, jwksUri, authType) =
|
|
|
119
124
|
if (authType === 'MANAGEMENT') {
|
|
120
125
|
resolve(decoded);
|
|
121
126
|
}
|
|
127
|
+
else if (authType === 'CONSUMER') {
|
|
128
|
+
resolve(decoded);
|
|
129
|
+
}
|
|
122
130
|
else {
|
|
123
131
|
resolve(decoded);
|
|
124
132
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-authenticated-subject.js","sourceRoot":"","sources":["../../src/common/get-authenticated-subject.ts"],"names":[],"mappings":";;;AAAA,yEAAmE;AACnE,oCAAoC;AACpC,iCAAiC;AACjC,
|
|
1
|
+
{"version":3,"file":"get-authenticated-subject.js","sourceRoot":"","sources":["../../src/common/get-authenticated-subject.ts"],"names":[],"mappings":";;;AAAA,yEAAmE;AACnE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B,GAAE,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;YACxE,IAAI,KAAK,EAAE;gBACT,MAAM,CAAC,KAAK,CAAC,CAAC;gBACd,OAAO;aACR;YAED,IAAI,QAAQ,KAAK,YAAY,EAAE;gBAC7B,OAAO,CAAC,OAAyC,CAAC,CAAC;aACpD;iBAAM,IAAI,QAAQ,KAAK,UAAU,EAAE;gBAClC,OAAO,CAAC,OAAgC,CAAC,CAAC;aAC3C;iBAAM;gBACL,OAAO,CAAC,OAA2C,CAAC,CAAC;aACtD;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guard-error.d.ts","sourceRoot":"","sources":["../../src/common/guard-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"guard-error.d.ts","sourceRoot":"","sources":["../../src/common/guard-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAC,YAAY,EAAc,MAAM,+BAA+B,CAAC;AAExE,qBAAa,gBAAgB;IAElB,IAAI,EAAE,SAAS;IACf,OAAO,EAAE,MAAM;IACf,aAAa,CAAC;IACd,OAAO,CAAC;gBAHR,IAAI,EAAE,SAAS,EACf,OAAO,EAAE,MAAM,EACf,aAAa,CAAC,mBAAO,EACrB,OAAO,CAAC,qCAAyB;CAE3C;AAED,qBAAa,YAAa,SAAQ,YAAY;gBAChC,IAAI,EAAE,gBAAgB;IAWlC,SAAS,CAAC,IAAI,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC5C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guard-error.js","sourceRoot":"","sources":["../../src/common/guard-error.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"guard-error.js","sourceRoot":"","sources":["../../src/common/guard-error.ts"],"names":[],"mappings":";;;AACA,yEAAwE;AAExE,MAAa,gBAAgB;IAC3B,YACS,IAAe,EACf,OAAe,EACf,aAAqB,EACrB,OAAiC;QAHjC,SAAI,GAAJ,IAAI,CAAW;QACf,YAAO,GAAP,OAAO,CAAQ;QACf,kBAAa,GAAb,aAAa,CAAQ;QACrB,YAAO,GAAP,OAAO,CAA0B;IACvC,CAAC;CACL;AAPD,4CAOC;AAED,MAAa,YAAa,SAAQ,oCAAY;IAC5C,YAAY,IAAsB;;QAChC,IAAI,IAAI,CAAC,aAAa,EAAE;YACtB,KAAK,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;SACzC;aAAM;YACL,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;SACrB;QAED,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACtB,IAAI,CAAC,OAAO,mBAAK,WAAW,EAAX,mCAAW,IAAK,CAAC,MAAA,IAAI,CAAC,OAAO,mCAAI,EAAE,CAAC,CAAE,CAAC;IAC1D,CAAC;CAIF;AAdD,oCAcC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ErrorCode } from '../error-code.enum';
|
|
2
|
+
/**
|
|
3
|
+
* Handles an error thrown by the parseJwtToken function.
|
|
4
|
+
* Returns error code of type ErrorCode, a message and original error.
|
|
5
|
+
*
|
|
6
|
+
* @param err Error of type unknown
|
|
7
|
+
* @param authType Auth Type - 'MANAGEMENT' | 'CONSUMER'
|
|
8
|
+
* @param token JWT token
|
|
9
|
+
* @returns [code, message, originalError]
|
|
10
|
+
*/
|
|
11
|
+
export declare const handleJwtParseError: (err: unknown, authType: 'MANAGEMENT' | 'CONSUMER' | undefined, token: string) => [code: ErrorCode, message: string, originalError: Error];
|
|
12
|
+
//# sourceMappingURL=parse-jwt-token-error-handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-jwt-token-error-handler.d.ts","sourceRoot":"","sources":["../../../src/common/helpers/parse-jwt-token-error-handler.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAkE/C;;;;;;;;GAQG;AACH,eAAO,MAAM,mBAAmB,QACzB,OAAO,YACF,YAAY,GAAG,UAAU,GAAG,SAAS,SACxC,MAAM,6DAiCd,CAAC"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.handleJwtParseError = void 0;
|
|
4
|
+
const mosaic_service_common_1 = require("@axinom/mosaic-service-common");
|
|
5
|
+
const jwt = require("jsonwebtoken");
|
|
6
|
+
const jwks = require("jwks-rsa");
|
|
7
|
+
const error_code_enum_1 = require("../error-code.enum");
|
|
8
|
+
/**
|
|
9
|
+
* To be used with parse-jwt-token.ts
|
|
10
|
+
* This method takes an error code and builds the respective error message for that depending on the authType.
|
|
11
|
+
*
|
|
12
|
+
* @param errorCode a value from the enum ErrorCode
|
|
13
|
+
* @param authType Auth Type - 'MANAGEMENT' | 'CONSUMER'
|
|
14
|
+
* @param authConfig AuthenticationConfig instance
|
|
15
|
+
* @param token JWT Token
|
|
16
|
+
* @returns
|
|
17
|
+
*/
|
|
18
|
+
const buildErrorMessage = (errorCode, authType, token) => {
|
|
19
|
+
let message = '';
|
|
20
|
+
const decodedToken = jwt.decode(token);
|
|
21
|
+
switch (errorCode) {
|
|
22
|
+
case error_code_enum_1.ErrorCode.SigningKeyNotFound:
|
|
23
|
+
message = `Could not find a matching signing key to verify the access token. The signing key used to create the token may have been revoked or the Tenant(${decodedToken.tenantId})/Environment(${decodedToken.environmentId})${authType === 'CONSUMER'
|
|
24
|
+
? `/Application(${decodedToken.applicationId})`
|
|
25
|
+
: ''} configuration is erroneous.`;
|
|
26
|
+
break;
|
|
27
|
+
case error_code_enum_1.ErrorCode.JwksError:
|
|
28
|
+
message = `Error occurred while trying to fetch signing keys from the JWKS endpoint for the Tenant(${decodedToken.tenantId})/Environment(${decodedToken.environmentId})${authType === 'CONSUMER'
|
|
29
|
+
? `/Application(${decodedToken.applicationId}).`
|
|
30
|
+
: '.'}`;
|
|
31
|
+
break;
|
|
32
|
+
case error_code_enum_1.ErrorCode.UserServiceNotAccessible:
|
|
33
|
+
message =
|
|
34
|
+
'The User service is not accessible. Please contact Axinom support.';
|
|
35
|
+
break;
|
|
36
|
+
case error_code_enum_1.ErrorCode.IdentityServiceNotAccessible:
|
|
37
|
+
message =
|
|
38
|
+
'The Identity service is not accessible. Please contact Axinom support.';
|
|
39
|
+
break;
|
|
40
|
+
case error_code_enum_1.ErrorCode.AccessTokenExpired:
|
|
41
|
+
message = 'Access Token is expired';
|
|
42
|
+
break;
|
|
43
|
+
case error_code_enum_1.ErrorCode.AccessTokenVerificationFailed:
|
|
44
|
+
message = 'Access token verification failed';
|
|
45
|
+
break;
|
|
46
|
+
default:
|
|
47
|
+
message = 'Unknown error';
|
|
48
|
+
}
|
|
49
|
+
return message;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Handles an error thrown by the parseJwtToken function.
|
|
53
|
+
* Returns error code of type ErrorCode, a message and original error.
|
|
54
|
+
*
|
|
55
|
+
* @param err Error of type unknown
|
|
56
|
+
* @param authType Auth Type - 'MANAGEMENT' | 'CONSUMER'
|
|
57
|
+
* @param token JWT token
|
|
58
|
+
* @returns [code, message, originalError]
|
|
59
|
+
*/
|
|
60
|
+
const handleJwtParseError = (err, authType, token) => {
|
|
61
|
+
let code;
|
|
62
|
+
let message;
|
|
63
|
+
let originalError;
|
|
64
|
+
if (err instanceof jwt.TokenExpiredError) {
|
|
65
|
+
code = error_code_enum_1.ErrorCode.AccessTokenExpired;
|
|
66
|
+
message = buildErrorMessage(code, authType, token);
|
|
67
|
+
}
|
|
68
|
+
else if (err instanceof jwks.SigningKeyNotFoundError) {
|
|
69
|
+
code = error_code_enum_1.ErrorCode.SigningKeyNotFound;
|
|
70
|
+
message = buildErrorMessage(code, authType, token);
|
|
71
|
+
}
|
|
72
|
+
else if (err instanceof jwks.JwksError) {
|
|
73
|
+
code = error_code_enum_1.ErrorCode.JwksError;
|
|
74
|
+
message = buildErrorMessage(code, authType, token);
|
|
75
|
+
}
|
|
76
|
+
else if (err.code === 'ECONNREFUSED') {
|
|
77
|
+
code =
|
|
78
|
+
authType === 'CONSUMER'
|
|
79
|
+
? error_code_enum_1.ErrorCode.UserServiceNotAccessible
|
|
80
|
+
: error_code_enum_1.ErrorCode.IdentityServiceNotAccessible;
|
|
81
|
+
message = buildErrorMessage(code, authType, token);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
code = error_code_enum_1.ErrorCode.AccessTokenVerificationFailed;
|
|
85
|
+
message = buildErrorMessage(code, authType, token);
|
|
86
|
+
}
|
|
87
|
+
// If thrown error is an instance of Error, take that as the original error. If not, create a new GeneralError and encapsulate the unknown error in the details
|
|
88
|
+
if (err instanceof Error) {
|
|
89
|
+
originalError = err;
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
originalError = new mosaic_service_common_1.GeneralError('Unknown Error', { err });
|
|
93
|
+
}
|
|
94
|
+
return [code, message, originalError];
|
|
95
|
+
};
|
|
96
|
+
exports.handleJwtParseError = handleJwtParseError;
|
|
97
|
+
//# sourceMappingURL=parse-jwt-token-error-handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-jwt-token-error-handler.js","sourceRoot":"","sources":["../../../src/common/helpers/parse-jwt-token-error-handler.ts"],"names":[],"mappings":";;;AAAA,yEAA6D;AAC7D,oCAAoC;AACpC,iCAAiC;AAEjC,wDAA+C;AAE/C;;;;;;;;;GASG;AACH,MAAM,iBAAiB,GAAG,CACxB,SAAoB,EACpB,QAA+C,EAC/C,KAAa,EACL,EAAE;IACV,IAAI,OAAO,GAAG,EAAE,CAAC;IACjB,MAAM,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Ac,mCAAmC,CAAC;AAClD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,mBAAmB,CAAC;AAClC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC;AAC7C,cAAc,mCAAmC,CAAC;AAClD,cAAc,mCAAmC,CAAC;AAClD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,mBAAmB,CAAC;AAClC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC"}
|
package/dist/common/index.js
CHANGED
|
@@ -10,6 +10,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
10
10
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./assert-consumer-token-type"), exports);
|
|
13
14
|
__exportStar(require("./authenticated-subject.interface"), exports);
|
|
14
15
|
__exportStar(require("./authentication-config.interface"), exports);
|
|
15
16
|
__exportStar(require("./authentication-request-context.interface"), exports);
|
package/dist/common/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oEAAkD;AAClD,oEAAkD;AAClD,6EAA2D;AAC3D,oDAAkC;AAClC,8DAA4C;AAC5C,gDAA8B;AAC9B,uDAAqC;AACrC,oDAAkC;AAClC,sDAAoC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+DAA6C;AAC7C,oEAAkD;AAClD,oEAAkD;AAClD,6EAA2D;AAC3D,oDAAkC;AAClC,8DAA4C;AAC5C,gDAA8B;AAC9B,uDAAqC;AACrC,oDAAkC;AAClC,sDAAoC"}
|
|
@@ -3,7 +3,7 @@ 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.
|
|
5
5
|
* @param token JWT token without `Bearer ` prefix
|
|
6
|
-
* @param authConfig an object with ID service connection information or a path to a public key file.
|
|
6
|
+
* @param authConfig an object with ID/User service connection information or a path to a public key file.
|
|
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>;
|
|
@@ -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":"AAGA,OAAO,EACL,qBAAqB,EAErB,8BAA8B,EAC9B,6BAA6B,EAK7B,+BAA+B,EAEhC,MAAM,GAAG,CAAC;AACX,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAIzE;;;;;GAKG;AACH,eAAO,MAAM,aAAa,UACjB,MAAM,GAAG,SAAS,cACb,MAAM,GAAG,oBAAoB,uDAExC,QAAQ,+BAA+B,GAAG,6BAA6B,CA6EzE,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,2BAA2B,UAC/B,MAAM,KACZ,8BAEF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,UAC7B,MAAM,KACZ,qBAEF,CAAC"}
|
|
@@ -4,13 +4,13 @@ exports.decodeConsumerAccessToken = exports.decodeManagementAccessToken = export
|
|
|
4
4
|
const mosaic_service_common_1 = require("@axinom/mosaic-service-common");
|
|
5
5
|
const fs = require("fs");
|
|
6
6
|
const jwt = require("jsonwebtoken");
|
|
7
|
-
const jwks = require("jwks-rsa");
|
|
8
7
|
const _1 = require(".");
|
|
9
8
|
const guard_error_1 = require("./guard-error");
|
|
9
|
+
const parse_jwt_token_error_handler_1 = require("./helpers/parse-jwt-token-error-handler");
|
|
10
10
|
/**
|
|
11
11
|
* Parses a JWT token to produce an ManagementAuthenticationContext or a ConsumeAuthenticationContext with subject information and error information, if some error occurred during token processing.
|
|
12
12
|
* @param token JWT token without `Bearer ` prefix
|
|
13
|
-
* @param authConfig an object with ID service connection information or a path to a public key file.
|
|
13
|
+
* @param authConfig an object with ID/User service connection information or a path to a public key file.
|
|
14
14
|
* @param authType The type of Token that's being passed. Should be either `MANAGEMENT` or `CONSUMER`.
|
|
15
15
|
*/
|
|
16
16
|
const parseJwtToken = async (token, authConfig, authType) => {
|
|
@@ -19,19 +19,27 @@ const parseJwtToken = async (token, authConfig, authType) => {
|
|
|
19
19
|
let originalError;
|
|
20
20
|
let subject;
|
|
21
21
|
let authErrorInfo;
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
if (!(0, mosaic_service_common_1.isNullOrWhitespace)(token)) {
|
|
23
|
+
try {
|
|
24
24
|
// If authConfig is a string value, it means the authentication is happening for either the Tenant Admin or the Environment Admin scopes.
|
|
25
25
|
if (typeof authConfig === 'string') {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
if (authType !== undefined) {
|
|
27
|
+
code = _1.ErrorCode.AuthConfigInvalid;
|
|
28
|
+
message =
|
|
29
|
+
'authType should not be provided when authenticationConfig is a string.';
|
|
30
|
+
originalError = new Error(message);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
const publicKeyPath = authConfig;
|
|
34
|
+
const publicKey = fs.readFileSync(publicKeyPath, 'utf8');
|
|
35
|
+
const decoded = jwt.verify(token, publicKey, (0, _1.getJwtVerifyOptions)());
|
|
36
|
+
subject = decoded;
|
|
37
|
+
}
|
|
30
38
|
}
|
|
31
39
|
else {
|
|
32
40
|
if (authType === undefined) {
|
|
33
41
|
code = _1.ErrorCode.AuthConfigInvalid;
|
|
34
|
-
message = '
|
|
42
|
+
message = 'authType is not provided for Authentication Config';
|
|
35
43
|
originalError = new Error(message);
|
|
36
44
|
}
|
|
37
45
|
else if (authType === 'MANAGEMENT') {
|
|
@@ -42,36 +50,14 @@ const parseJwtToken = async (token, authConfig, authType) => {
|
|
|
42
50
|
}
|
|
43
51
|
}
|
|
44
52
|
}
|
|
45
|
-
|
|
46
|
-
code =
|
|
47
|
-
message = 'Access Token is not provided';
|
|
48
|
-
originalError = new Error(message);
|
|
53
|
+
catch (err) {
|
|
54
|
+
[code, message, originalError] = (0, parse_jwt_token_error_handler_1.handleJwtParseError)(err, authType, token);
|
|
49
55
|
}
|
|
50
56
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
message = 'Access Token is expired';
|
|
56
|
-
}
|
|
57
|
-
else if (err instanceof jwks.SigningKeyNotFoundError) {
|
|
58
|
-
code = _1.ErrorCode.SigningKeyNotFound;
|
|
59
|
-
message = `Could not find a matching signing key to verify the access token. The signing key used to create the token may have been revoked or the Tenant(${authConfig.tenantId})/Environment(${authConfig.environmentId}) configuration is erroneous.`;
|
|
60
|
-
}
|
|
61
|
-
else if (err instanceof jwks.JwksError) {
|
|
62
|
-
code = _1.ErrorCode.JwksError;
|
|
63
|
-
message = `Error occurred while trying to fetch signing keys from the JWKS endpoint for the Tenant(${authConfig.tenantId})/Environment(${authConfig.environmentId}).`;
|
|
64
|
-
}
|
|
65
|
-
else if (err.code === 'ECONNREFUSED') {
|
|
66
|
-
code = _1.ErrorCode.IdentityServiceNotAccessible;
|
|
67
|
-
message =
|
|
68
|
-
'The identity service is not accessible. Please contact Axinom support.';
|
|
69
|
-
}
|
|
70
|
-
else {
|
|
71
|
-
code = _1.ErrorCode.AccessTokenVerificationFailed;
|
|
72
|
-
message = 'Access token verification failed';
|
|
73
|
-
}
|
|
74
|
-
originalError = err;
|
|
57
|
+
else {
|
|
58
|
+
code = _1.ErrorCode.AccessTokenRequired;
|
|
59
|
+
message = 'Access Token is not provided';
|
|
60
|
+
originalError = new Error(message);
|
|
75
61
|
}
|
|
76
62
|
if (code !== undefined &&
|
|
77
63
|
message !== undefined &&
|
|
@@ -86,10 +72,18 @@ const parseJwtToken = async (token, authConfig, authType) => {
|
|
|
86
72
|
};
|
|
87
73
|
}
|
|
88
74
|
else {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
75
|
+
if ((subject === null || subject === void 0 ? void 0 : subject.subjectType) === _1.SubjectType.ConsumerAccount) {
|
|
76
|
+
return {
|
|
77
|
+
subject: subject,
|
|
78
|
+
authErrorInfo,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
return {
|
|
83
|
+
subject: subject,
|
|
84
|
+
authErrorInfo,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
93
87
|
}
|
|
94
88
|
};
|
|
95
89
|
exports.parseJwtToken = parseJwtToken;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-jwt-token.js","sourceRoot":"","sources":["../../src/common/parse-jwt-token.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"parse-jwt-token.js","sourceRoot":"","sources":["../../src/common/parse-jwt-token.ts"],"names":[],"mappings":";;;AAAA,yEAAmE;AACnE,yBAAyB;AACzB,oCAAoC;AACpC,wBAWW;AAEX,+CAAiD;AACjD,2FAA8E;AAE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BAIpC"}
|
|
@@ -5,6 +5,7 @@ export declare enum SubjectType {
|
|
|
5
5
|
ImpersonatedUserAccount = "ImpersonatedUserAccount",
|
|
6
6
|
SuperUserAccount = "SuperUserAccount",
|
|
7
7
|
EnvironmentAdminAccount = "EnvironmentAdminAccount",
|
|
8
|
-
ConsumerAccount = "ConsumerAccount"
|
|
8
|
+
ConsumerAccount = "ConsumerAccount",
|
|
9
|
+
ConsumerApplication = "ConsumerApplication"
|
|
9
10
|
}
|
|
10
11
|
//# sourceMappingURL=subject-type.enum.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subject-type.enum.d.ts","sourceRoot":"","sources":["../../src/common/subject-type.enum.ts"],"names":[],"mappings":"AAAA,oBAAY,WAAW;IACrB,qBAAqB,0BAA0B;IAC/C,cAAc,mBAAmB;IACjC,WAAW,gBAAgB;IAC3B,uBAAuB,4BAA4B;IACnD,gBAAgB,qBAAqB;IACrC,uBAAuB,4BAA4B;IACnD,eAAe,oBAAoB;
|
|
1
|
+
{"version":3,"file":"subject-type.enum.d.ts","sourceRoot":"","sources":["../../src/common/subject-type.enum.ts"],"names":[],"mappings":"AAAA,oBAAY,WAAW;IACrB,qBAAqB,0BAA0B;IAC/C,cAAc,mBAAmB;IACjC,WAAW,gBAAgB;IAC3B,uBAAuB,4BAA4B;IACnD,gBAAgB,qBAAqB;IACrC,uBAAuB,4BAA4B;IACnD,eAAe,oBAAoB;IACnC,mBAAmB,wBAAwB;CAC5C"}
|
|
@@ -10,5 +10,6 @@ var SubjectType;
|
|
|
10
10
|
SubjectType["SuperUserAccount"] = "SuperUserAccount";
|
|
11
11
|
SubjectType["EnvironmentAdminAccount"] = "EnvironmentAdminAccount";
|
|
12
12
|
SubjectType["ConsumerAccount"] = "ConsumerAccount";
|
|
13
|
+
SubjectType["ConsumerApplication"] = "ConsumerApplication";
|
|
13
14
|
})(SubjectType = exports.SubjectType || (exports.SubjectType = {}));
|
|
14
15
|
//# sourceMappingURL=subject-type.enum.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subject-type.enum.js","sourceRoot":"","sources":["../../src/common/subject-type.enum.ts"],"names":[],"mappings":";;;AAAA,IAAY,
|
|
1
|
+
{"version":3,"file":"subject-type.enum.js","sourceRoot":"","sources":["../../src/common/subject-type.enum.ts"],"names":[],"mappings":";;;AAAA,IAAY,WASX;AATD,WAAY,WAAW;IACrB,8DAA+C,CAAA;IAC/C,gDAAiC,CAAA;IACjC,0CAA2B,CAAA;IAC3B,kEAAmD,CAAA;IACnD,oDAAqC,CAAA;IACrC,kEAAmD,CAAA;IACnD,kDAAmC,CAAA;IACnC,0DAA2C,CAAA;AAC7C,CAAC,EATW,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAStB"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { Express, Request, Response } from 'express';
|
|
1
|
+
import { Express, NextFunction, Request, Response } from 'express';
|
|
2
2
|
import { Middleware } from 'postgraphile';
|
|
3
3
|
import { AuthenticationConfig } from '../common';
|
|
4
|
+
export declare const jwtParserMiddleware: (authConfig: AuthenticationConfig, authType?: "MANAGEMENT" | "CONSUMER" | undefined) => (req: Request, _res: Response, next: NextFunction) => Promise<void>;
|
|
4
5
|
/**
|
|
5
6
|
* This is an Express Middleware which throws an error if there're any Authorization errors in ManagementAuthenticationContext.
|
|
6
7
|
* @param req Express Request object
|
|
@@ -22,6 +23,7 @@ export declare const throwConsumerAuthError: (req: Request, _res: Response, next
|
|
|
22
23
|
* @param {Express} app the Express app instance.
|
|
23
24
|
* @param {string[]} guardRoutes an array of routes that needs to be protected.
|
|
24
25
|
* @param {string | AuthenticationConfig} authParams A string with the ID Service Auth Endpoint or an instance of `AuthenticationConfig` containing ID service connection information.
|
|
26
|
+
* For non-managed services, providing `AuthenticationConfig` with correct tenant and environment IDs is mandatory.
|
|
25
27
|
*/
|
|
26
28
|
export declare function setupManagementAuthentication(app: Express, guardRoutes: string[], authParams: string | AuthenticationConfig): void;
|
|
27
29
|
/**
|
|
@@ -31,6 +33,7 @@ export declare function setupManagementAuthentication(app: Express, guardRoutes:
|
|
|
31
33
|
* @param {Express} app the Express app instance.
|
|
32
34
|
* @param {string[]} guardRoutes an array of routes that needs to be protected.
|
|
33
35
|
* @param {string | AuthenticationConfig} authParams A string with the User Service Auth Endpoint or an instance of `AuthenticationConfig` containing User service connection information.
|
|
36
|
+
* For non-managed services, providing `AuthenticationConfig` with correct tenant and environment IDs is mandatory.
|
|
34
37
|
*/
|
|
35
38
|
export declare function setupConsumerAuthentication(app: Express, guardRoutes: string[], authParams: string | AuthenticationConfig): void;
|
|
36
39
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guard.middleware.d.ts","sourceRoot":"","sources":["../../src/graphql/guard.middleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"guard.middleware.d.ts","sourceRoot":"","sources":["../../src/graphql/guard.middleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAQ,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEzE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAGL,oBAAoB,EAKrB,MAAM,WAAW,CAAC;AAEnB,eAAO,MAAM,mBAAmB,eAClB,oBAAoB,6DAGb,OAAO,QAAQ,QAAQ,QAAQ,YAAY,kBAkB/D,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,QAC9B,OAAO,QACN,QAAQ,uBACO,GAAG,KAAK,IAAI,KAChC,IAMF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,QAC5B,OAAO,QACN,QAAQ,uBACO,GAAG,KAAK,IAAI,KAChC,IAMF,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAgB,6BAA6B,CAC3C,GAAG,EAAE,OAAO,EACZ,WAAW,EAAE,MAAM,EAAE,EACrB,UAAU,EAAE,MAAM,GAAG,oBAAoB,GACxC,IAAI,CAqBN;AAED;;;;;;;;GAQG;AACH,wBAAgB,2BAA2B,CACzC,GAAG,EAAE,OAAO,EACZ,WAAW,EAAE,MAAM,EAAE,EACrB,UAAU,EAAE,MAAM,GAAG,oBAAoB,GACxC,IAAI,CAqBN;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,4CAA4C,eAC3C,MAAM,GAAG,oBAAoB,KACxC,WAAW,OAAO,EAAE,QAAQ,CAAC,EAmB/B,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,0CAA0C,eACzC,MAAM,GAAG,oBAAoB,KACxC,WAAW,OAAO,EAAE,QAAQ,CAAC,EAmB/B,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.setupConsumerGQLSubscriptionAuthentication = exports.setupManagementGQLSubscriptionAuthentication = exports.setupConsumerAuthentication = exports.setupManagementAuthentication = exports.throwConsumerAuthError = exports.throwManagementAuthError = void 0;
|
|
3
|
+
exports.setupConsumerGQLSubscriptionAuthentication = exports.setupManagementGQLSubscriptionAuthentication = exports.setupConsumerAuthentication = exports.setupManagementAuthentication = exports.throwConsumerAuthError = exports.throwManagementAuthError = exports.jwtParserMiddleware = void 0;
|
|
4
4
|
const express_1 = require("express");
|
|
5
5
|
const bearerTokenExtractor = require("express-bearer-token");
|
|
6
6
|
const common_1 = require("../common");
|
|
@@ -16,6 +16,7 @@ const jwtParserMiddleware = (authConfig, authType) => {
|
|
|
16
16
|
next();
|
|
17
17
|
};
|
|
18
18
|
};
|
|
19
|
+
exports.jwtParserMiddleware = jwtParserMiddleware;
|
|
19
20
|
/**
|
|
20
21
|
* This is an Express Middleware which throws an error if there're any Authorization errors in ManagementAuthenticationContext.
|
|
21
22
|
* @param req Express Request object
|
|
@@ -51,6 +52,7 @@ exports.throwConsumerAuthError = throwConsumerAuthError;
|
|
|
51
52
|
* @param {Express} app the Express app instance.
|
|
52
53
|
* @param {string[]} guardRoutes an array of routes that needs to be protected.
|
|
53
54
|
* @param {string | AuthenticationConfig} authParams A string with the ID Service Auth Endpoint or an instance of `AuthenticationConfig` containing ID service connection information.
|
|
55
|
+
* For non-managed services, providing `AuthenticationConfig` with correct tenant and environment IDs is mandatory.
|
|
54
56
|
*/
|
|
55
57
|
function setupManagementAuthentication(app, guardRoutes, authParams) {
|
|
56
58
|
if (typeof authParams === 'string') {
|
|
@@ -59,10 +61,10 @@ function setupManagementAuthentication(app, guardRoutes, authParams) {
|
|
|
59
61
|
environmentId: '',
|
|
60
62
|
tenantId: '',
|
|
61
63
|
};
|
|
62
|
-
app.use(guardRoutes, bearerTokenExtractor(), jwtParserMiddleware(authenticationConfig, 'MANAGEMENT'), (0, express_1.json)());
|
|
64
|
+
app.use(guardRoutes, bearerTokenExtractor(), (0, exports.jwtParserMiddleware)(authenticationConfig, 'MANAGEMENT'), (0, express_1.json)());
|
|
63
65
|
}
|
|
64
66
|
else {
|
|
65
|
-
app.use(guardRoutes, bearerTokenExtractor(), jwtParserMiddleware(authParams, 'MANAGEMENT'), (0, express_1.json)());
|
|
67
|
+
app.use(guardRoutes, bearerTokenExtractor(), (0, exports.jwtParserMiddleware)(authParams, 'MANAGEMENT'), (0, express_1.json)());
|
|
66
68
|
}
|
|
67
69
|
}
|
|
68
70
|
exports.setupManagementAuthentication = setupManagementAuthentication;
|
|
@@ -73,6 +75,7 @@ exports.setupManagementAuthentication = setupManagementAuthentication;
|
|
|
73
75
|
* @param {Express} app the Express app instance.
|
|
74
76
|
* @param {string[]} guardRoutes an array of routes that needs to be protected.
|
|
75
77
|
* @param {string | AuthenticationConfig} authParams A string with the User Service Auth Endpoint or an instance of `AuthenticationConfig` containing User service connection information.
|
|
78
|
+
* For non-managed services, providing `AuthenticationConfig` with correct tenant and environment IDs is mandatory.
|
|
76
79
|
*/
|
|
77
80
|
function setupConsumerAuthentication(app, guardRoutes, authParams) {
|
|
78
81
|
if (typeof authParams === 'string') {
|
|
@@ -81,10 +84,10 @@ function setupConsumerAuthentication(app, guardRoutes, authParams) {
|
|
|
81
84
|
environmentId: '',
|
|
82
85
|
tenantId: '',
|
|
83
86
|
};
|
|
84
|
-
app.use(guardRoutes, bearerTokenExtractor(), jwtParserMiddleware(authenticationConfig, 'CONSUMER'), (0, express_1.json)());
|
|
87
|
+
app.use(guardRoutes, bearerTokenExtractor(), (0, exports.jwtParserMiddleware)(authenticationConfig, 'CONSUMER'), (0, express_1.json)());
|
|
85
88
|
}
|
|
86
89
|
else {
|
|
87
|
-
app.use(guardRoutes, bearerTokenExtractor(), jwtParserMiddleware(authParams, 'CONSUMER'), (0, express_1.json)());
|
|
90
|
+
app.use(guardRoutes, bearerTokenExtractor(), (0, exports.jwtParserMiddleware)(authParams, 'CONSUMER'), (0, express_1.json)());
|
|
88
91
|
}
|
|
89
92
|
}
|
|
90
93
|
exports.setupConsumerAuthentication = setupConsumerAuthentication;
|
|
@@ -105,14 +108,14 @@ const setupManagementGQLSubscriptionAuthentication = (authParams) => {
|
|
|
105
108
|
};
|
|
106
109
|
return [
|
|
107
110
|
bearerTokenExtractor(),
|
|
108
|
-
jwtParserMiddleware(authenticationConfig, 'MANAGEMENT'),
|
|
111
|
+
(0, exports.jwtParserMiddleware)(authenticationConfig, 'MANAGEMENT'),
|
|
109
112
|
exports.throwManagementAuthError,
|
|
110
113
|
];
|
|
111
114
|
}
|
|
112
115
|
else {
|
|
113
116
|
return [
|
|
114
117
|
bearerTokenExtractor(),
|
|
115
|
-
jwtParserMiddleware(authParams, 'MANAGEMENT'),
|
|
118
|
+
(0, exports.jwtParserMiddleware)(authParams, 'MANAGEMENT'),
|
|
116
119
|
exports.throwManagementAuthError,
|
|
117
120
|
];
|
|
118
121
|
}
|
|
@@ -135,14 +138,14 @@ const setupConsumerGQLSubscriptionAuthentication = (authParams) => {
|
|
|
135
138
|
};
|
|
136
139
|
return [
|
|
137
140
|
bearerTokenExtractor(),
|
|
138
|
-
jwtParserMiddleware(authenticationConfig, 'CONSUMER'),
|
|
141
|
+
(0, exports.jwtParserMiddleware)(authenticationConfig, 'CONSUMER'),
|
|
139
142
|
exports.throwConsumerAuthError,
|
|
140
143
|
];
|
|
141
144
|
}
|
|
142
145
|
else {
|
|
143
146
|
return [
|
|
144
147
|
bearerTokenExtractor(),
|
|
145
|
-
jwtParserMiddleware(authParams, 'CONSUMER'),
|
|
148
|
+
(0, exports.jwtParserMiddleware)(authParams, 'CONSUMER'),
|
|
146
149
|
exports.throwConsumerAuthError,
|
|
147
150
|
];
|
|
148
151
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guard.middleware.js","sourceRoot":"","sources":["../../src/graphql/guard.middleware.ts"],"names":[],"mappings":";;;AAAA,qCAAyE;AACzE,6DAA6D;AAE7D,sCAQmB;
|
|
1
|
+
{"version":3,"file":"guard.middleware.js","sourceRoot":"","sources":["../../src/graphql/guard.middleware.ts"],"names":[],"mappings":";;;AAAA,qCAAyE;AACzE,6DAA6D;AAE7D,sCAQmB;AAEZ,MAAM,mBAAmB,GAAG,CACjC,UAAgC,EAChC,QAAoC,EACpC,EAAE;IACF,OAAO,KAAK,EAAE,GAAY,EAAE,IAAc,EAAE,IAAkB,EAAE,EAAE;QAChE,IAAI,QAAQ,KAAK,SAAS,IAAI,QAAQ,KAAK,YAAY,EAAE;YACtD,GAAsC,CAAC,WAAW;gBACjD,CAAC,MAAM,IAAA,sBAAa,EAClB,GAAG,CAAC,KAAK,EACT,UAAU,EACV,YAAY,CACb,CAAoC,CAAC;SACzC;aAAM,IAAI,QAAQ,KAAK,UAAU,EAAE;YACjC,GAAoC,CAAC,WAAW,GAAG,CAAC,MAAM,IAAA,sBAAa,EACtE,GAAG,CAAC,KAAK,EACT,UAAU,EACV,UAAU,CACX,CAAkC,CAAC;SACrC;QAED,IAAI,EAAE,CAAC;IACT,CAAC,CAAC;AACJ,CAAC,CAAC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U;YACxB,aAAa,EAAE,EAAE;YACjB,QAAQ,EAAE,EAAE;SACb,CAAC;QACF,OAAO;YACL,oBAAoB,EAAE;YACtB,IAAA,2BAAmB,EAAC,oBAAoB,EAAE,UAAU,CAAC;YACrD,8BAAsB;SACvB,CAAC;KACH;SAAM;QACL,OAAO;YACL,oBAAoB,EAAE;YACtB,IAAA,2BAAmB,EAAC,UAAU,EAAE,UAAU,CAAC;YAC3C,8BAAsB;SACvB,CAAC;KACH;AACH,CAAC,CAAC;AArBW,QAAA,0CAA0C,8CAqBrD"}
|
package/dist/graphql/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export * from './enforce-strict-permissions.plugin';
|
|
2
2
|
export * from './guard.context';
|
|
3
|
-
export
|
|
3
|
+
export { setupConsumerAuthentication, setupConsumerGQLSubscriptionAuthentication, setupManagementAuthentication, setupManagementGQLSubscriptionAuthentication, throwConsumerAuthError, throwManagementAuthError, } from './guard.middleware';
|
|
4
4
|
export * from './guard.plugin';
|
|
5
5
|
export * from './subscription-authorization-hook-factory';
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/graphql/index.ts"],"names":[],"mappings":"AAAA,cAAc,qCAAqC,CAAC;AACpD,cAAc,iBAAiB,CAAC;AAChC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/graphql/index.ts"],"names":[],"mappings":"AAAA,cAAc,qCAAqC,CAAC;AACpD,cAAc,iBAAiB,CAAC;AAChC,OAAO,EACL,2BAA2B,EAC3B,0CAA0C,EAC1C,6BAA6B,EAC7B,4CAA4C,EAC5C,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,oBAAoB,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,2CAA2C,CAAC"}
|
package/dist/graphql/index.js
CHANGED
|
@@ -10,9 +10,16 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
10
10
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.throwManagementAuthError = exports.throwConsumerAuthError = exports.setupManagementGQLSubscriptionAuthentication = exports.setupManagementAuthentication = exports.setupConsumerGQLSubscriptionAuthentication = exports.setupConsumerAuthentication = void 0;
|
|
13
14
|
__exportStar(require("./enforce-strict-permissions.plugin"), exports);
|
|
14
15
|
__exportStar(require("./guard.context"), exports);
|
|
15
|
-
|
|
16
|
+
var guard_middleware_1 = require("./guard.middleware");
|
|
17
|
+
Object.defineProperty(exports, "setupConsumerAuthentication", { enumerable: true, get: function () { return guard_middleware_1.setupConsumerAuthentication; } });
|
|
18
|
+
Object.defineProperty(exports, "setupConsumerGQLSubscriptionAuthentication", { enumerable: true, get: function () { return guard_middleware_1.setupConsumerGQLSubscriptionAuthentication; } });
|
|
19
|
+
Object.defineProperty(exports, "setupManagementAuthentication", { enumerable: true, get: function () { return guard_middleware_1.setupManagementAuthentication; } });
|
|
20
|
+
Object.defineProperty(exports, "setupManagementGQLSubscriptionAuthentication", { enumerable: true, get: function () { return guard_middleware_1.setupManagementGQLSubscriptionAuthentication; } });
|
|
21
|
+
Object.defineProperty(exports, "throwConsumerAuthError", { enumerable: true, get: function () { return guard_middleware_1.throwConsumerAuthError; } });
|
|
22
|
+
Object.defineProperty(exports, "throwManagementAuthError", { enumerable: true, get: function () { return guard_middleware_1.throwManagementAuthError; } });
|
|
16
23
|
__exportStar(require("./guard.plugin"), exports);
|
|
17
24
|
__exportStar(require("./subscription-authorization-hook-factory"), exports);
|
|
18
25
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/graphql/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/graphql/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,sEAAoD;AACpD,kDAAgC;AAChC,uDAO4B;AAN1B,+HAAA,2BAA2B,OAAA;AAC3B,8IAAA,0CAA0C,OAAA;AAC1C,iIAAA,6BAA6B,OAAA;AAC7B,gJAAA,4CAA4C,OAAA;AAC5C,0HAAA,sBAAsB,OAAA;AACtB,4HAAA,wBAAwB,OAAA;AAE1B,iDAA+B;AAC/B,4EAA0D"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axinom/mosaic-id-guard",
|
|
3
|
-
"version": "0.11.0
|
|
3
|
+
"version": "0.11.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.5.0
|
|
30
|
-
"@axinom/mosaic-id-utils": "^0.6.0
|
|
31
|
-
"@axinom/mosaic-message-bus": "^0.6.0
|
|
32
|
-
"@axinom/mosaic-service-common": "^0.12.0
|
|
29
|
+
"@axinom/mosaic-id-link-be": "^0.5.0",
|
|
30
|
+
"@axinom/mosaic-id-utils": "^0.6.0",
|
|
31
|
+
"@axinom/mosaic-message-bus": "^0.6.0",
|
|
32
|
+
"@axinom/mosaic-service-common": "^0.12.0",
|
|
33
33
|
"amqplib": "^0.6.0",
|
|
34
34
|
"express": "^4.17.1",
|
|
35
35
|
"express-bearer-token": "^2.4.0",
|
|
@@ -47,16 +47,18 @@
|
|
|
47
47
|
"subscriptions-transport-ws": "^0.9.19"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
+
"@types/supertest": "^2.0.11",
|
|
50
51
|
"graphql-subscriptions": "^1.2.1",
|
|
51
52
|
"jest": "26.6.0",
|
|
52
53
|
"mock-jwks": "^0.3.1",
|
|
53
54
|
"nock": "^13.0.6",
|
|
54
55
|
"rimraf": "^3.0.2",
|
|
56
|
+
"supertest": "^6.1.6",
|
|
55
57
|
"ts-node": "^8.9.0",
|
|
56
58
|
"typescript": "^4.5.4"
|
|
57
59
|
},
|
|
58
60
|
"publishConfig": {
|
|
59
61
|
"access": "public"
|
|
60
62
|
},
|
|
61
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "f80cb6c17c7fe9993994473b513b568c7ae718d8"
|
|
62
64
|
}
|