@pristine-ts/security 2.0.3 → 2.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/cjs/errors/authenticator-decorator.error.js +9 -13
- package/dist/lib/cjs/errors/authenticator-decorator.error.js.map +1 -1
- package/dist/lib/cjs/errors/authenticator-instantiation.error.js +5 -9
- package/dist/lib/cjs/errors/authenticator-instantiation.error.js.map +1 -1
- package/dist/lib/cjs/errors/guard-decorator.error.js +9 -13
- package/dist/lib/cjs/errors/guard-decorator.error.js.map +1 -1
- package/dist/lib/cjs/errors/guard-instantiation.error.js +5 -9
- package/dist/lib/cjs/errors/guard-instantiation.error.js.map +1 -1
- package/dist/lib/cjs/factories/authenticator.factory.js +5 -2
- package/dist/lib/cjs/factories/authenticator.factory.js.map +1 -1
- package/dist/lib/cjs/factories/guard.factory.js +6 -2
- package/dist/lib/cjs/factories/guard.factory.js.map +1 -1
- package/dist/lib/cjs/guards/role.guard.js +6 -0
- package/dist/lib/cjs/guards/role.guard.js.map +1 -1
- package/dist/lib/cjs/managers/authentication.manager.js +8 -9
- package/dist/lib/cjs/managers/authentication.manager.js.map +1 -1
- package/dist/lib/cjs/managers/authorizer.manager.js +12 -24
- package/dist/lib/cjs/managers/authorizer.manager.js.map +1 -1
- package/dist/lib/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/lib/esm/errors/authenticator-decorator.error.js +10 -14
- package/dist/lib/esm/errors/authenticator-decorator.error.js.map +1 -1
- package/dist/lib/esm/errors/authenticator-instantiation.error.js +6 -10
- package/dist/lib/esm/errors/authenticator-instantiation.error.js.map +1 -1
- package/dist/lib/esm/errors/guard-decorator.error.js +10 -14
- package/dist/lib/esm/errors/guard-decorator.error.js.map +1 -1
- package/dist/lib/esm/errors/guard-instantiation.error.js +6 -10
- package/dist/lib/esm/errors/guard-instantiation.error.js.map +1 -1
- package/dist/lib/esm/factories/authenticator.factory.js +5 -2
- package/dist/lib/esm/factories/authenticator.factory.js.map +1 -1
- package/dist/lib/esm/factories/guard.factory.js +6 -2
- package/dist/lib/esm/factories/guard.factory.js.map +1 -1
- package/dist/lib/esm/guards/role.guard.js +7 -1
- package/dist/lib/esm/guards/role.guard.js.map +1 -1
- package/dist/lib/esm/managers/authentication.manager.js +9 -10
- package/dist/lib/esm/managers/authentication.manager.js.map +1 -1
- package/dist/lib/esm/managers/authorizer.manager.js +13 -25
- package/dist/lib/esm/managers/authorizer.manager.js.map +1 -1
- package/dist/lib/esm/tsconfig.tsbuildinfo +1 -1
- package/dist/types/errors/authenticator-decorator.error.d.ts +2 -2
- package/dist/types/errors/authenticator-instantiation.error.d.ts +2 -2
- package/dist/types/errors/guard-decorator.error.d.ts +2 -2
- package/dist/types/errors/guard-instantiation.error.d.ts +2 -2
- package/dist/types/managers/authentication.manager.d.ts +2 -3
- package/dist/types/managers/authorizer.manager.d.ts +2 -4
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guard-decorator.error.js","sourceRoot":"","sources":["../../../../src/errors/guard-decorator.error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,qBAAqB,CAAC;AAGlD;;GAEG;AACH,MAAM,OAAO,mBAAoB,SAAQ,aAAa;IAEpD,YAAmB,OAAe,EAAE,KAAgC,EAAE,OAAY,EAAE,MAAW,EAC5E,WAAoB,EACpB,UAA+B;QAChD,KAAK,CAAC,OAAO,EAAE;
|
|
1
|
+
{"version":3,"file":"guard-decorator.error.js","sourceRoot":"","sources":["../../../../src/errors/guard-decorator.error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,qBAAqB,CAAC;AAGlD;;GAEG;AACH,MAAM,OAAO,mBAAoB,SAAQ,aAAa;IAEpD,YAAmB,OAAe,EAAE,KAAgC,EAAE,OAAY,EAAE,MAAW,EAC5E,WAAoB,EACpB,UAA+B;QAChD,KAAK,CAAC,OAAO,EAAE,EAAC,OAAO,EAAE;gBACvB,OAAO;gBACP,KAAK;gBACL,OAAO;gBACP,MAAM;gBACN,WAAW;gBACX,UAAU;aACX,EAAC,CAAC,CAAC;IAAE,CAAC;CACV"}
|
|
@@ -1,17 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PristineError } from "@pristine-ts/common";
|
|
2
2
|
/**
|
|
3
3
|
* This Error is thrown when there's an error that happens when the guards ere being initialized
|
|
4
4
|
*/
|
|
5
|
-
export class GuardInstantiationError extends
|
|
5
|
+
export class GuardInstantiationError extends PristineError {
|
|
6
6
|
constructor(message, instantiatedGuard, guardContext) {
|
|
7
|
-
super(message, {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
// Set the prototype explicitly.
|
|
12
|
-
// As specified in the documentation in TypeScript
|
|
13
|
-
// https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#extending-built-ins-like-error-array-and-map-may-no-longer-work
|
|
14
|
-
Object.setPrototypeOf(this, GuardInstantiationError.prototype);
|
|
7
|
+
super(message, { details: {
|
|
8
|
+
instantiatedGuard,
|
|
9
|
+
guardContext,
|
|
10
|
+
} });
|
|
15
11
|
}
|
|
16
12
|
}
|
|
17
13
|
//# sourceMappingURL=guard-instantiation.error.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guard-instantiation.error.js","sourceRoot":"","sources":["../../../../src/errors/guard-instantiation.error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,qBAAqB,CAAC;AAGlD;;GAEG;AACH,MAAM,OAAO,uBAAwB,SAAQ,aAAa;IACxD,YAAmB,OAAe,EAAE,iBAA4C,EAAE,YAAiB;QACjG,KAAK,CAAC,OAAO,EAAE
|
|
1
|
+
{"version":3,"file":"guard-instantiation.error.js","sourceRoot":"","sources":["../../../../src/errors/guard-instantiation.error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,qBAAqB,CAAC;AAGlD;;GAEG;AACH,MAAM,OAAO,uBAAwB,SAAQ,aAAa;IACxD,YAAmB,OAAe,EAAE,iBAA4C,EAAE,YAAiB;QACjG,KAAK,CAAC,OAAO,EAAE,EAAC,OAAO,EAAE;gBACvB,iBAAiB;gBACjB,YAAY;aACb,EAAC,CAAC,CAAC;IAAE,CAAC;CACV"}
|
|
@@ -19,8 +19,11 @@ let AuthenticatorFactory = class AuthenticatorFactory {
|
|
|
19
19
|
fromContext(authenticatorContext, container) {
|
|
20
20
|
// Check if the guard needs to be instantiated
|
|
21
21
|
let instantiatedAuthenticator = authenticatorContext.authenticator;
|
|
22
|
-
//
|
|
23
|
-
//
|
|
22
|
+
// ── container.resolve, justified ────────────────────────────────────────────
|
|
23
|
+
// Per CLAUDE.md: factory whose target class is data carried on the route's
|
|
24
|
+
// `@authenticator(SomeAuth)` metadata. Token isn't known at factory construction;
|
|
25
|
+
// resolving it is the factory's entire purpose. Per-event container passed in by
|
|
26
|
+
// the router so the authenticator sees request-scoped dependencies.
|
|
24
27
|
if (typeof instantiatedAuthenticator === 'function') {
|
|
25
28
|
instantiatedAuthenticator = container.resolve(instantiatedAuthenticator);
|
|
26
29
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authenticator.factory.js","sourceRoot":"","sources":["../../../../src/factories/authenticator.factory.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAsB,UAAU,EAAC,MAAM,UAAU,CAAC;AAGzD,OAAO,EAAC,+BAA+B,EAAC,MAAM,6CAA6C,CAAC;AAE5F;;GAEG;AAEI,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IAE/B;;;;;OAKG;IACH,WAAW,CAAC,oBAAmD,EAAE,SAA8B;QAC7F,8CAA8C;QAC9C,IAAI,yBAAyB,GAA2B,oBAAoB,CAAC,aAAuC,CAAC;QAErH,
|
|
1
|
+
{"version":3,"file":"authenticator.factory.js","sourceRoot":"","sources":["../../../../src/factories/authenticator.factory.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAsB,UAAU,EAAC,MAAM,UAAU,CAAC;AAGzD,OAAO,EAAC,+BAA+B,EAAC,MAAM,6CAA6C,CAAC;AAE5F;;GAEG;AAEI,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IAE/B;;;;;OAKG;IACH,WAAW,CAAC,oBAAmD,EAAE,SAA8B;QAC7F,8CAA8C;QAC9C,IAAI,yBAAyB,GAA2B,oBAAoB,CAAC,aAAuC,CAAC;QAErH,+EAA+E;QAC/E,2EAA2E;QAC3E,kFAAkF;QAClF,iFAAiF;QACjF,oEAAoE;QACpE,IAAI,OAAO,yBAAyB,KAAK,UAAU,EAAE,CAAC;YACpD,yBAAyB,GAAG,SAAS,CAAC,OAAO,CAAC,yBAAyB,CAAC,CAAC;QAC3E,CAAC;QAED,uDAAuD;QACvD,IAAI,OAAO,yBAAyB,CAAC,YAAY,KAAK,UAAU,EAAE,CAAC;YACjE,MAAM,IAAI,+BAA+B,CAAC,oGAAoG,EAAE,yBAAyB,EAAE,oBAAoB,CAAC,CAAC;QACnM,CAAC;QAED,qDAAqD;QACrD,IAAI,OAAO,yBAAyB,CAAC,UAAU,KAAK,UAAU,EAAE,CAAC;YAC/D,MAAM,IAAI,+BAA+B,CAAC,kGAAkG,EAAE,yBAAyB,EAAE,oBAAoB,CAAC,CAAC;QACjM,CAAC;QAED,OAAO,yBAAyB,CAAC;IACnC,CAAC;CACF,CAAA;AAjCY,oBAAoB;IADhC,UAAU,EAAE;GACA,oBAAoB,CAiChC"}
|
|
@@ -19,8 +19,12 @@ let GuardFactory = class GuardFactory {
|
|
|
19
19
|
fromContext(guardContext, container) {
|
|
20
20
|
// Check if the guard needs to be instantiated
|
|
21
21
|
let instantiatedGuard = guardContext.guard;
|
|
22
|
-
//
|
|
23
|
-
//
|
|
22
|
+
// ── container.resolve, justified ────────────────────────────────────────────
|
|
23
|
+
// Per CLAUDE.md: this is a factory whose target class is data carried on the
|
|
24
|
+
// route's metadata (the `@guard(SomeGuard)` decorator value). The token isn't
|
|
25
|
+
// known at factory construction; the factory's whole job is to look it up. The
|
|
26
|
+
// per-event child container is passed in by the router so the resolved guard
|
|
27
|
+
// sees the correct request-scoped dependencies.
|
|
24
28
|
if (typeof instantiatedGuard === 'function') {
|
|
25
29
|
instantiatedGuard = container.resolve(instantiatedGuard);
|
|
26
30
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guard.factory.js","sourceRoot":"","sources":["../../../../src/factories/guard.factory.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAsB,UAAU,EAAC,MAAM,UAAU,CAAC;AAGzD,OAAO,EAAC,uBAAuB,EAAC,MAAM,qCAAqC,CAAC;AAE5E;;GAEG;AAEI,IAAM,YAAY,GAAlB,MAAM,YAAY;IAEvB;;;;;OAKG;IACH,WAAW,CAAC,YAAmC,EAAE,SAA8B;QAC7E,8CAA8C;QAC9C,IAAI,iBAAiB,GAAmB,YAAY,CAAC,KAAuB,CAAC;QAE7E,
|
|
1
|
+
{"version":3,"file":"guard.factory.js","sourceRoot":"","sources":["../../../../src/factories/guard.factory.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAsB,UAAU,EAAC,MAAM,UAAU,CAAC;AAGzD,OAAO,EAAC,uBAAuB,EAAC,MAAM,qCAAqC,CAAC;AAE5E;;GAEG;AAEI,IAAM,YAAY,GAAlB,MAAM,YAAY;IAEvB;;;;;OAKG;IACH,WAAW,CAAC,YAAmC,EAAE,SAA8B;QAC7E,8CAA8C;QAC9C,IAAI,iBAAiB,GAAmB,YAAY,CAAC,KAAuB,CAAC;QAE7E,+EAA+E;QAC/E,6EAA6E;QAC7E,8EAA8E;QAC9E,+EAA+E;QAC/E,6EAA6E;QAC7E,gDAAgD;QAChD,IAAI,OAAO,iBAAiB,KAAK,UAAU,EAAE,CAAC;YAC5C,iBAAiB,GAAG,SAAS,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;QAC3D,CAAC;QAED,uDAAuD;QACvD,IAAI,OAAO,iBAAiB,CAAC,YAAY,KAAK,UAAU,EAAE,CAAC;YACzD,MAAM,IAAI,uBAAuB,CAAC,wDAAwD,EAAE,iBAAiB,EAAE,YAAY,CAAC,CAAC;QAC/H,CAAC;QAED,qDAAqD;QACrD,IAAI,OAAO,iBAAiB,CAAC,UAAU,KAAK,UAAU,EAAE,CAAC;YACvD,MAAM,IAAI,uBAAuB,CAAC,sDAAsD,EAAE,iBAAiB,EAAE,YAAY,CAAC,CAAC;QAC7H,CAAC;QAED,OAAO,iBAAiB,CAAC;IAC3B,CAAC;CACF,CAAA;AAlCY,YAAY;IADxB,UAAU,EAAE;GACA,YAAY,CAkCxB"}
|
|
@@ -21,7 +21,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
21
21
|
};
|
|
22
22
|
import { inject, injectable } from "tsyringe";
|
|
23
23
|
import { SecurityConfigurationKeys } from "../security.configuration-keys";
|
|
24
|
-
import { injectConfig } from "@pristine-ts/common";
|
|
24
|
+
import { injectConfig, Request, traced } from "@pristine-ts/common";
|
|
25
25
|
/**
|
|
26
26
|
* The role guard is a guard that validates if the identity making the request has the required roles.
|
|
27
27
|
*/
|
|
@@ -98,6 +98,12 @@ let RoleGuard = class RoleGuard {
|
|
|
98
98
|
});
|
|
99
99
|
}
|
|
100
100
|
};
|
|
101
|
+
__decorate([
|
|
102
|
+
traced(),
|
|
103
|
+
__metadata("design:type", Function),
|
|
104
|
+
__metadata("design:paramtypes", [Request, Object]),
|
|
105
|
+
__metadata("design:returntype", Promise)
|
|
106
|
+
], RoleGuard.prototype, "isAuthorized", null);
|
|
101
107
|
RoleGuard = __decorate([
|
|
102
108
|
injectable(),
|
|
103
109
|
__param(0, injectConfig(SecurityConfigurationKeys.RolesClaimKey)),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"role.guard.js","sourceRoot":"","sources":["../../../../src/guards/role.guard.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;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S;IADrB,UAAU,EAAE;IAgBE,WAAA,YAAY,CAAC,yBAAyB,CAAC,aAAa,CAAC,CAAA;IACrD,WAAA,MAAM,CAAC,qBAAqB,CAAC,CAAA;;GAhB/B,SAAS,CAkFrB"}
|
|
@@ -20,7 +20,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
20
20
|
});
|
|
21
21
|
};
|
|
22
22
|
import { inject, injectable, injectAll } from "tsyringe";
|
|
23
|
-
import { moduleScoped, ServiceDefinitionTagEnum, tag } from "@pristine-ts/common";
|
|
23
|
+
import { moduleScoped, Request, ServiceDefinitionTagEnum, tag, traced } from "@pristine-ts/common";
|
|
24
24
|
import { AuthenticatorFactory } from "../factories/authenticator.factory";
|
|
25
25
|
import { SecurityModuleKeyname } from "../security.module.keyname";
|
|
26
26
|
import { authenticatorMetadataKeyname } from "../decorators/authenticator.decorator";
|
|
@@ -35,11 +35,10 @@ let AuthenticationManager = class AuthenticationManager {
|
|
|
35
35
|
* @param logHandler The log handler to output logs.
|
|
36
36
|
* @param authenticatorFactory The factory to create the authenticator.
|
|
37
37
|
*/
|
|
38
|
-
constructor(identityProviders, logHandler, authenticatorFactory
|
|
38
|
+
constructor(identityProviders, logHandler, authenticatorFactory) {
|
|
39
39
|
this.identityProviders = identityProviders;
|
|
40
40
|
this.logHandler = logHandler;
|
|
41
41
|
this.authenticatorFactory = authenticatorFactory;
|
|
42
|
-
this.breadcrumbHandler = breadcrumbHandler;
|
|
43
42
|
}
|
|
44
43
|
/**
|
|
45
44
|
* Authenticates a request by providing the identity that made the request.
|
|
@@ -49,10 +48,6 @@ let AuthenticationManager = class AuthenticationManager {
|
|
|
49
48
|
*/
|
|
50
49
|
authenticate(request, routeContext, container) {
|
|
51
50
|
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
-
this.breadcrumbHandler.add(request.id, `${SecurityModuleKeyname}:authentication.manager:authenticate:enter`, {
|
|
53
|
-
request,
|
|
54
|
-
routeContext
|
|
55
|
-
});
|
|
56
51
|
if (!routeContext || routeContext[authenticatorMetadataKeyname] === undefined) {
|
|
57
52
|
return undefined;
|
|
58
53
|
}
|
|
@@ -81,7 +76,6 @@ let AuthenticationManager = class AuthenticationManager {
|
|
|
81
76
|
highlights: {
|
|
82
77
|
identity,
|
|
83
78
|
},
|
|
84
|
-
breadcrumb: `${SecurityModuleKeyname}:authentication.manager:authenticate:return`,
|
|
85
79
|
extra: {
|
|
86
80
|
request,
|
|
87
81
|
routeContext,
|
|
@@ -91,14 +85,19 @@ let AuthenticationManager = class AuthenticationManager {
|
|
|
91
85
|
});
|
|
92
86
|
}
|
|
93
87
|
};
|
|
88
|
+
__decorate([
|
|
89
|
+
traced(),
|
|
90
|
+
__metadata("design:type", Function),
|
|
91
|
+
__metadata("design:paramtypes", [Request, Object, Object]),
|
|
92
|
+
__metadata("design:returntype", Promise)
|
|
93
|
+
], AuthenticationManager.prototype, "authenticate", null);
|
|
94
94
|
AuthenticationManager = __decorate([
|
|
95
95
|
moduleScoped(SecurityModuleKeyname),
|
|
96
96
|
tag("AuthenticationManagerInterface"),
|
|
97
97
|
injectable(),
|
|
98
98
|
__param(0, injectAll(ServiceDefinitionTagEnum.IdentityProvider, { isOptional: true })),
|
|
99
99
|
__param(1, inject("LogHandlerInterface")),
|
|
100
|
-
|
|
101
|
-
__metadata("design:paramtypes", [Array, Object, AuthenticatorFactory, Object])
|
|
100
|
+
__metadata("design:paramtypes", [Array, Object, AuthenticatorFactory])
|
|
102
101
|
], AuthenticationManager);
|
|
103
102
|
export { AuthenticationManager };
|
|
104
103
|
//# sourceMappingURL=authentication.manager.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authentication.manager.js","sourceRoot":"","sources":["../../../../src/managers/authentication.manager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAsB,MAAM,EAAE,UAAU,EAAE,SAAS,EAAC,MAAM,UAAU,CAAC;AAE5E,OAAO,EAAoB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AC,YAAY,CAAC,OAAO,CAAC,CAAC;gBAEjE,IAAI,QAAQ,IAAI,SAAS,EAAE,CAAC;oBAC1B,OAAO,QAAQ,CAAC;gBAClB,CAAC;gBAED,mCAAmC;gBACnC,KAAK,MAAM,gBAAgB,IAAI,IAAI,CAAC,iBAAiB,EAAE,CAAC;oBACtD,QAAQ,GAAG,MAAM,gBAAgB,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;gBACtD,CAAC;YAEH,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,0DAA0D,EAAE;oBAChF,KAAK,EAAE,EAAC,KAAK,EAAE,CAAC,EAAC;iBAClB,CAAC,CAAC;gBACH,MAAM,CAAC,CAAC;YACV,CAAC;YAED,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,kCAAkC,EAAE;gBACvD,UAAU,EAAE;oBACV,QAAQ;iBACT;gBACD,KAAK,EAAE;oBACL,OAAO;oBACP,YAAY;iBACb;aACF,CAAC,CAAA;YACF,OAAO,QAAQ,CAAC;QAClB,CAAC;KAAA;CACF,CAAA;AA7Cc;IADZ,MAAM,EAAE;;qCAC0B,OAAO;;yDA4CzC;AAjEU,qBAAqB;IAHjC,YAAY,CAAC,qBAAqB,CAAC;IACnC,GAAG,CAAC,gCAAgC,CAAC;IACrC,UAAU,EAAE;IAUR,WAAA,SAAS,CAAC,wBAAwB,CAAC,gBAAgB,EAAE,EAAC,UAAU,EAAE,IAAI,EAAC,CAAC,CAAA;IACxE,WAAA,MAAM,CAAC,qBAAqB,CAAC,CAAA;oDACS,oBAAoB;GAXlD,qBAAqB,CAkEjC"}
|
|
@@ -20,7 +20,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
20
20
|
});
|
|
21
21
|
};
|
|
22
22
|
import { inject, injectable } from "tsyringe";
|
|
23
|
-
import { moduleScoped, tag } from "@pristine-ts/common";
|
|
23
|
+
import { moduleScoped, Request, tag, traced } from "@pristine-ts/common";
|
|
24
24
|
import { GuardFactory } from "../factories/guard.factory";
|
|
25
25
|
import { SecurityModuleKeyname } from "../security.module.keyname";
|
|
26
26
|
import { guardMetadataKeyname } from "../decorators/guard.decorator";
|
|
@@ -33,12 +33,10 @@ let AuthorizerManager = class AuthorizerManager {
|
|
|
33
33
|
* The authorizer manager provides authorization by authorizing the action.
|
|
34
34
|
* @param logHandler The log handler to output logs.
|
|
35
35
|
* @param guardFactory The factory to create the guard.
|
|
36
|
-
* @param breadcrumbHandler
|
|
37
36
|
*/
|
|
38
|
-
constructor(logHandler, guardFactory
|
|
37
|
+
constructor(logHandler, guardFactory) {
|
|
39
38
|
this.logHandler = logHandler;
|
|
40
39
|
this.guardFactory = guardFactory;
|
|
41
|
-
this.breadcrumbHandler = breadcrumbHandler;
|
|
42
40
|
}
|
|
43
41
|
/**
|
|
44
42
|
* Returns whether or not the request is authorized to access the route.
|
|
@@ -50,11 +48,6 @@ let AuthorizerManager = class AuthorizerManager {
|
|
|
50
48
|
isAuthorized(request, routeContext, container, identity) {
|
|
51
49
|
return __awaiter(this, void 0, void 0, function* () {
|
|
52
50
|
var _a, _b, _c;
|
|
53
|
-
// If there are no guards defined, we simply return that it is authorized.
|
|
54
|
-
this.breadcrumbHandler.add(request.id, `${SecurityModuleKeyname}:authorizer.manager:isAuthorized:enter`, {
|
|
55
|
-
request,
|
|
56
|
-
routeContext
|
|
57
|
-
});
|
|
58
51
|
if (!routeContext || routeContext[guardMetadataKeyname] === undefined || Array.isArray(routeContext[guardMetadataKeyname]) === false) {
|
|
59
52
|
return true;
|
|
60
53
|
}
|
|
@@ -84,31 +77,26 @@ let AuthorizerManager = class AuthorizerManager {
|
|
|
84
77
|
isAuthorized = false;
|
|
85
78
|
}
|
|
86
79
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
breadcrumb: `${SecurityModuleKeyname}:authorizer.manager:isAuthorized:return`
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
95
|
-
this.logHandler.info(`User authorized`, {
|
|
96
|
-
headlights: { isAuthorized },
|
|
97
|
-
extra: { request, routeContext },
|
|
98
|
-
breadcrumb: `${SecurityModuleKeyname}:authorizer.manager:isAuthorized:return`
|
|
99
|
-
});
|
|
100
|
-
}
|
|
80
|
+
this.logHandler.info(`User authorized`, {
|
|
81
|
+
headlights: { isAuthorized },
|
|
82
|
+
extra: { request, routeContext },
|
|
83
|
+
});
|
|
101
84
|
return isAuthorized;
|
|
102
85
|
});
|
|
103
86
|
}
|
|
104
87
|
};
|
|
88
|
+
__decorate([
|
|
89
|
+
traced(),
|
|
90
|
+
__metadata("design:type", Function),
|
|
91
|
+
__metadata("design:paramtypes", [Request, Object, Object, Object]),
|
|
92
|
+
__metadata("design:returntype", Promise)
|
|
93
|
+
], AuthorizerManager.prototype, "isAuthorized", null);
|
|
105
94
|
AuthorizerManager = __decorate([
|
|
106
95
|
moduleScoped(SecurityModuleKeyname),
|
|
107
96
|
tag("AuthorizerManagerInterface"),
|
|
108
97
|
injectable(),
|
|
109
98
|
__param(0, inject("LogHandlerInterface")),
|
|
110
|
-
|
|
111
|
-
__metadata("design:paramtypes", [Object, GuardFactory, Object])
|
|
99
|
+
__metadata("design:paramtypes", [Object, GuardFactory])
|
|
112
100
|
], AuthorizerManager);
|
|
113
101
|
export { AuthorizerManager };
|
|
114
102
|
//# sourceMappingURL=authorizer.manager.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authorizer.manager.js","sourceRoot":"","sources":["../../../../src/managers/authorizer.manager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAsB,MAAM,EAAE,UAAU,EAAC,MAAM,UAAU,CAAC;AAEjE,OAAO,EAAoB,YAAY,
|
|
1
|
+
{"version":3,"file":"authorizer.manager.js","sourceRoot":"","sources":["../../../../src/managers/authorizer.manager.ts"],"names":[],"mappings":";;;;;;;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