@pristine-ts/security 0.0.189 → 0.0.190
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/decorators/authenticator.decorator.js +6 -0
- package/dist/lib/cjs/decorators/authenticator.decorator.js.map +1 -1
- package/dist/lib/cjs/decorators/guard.decorator.js +6 -0
- package/dist/lib/cjs/decorators/guard.decorator.js.map +1 -1
- package/dist/lib/cjs/enums/resource-action.enum.js +5 -0
- package/dist/lib/cjs/enums/resource-action.enum.js.map +1 -1
- package/dist/lib/cjs/enums/vote.enum.js +3 -0
- package/dist/lib/cjs/enums/vote.enum.js.map +1 -1
- package/dist/lib/cjs/enums/voting-strategy.enum.js +10 -0
- package/dist/lib/cjs/enums/voting-strategy.enum.js.map +1 -1
- package/dist/lib/cjs/errors/authenticator-decorator.error.js +2 -2
- package/dist/lib/cjs/errors/authenticator-decorator.error.js.map +1 -1
- package/dist/lib/cjs/errors/authenticator-instantiation.error.js +1 -1
- package/dist/lib/cjs/errors/authenticator-instantiation.error.js.map +1 -1
- package/dist/lib/cjs/errors/errors.js +1 -0
- package/dist/lib/cjs/errors/errors.js.map +1 -1
- package/dist/lib/cjs/errors/guard-decorator.error.js +1 -1
- package/dist/lib/cjs/errors/guard-decorator.error.js.map +1 -1
- package/dist/lib/cjs/errors/guard-instantiation.error.js +1 -1
- package/dist/lib/cjs/errors/guard-instantiation.error.js.map +1 -1
- package/dist/lib/cjs/factories/authenticator.factory.js +11 -0
- package/dist/lib/cjs/factories/authenticator.factory.js.map +1 -1
- package/dist/lib/cjs/factories/guard.factory.js +11 -0
- package/dist/lib/cjs/factories/guard.factory.js.map +1 -1
- package/dist/lib/cjs/guards/role.guard.js +26 -0
- package/dist/lib/cjs/guards/role.guard.js.map +1 -1
- package/dist/lib/cjs/interfaces/interfaces.js +2 -0
- package/dist/lib/cjs/interfaces/interfaces.js.map +1 -1
- package/dist/lib/cjs/managers/authentication.manager.js +16 -1
- package/dist/lib/cjs/managers/authentication.manager.js.map +1 -1
- package/dist/lib/cjs/managers/authorizer.manager.js +16 -0
- package/dist/lib/cjs/managers/authorizer.manager.js.map +1 -1
- package/dist/lib/cjs/managers/managers.js +1 -1
- package/dist/lib/cjs/managers/managers.js.map +1 -1
- package/dist/lib/cjs/managers/permission.manager.js +16 -0
- package/dist/lib/cjs/managers/permission.manager.js.map +1 -1
- package/dist/lib/cjs/providers/default-identity.provider.js +2 -0
- package/dist/lib/cjs/providers/default-identity.provider.js.map +1 -1
- package/dist/lib/cjs/security.module.js +3 -0
- package/dist/lib/cjs/security.module.js.map +1 -1
- package/dist/lib/esm/decorators/authenticator.decorator.js +6 -0
- package/dist/lib/esm/decorators/authenticator.decorator.js.map +1 -1
- package/dist/lib/esm/decorators/guard.decorator.js +6 -0
- package/dist/lib/esm/decorators/guard.decorator.js.map +1 -1
- package/dist/lib/esm/enums/resource-action.enum.js +5 -0
- package/dist/lib/esm/enums/resource-action.enum.js.map +1 -1
- package/dist/lib/esm/enums/vote.enum.js +3 -0
- package/dist/lib/esm/enums/vote.enum.js.map +1 -1
- package/dist/lib/esm/enums/voting-strategy.enum.js +10 -0
- package/dist/lib/esm/enums/voting-strategy.enum.js.map +1 -1
- package/dist/lib/esm/errors/authenticator-decorator.error.js +2 -2
- package/dist/lib/esm/errors/authenticator-decorator.error.js.map +1 -1
- package/dist/lib/esm/errors/authenticator-instantiation.error.js +1 -1
- package/dist/lib/esm/errors/authenticator-instantiation.error.js.map +1 -1
- package/dist/lib/esm/errors/errors.js +1 -0
- package/dist/lib/esm/errors/errors.js.map +1 -1
- package/dist/lib/esm/errors/guard-decorator.error.js +1 -1
- package/dist/lib/esm/errors/guard-decorator.error.js.map +1 -1
- package/dist/lib/esm/errors/guard-instantiation.error.js +1 -1
- package/dist/lib/esm/errors/guard-instantiation.error.js.map +1 -1
- package/dist/lib/esm/factories/authenticator.factory.js +11 -0
- package/dist/lib/esm/factories/authenticator.factory.js.map +1 -1
- package/dist/lib/esm/factories/guard.factory.js +11 -0
- package/dist/lib/esm/factories/guard.factory.js.map +1 -1
- package/dist/lib/esm/guards/role.guard.js +26 -0
- package/dist/lib/esm/guards/role.guard.js.map +1 -1
- package/dist/lib/esm/interfaces/interfaces.js +2 -0
- package/dist/lib/esm/interfaces/interfaces.js.map +1 -1
- package/dist/lib/esm/managers/authentication.manager.js +16 -1
- package/dist/lib/esm/managers/authentication.manager.js.map +1 -1
- package/dist/lib/esm/managers/authorizer.manager.js +16 -0
- package/dist/lib/esm/managers/authorizer.manager.js.map +1 -1
- package/dist/lib/esm/managers/managers.js +1 -1
- package/dist/lib/esm/managers/managers.js.map +1 -1
- package/dist/lib/esm/managers/permission.manager.js +16 -0
- package/dist/lib/esm/managers/permission.manager.js.map +1 -1
- package/dist/lib/esm/providers/default-identity.provider.js +2 -0
- package/dist/lib/esm/providers/default-identity.provider.js.map +1 -1
- package/dist/lib/esm/security.module.js +3 -0
- package/dist/lib/esm/security.module.js.map +1 -1
- package/dist/types/decorators/authenticator.decorator.d.ts +6 -0
- package/dist/types/decorators/guard.decorator.d.ts +6 -0
- package/dist/types/enums/resource-action.enum.d.ts +5 -0
- package/dist/types/enums/vote.enum.d.ts +3 -0
- package/dist/types/enums/voting-strategy.enum.d.ts +10 -0
- package/dist/types/errors/authenticator-decorator.error.d.ts +3 -3
- package/dist/types/errors/authenticator-instantiation.error.d.ts +2 -2
- package/dist/types/errors/errors.d.ts +1 -0
- 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/factories/authenticator.factory.d.ts +9 -0
- package/dist/types/factories/guard.factory.d.ts +9 -0
- package/dist/types/guards/role.guard.d.ts +24 -0
- package/dist/types/interfaces/authentication-manager.interface.d.ts +11 -0
- package/dist/types/interfaces/authenticator-context.interface.d.ts +12 -0
- package/dist/types/interfaces/authenticator.interface.d.ts +9 -0
- package/dist/types/interfaces/authorizer-manager.interface.d.ts +11 -0
- package/dist/types/interfaces/guard-context.interface.d.ts +13 -0
- package/dist/types/interfaces/guard.interface.d.ts +15 -0
- package/dist/types/interfaces/identity-provider.interface.d.ts +9 -0
- package/dist/types/interfaces/interfaces.d.ts +2 -0
- package/dist/types/interfaces/voter.interface.d.ts +14 -0
- package/dist/types/managers/authentication.manager.d.ts +16 -0
- package/dist/types/managers/authorizer.manager.d.ts +16 -0
- package/dist/types/managers/managers.d.ts +1 -1
- package/dist/types/managers/permission.manager.d.ts +16 -0
- package/dist/types/providers/default-identity.provider.d.ts +2 -0
- package/package.json +4 -4
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.authenticator = void 0;
|
|
4
4
|
const authenticator_decorator_error_1 = require("../errors/authenticator-decorator.error");
|
|
5
|
+
/**
|
|
6
|
+
* This decorator specifies the authenticator that should be used to authenticate a request.
|
|
7
|
+
* It should be used either on a controller class or directly on a method.
|
|
8
|
+
* @param authenticator The authenticator to use.
|
|
9
|
+
* @param options Any options that will be passed on to the authenticator.
|
|
10
|
+
*/
|
|
5
11
|
const authenticator = (authenticator, options) => {
|
|
6
12
|
return (target, propertyKey, descriptor) => {
|
|
7
13
|
// This is the condition to check that the authenticator is valid.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authenticator.decorator.js","sourceRoot":"","sources":["../../../../src/decorators/authenticator.decorator.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"authenticator.decorator.js","sourceRoot":"","sources":["../../../../src/decorators/authenticator.decorator.ts"],"names":[],"mappings":";;;AAEA,2FAAoF;AAEpF;;;;;GAKG;AACI,MAAM,aAAa,GAAG,CAAC,aAAgD,EAAE,OAAa,EAAE,EAAE;IAC7F,OAAO,CAAE,MAAW,EACX,WAAoB,EACpB,UAA+B,EAAE,EAAE;QAGxC,kEAAkE;QAClE,IAAG,CAAC,CAAC,aAAa,IAAI,CAClB,CAAC,OAAO,aAAa,KAAK,UAA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|
|
4
4
|
const guard_decorator_error_1 = require("../errors/guard-decorator.error");
|
|
5
|
+
/**
|
|
6
|
+
* This decorator specifies the guard that should be used to authorize a request.
|
|
7
|
+
* It should be used either on a controller class or directly on a method.
|
|
8
|
+
* @param guard
|
|
9
|
+
* @param options Any options that will be passed on to the guard.
|
|
10
|
+
*/
|
|
5
11
|
const guard = (guard, options) => {
|
|
6
12
|
return (target, propertyKey, descriptor) => {
|
|
7
13
|
// Validate the interface of the guard
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guard.decorator.js","sourceRoot":"","sources":["../../../../src/decorators/guard.decorator.ts"],"names":[],"mappings":";;;AACA,2EAAoE;
|
|
1
|
+
{"version":3,"file":"guard.decorator.js","sourceRoot":"","sources":["../../../../src/decorators/guard.decorator.ts"],"names":[],"mappings":";;;AACA,2EAAoE;AAGpE;;;;;GAKG;AACI,MAAM,KAAK,GAAG,CAAC,KAAgC,EAAE,OAAa,EAAE,EAAE;IACrE,OAAO,CAAE,MAAW,EACX,WAAoB,EACpB,UAA+B,EAAE,EAAE;QAExC,sCAAsC;QACtC,IAAI,CAAC,CAAC,KAAK,IAAI,CACX,CAAC,OAAO,KAAK,KAAK,UAAU,IAAI,OAAO,KAAK,CAAC,SAAS,CAAC,YAAY,KAAK,UAAU,CAAC;YACnF,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,CAAC,YAAY,KAAK,UAAU,CAAC,CAC1E,CAAC,EAAE;YACA,MAAM,IAAI,2CAAmB,CAAC,4FAA4F,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC;SAChL;QAED,+BAA+B;QAC/B,MAAM,YAAY,GAA2B;YACzC,eAAe,EAAG,KAAa,CAAC,SAAS,CAAC,WAAW,CAAC,IAAI;YAC1D,KAAK;YACL,OAAO;SACV,CAAC;QAEF,gFAAgF;QAChF,IAAG,UAAU,IAAI,WAAW,EAAE;YAC1B,IAAG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ineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ResourceActionEnum = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* The resource action enum specifies the most common actions that can be taken on a resource.
|
|
6
|
+
* It's used in the voters to validate if a user is authorized to execute that action.
|
|
7
|
+
* More actions can be defined in more specified enum based on the resource type.
|
|
8
|
+
*/
|
|
4
9
|
var ResourceActionEnum;
|
|
5
10
|
(function (ResourceActionEnum) {
|
|
6
11
|
ResourceActionEnum["List"] = "LIST";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource-action.enum.js","sourceRoot":"","sources":["../../../../src/enums/resource-action.enum.ts"],"names":[],"mappings":";;;AAAA,IAAY,kBAMX;AAND,WAAY,kBAAkB;IAC1B,mCAAa,CAAA;IACb,mCAAa,CAAA;IACb,uCAAiB,CAAA;IACjB,uCAAiB,CAAA;IACjB,uCAAiB,CAAA;AACrB,CAAC,EANW,kBAAkB,GAAlB,0BAAkB,KAAlB,0BAAkB,QAM7B"}
|
|
1
|
+
{"version":3,"file":"resource-action.enum.js","sourceRoot":"","sources":["../../../../src/enums/resource-action.enum.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACH,IAAY,kBAMX;AAND,WAAY,kBAAkB;IAC1B,mCAAa,CAAA;IACb,mCAAa,CAAA;IACb,uCAAiB,CAAA;IACjB,uCAAiB,CAAA;IACjB,uCAAiB,CAAA;AACrB,CAAC,EANW,kBAAkB,GAAlB,0BAAkB,KAAlB,0BAAkB,QAM7B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vote.enum.js","sourceRoot":"","sources":["../../../../src/enums/vote.enum.ts"],"names":[],"mappings":";;;AAAA,IAAY,QAIX;AAJD,WAAY,QAAQ;IAChB,2BAAe,CAAA;IACf,yBAAa,CAAA;IACb,+BAAmB,CAAA;AACvB,CAAC,EAJW,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAInB"}
|
|
1
|
+
{"version":3,"file":"vote.enum.js","sourceRoot":"","sources":["../../../../src/enums/vote.enum.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,IAAY,QAIX;AAJD,WAAY,QAAQ;IAChB,2BAAe,CAAA;IACf,yBAAa,CAAA;IACb,+BAAmB,CAAA;AACvB,CAAC,EAJW,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAInB"}
|
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.VotingStrategyEnum = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* The voting strategy enum defines the different strategies that the permission manager uses to
|
|
6
|
+
* merge the results of all the voter.
|
|
7
|
+
*/
|
|
4
8
|
var VotingStrategyEnum;
|
|
5
9
|
(function (VotingStrategyEnum) {
|
|
10
|
+
/**
|
|
11
|
+
* When all the voters abstain from voting, the access is granted.
|
|
12
|
+
*/
|
|
6
13
|
VotingStrategyEnum["GrantOnUnanimousAbstention"] = "GRANT_ON_UNANIMOUS_ABSTENTION";
|
|
14
|
+
/**
|
|
15
|
+
* When all the voters abstain from voting, the access is denied.
|
|
16
|
+
*/
|
|
7
17
|
VotingStrategyEnum["DenyOnUnanimousAbstention"] = "DENY_ON_UNANIMOUS_ABSTENTION";
|
|
8
18
|
})(VotingStrategyEnum = exports.VotingStrategyEnum || (exports.VotingStrategyEnum = {}));
|
|
9
19
|
//# sourceMappingURL=voting-strategy.enum.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"voting-strategy.enum.js","sourceRoot":"","sources":["../../../../src/enums/voting-strategy.enum.ts"],"names":[],"mappings":";;;AAAA,IAAY,
|
|
1
|
+
{"version":3,"file":"voting-strategy.enum.js","sourceRoot":"","sources":["../../../../src/enums/voting-strategy.enum.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,IAAY,kBAUX;AAVD,WAAY,kBAAkB;IAC1B;;OAEG;IACH,kFAA4D,CAAA;IAE5D;;OAEG;IACH,gFAA0D,CAAA;AAC9D,CAAC,EAVW,kBAAkB,GAAlB,0BAAkB,KAAlB,0BAAkB,QAU7B"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AuthenticatorDecoratorError = void 0;
|
|
4
|
+
const common_1 = require("@pristine-ts/common");
|
|
4
5
|
/**
|
|
5
|
-
* This Error is thrown when there's an error
|
|
6
|
+
* This Error is thrown when there's an error with the authenticator decorator.
|
|
6
7
|
*/
|
|
7
|
-
const common_1 = require("@pristine-ts/common");
|
|
8
8
|
class AuthenticatorDecoratorError extends common_1.LoggableError {
|
|
9
9
|
constructor(message, authenticator, options, target, propertyKey, descriptor) {
|
|
10
10
|
super(message, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authenticator-decorator.error.js","sourceRoot":"","sources":["../../../../src/errors/authenticator-decorator.error.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,
|
|
1
|
+
{"version":3,"file":"authenticator-decorator.error.js","sourceRoot":"","sources":["../../../../src/errors/authenticator-decorator.error.ts"],"names":[],"mappings":";;;AAAA,gDAAkD;AAGlD;;GAEG;AACH,MAAa,2BAA4B,SAAQ,sBAAa;IAE1D,YAAmB,OAAe,EAAE,aAAgD,EAAE,OAAY,EAAE,MAAW,EAC5F,WAAoB,EACpB,UAA+B;QAC9C,KAAK,CAAC,OAAO,EAAE;YACX,OAAO;YACP,aAAa;YACb,OAAO;YACP,MAAM;YACN,WAAW;YACX,UAAU;SACb,CAAC,CAAC;QAEH,gCAAgC;QAChC,kDAAkD;QAClD,gIAAgI;QAChI,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,2BAA2B,CAAC,SAAS,CAAC,CAAC;IACvE,CAAC;CACJ;AAnBD,kEAmBC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AuthenticatorInstantiationError = void 0;
|
|
4
|
+
const common_1 = require("@pristine-ts/common");
|
|
4
5
|
/**
|
|
5
6
|
* This Error is thrown when there's an error that happens when the authenticator are being initialized
|
|
6
7
|
*/
|
|
7
|
-
const common_1 = require("@pristine-ts/common");
|
|
8
8
|
class AuthenticatorInstantiationError extends common_1.LoggableError {
|
|
9
9
|
constructor(message, instantiatedAuthenticator, authenticatorContext) {
|
|
10
10
|
super(message, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authenticator-instantiation.error.js","sourceRoot":"","sources":["../../../../src/errors/authenticator-instantiation.error.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,
|
|
1
|
+
{"version":3,"file":"authenticator-instantiation.error.js","sourceRoot":"","sources":["../../../../src/errors/authenticator-instantiation.error.ts"],"names":[],"mappings":";;;AAAA,gDAAkD;AAGlD;;GAEG;AACH,MAAa,+BAAgC,SAAQ,sBAAa;IAG9D,YAAmB,OAAe,EAAE,yBAA4D,EAAE,oBAAyB;QACvH,KAAK,CAAC,OAAO,EAAE;YACX,yBAAyB;YACzB,oBAAoB;SACvB,CAAC,CAAC;QAEH,gCAAgC;QAChC,kDAAkD;QAClD,gIAAgI;QAChI,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,+BAA+B,CAAC,SAAS,CAAC,CAAC;IAC3E,CAAC;CACJ;AAdD,0EAcC"}
|
|
@@ -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("./authenticator-decorator.error"), exports);
|
|
13
14
|
__exportStar(require("./authenticator-instantiation.error"), exports);
|
|
14
15
|
__exportStar(require("./guard-decorator.error"), exports);
|
|
15
16
|
__exportStar(require("./guard-instantiation.error"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../../src/errors/errors.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,sEAAoD;AACpD,0DAAwC;AACxC,8DAA4C"}
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../../src/errors/errors.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kEAAgD;AAChD,sEAAoD;AACpD,0DAAwC;AACxC,8DAA4C"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.GuardDecoratorError = void 0;
|
|
4
|
+
const common_1 = require("@pristine-ts/common");
|
|
4
5
|
/**
|
|
5
6
|
* This Error is thrown when there's an error that happens when the guards ere being initialized
|
|
6
7
|
*/
|
|
7
|
-
const common_1 = require("@pristine-ts/common");
|
|
8
8
|
class GuardDecoratorError extends common_1.LoggableError {
|
|
9
9
|
constructor(message, guard, options, target, propertyKey, descriptor) {
|
|
10
10
|
super(message, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guard-decorator.error.js","sourceRoot":"","sources":["../../../../src/errors/guard-decorator.error.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,
|
|
1
|
+
{"version":3,"file":"guard-decorator.error.js","sourceRoot":"","sources":["../../../../src/errors/guard-decorator.error.ts"],"names":[],"mappings":";;;AAAA,gDAAkD;AAGlD;;GAEG;AACH,MAAa,mBAAoB,SAAQ,sBAAa;IAElD,YAAmB,OAAe,EAAE,KAAgC,EAAE,OAAY,EAAE,MAAW,EAC5E,WAAoB,EACpB,UAA+B;QAC9C,KAAK,CAAC,OAAO,EAAE;YACX,OAAO;YACP,KAAK;YACL,OAAO;YACP,MAAM;YACN,WAAW;YACX,UAAU;SACb,CAAC,CAAC;QAEH,gCAAgC;QAChC,kDAAkD;QAClD,gIAAgI;QAChI,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,mBAAmB,CAAC,SAAS,CAAC,CAAC;IAC/D,CAAC;CACJ;AAnBD,kDAmBC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.GuardInstantiationError = void 0;
|
|
4
|
+
const common_1 = require("@pristine-ts/common");
|
|
4
5
|
/**
|
|
5
6
|
* This Error is thrown when there's an error that happens when the guards ere being initialized
|
|
6
7
|
*/
|
|
7
|
-
const common_1 = require("@pristine-ts/common");
|
|
8
8
|
class GuardInstantiationError extends common_1.LoggableError {
|
|
9
9
|
constructor(message, instantiatedGuard, guardContext) {
|
|
10
10
|
super(message, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guard-instantiation.error.js","sourceRoot":"","sources":["../../../../src/errors/guard-instantiation.error.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,
|
|
1
|
+
{"version":3,"file":"guard-instantiation.error.js","sourceRoot":"","sources":["../../../../src/errors/guard-instantiation.error.ts"],"names":[],"mappings":";;;AAAA,gDAAkD;AAGlD;;GAEG;AACH,MAAa,uBAAwB,SAAQ,sBAAa;IACtD,YAAmB,OAAe,EAAE,iBAA4C,EAAE,YAAiB;QAC/F,KAAK,CAAC,OAAO,EAAE;YACX,iBAAiB;YACjB,YAAY;SACf,CAAC,CAAC;QAEH,gCAAgC;QAChC,kDAAkD;QAClD,gIAAgI;QAChI,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,uBAAuB,CAAC,SAAS,CAAC,CAAC;IACnE,CAAC;CACJ;AAZD,0DAYC"}
|
|
@@ -9,10 +9,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
9
9
|
exports.AuthenticatorFactory = void 0;
|
|
10
10
|
const tsyringe_1 = require("tsyringe");
|
|
11
11
|
const authenticator_instantiation_error_1 = require("../errors/authenticator-instantiation.error");
|
|
12
|
+
/**
|
|
13
|
+
* The AuthenticatorFactory returns the proper instantiated authenticator.
|
|
14
|
+
*/
|
|
12
15
|
let AuthenticatorFactory = class AuthenticatorFactory {
|
|
16
|
+
/**
|
|
17
|
+
* This function takes the authenticator context and returns the proper instantiated authenticator.
|
|
18
|
+
* It also validates that the authenticator is valid (it implements the AuthenticatorInterface).
|
|
19
|
+
* @param authenticatorContext The authenticator context that holds the authenticator and options to use.
|
|
20
|
+
* @param container The dependency container from which to retrieve the instantiated authenticator.
|
|
21
|
+
*/
|
|
13
22
|
fromContext(authenticatorContext, container) {
|
|
14
23
|
// Check if the guard needs to be instantiated
|
|
15
24
|
let instantiatedAuthenticator = authenticatorContext.authenticator;
|
|
25
|
+
// If authenticatorContext.authenticator is a function, we resolve that function through the container.
|
|
26
|
+
// TODO: validate if this is good.
|
|
16
27
|
if (typeof instantiatedAuthenticator === 'function') {
|
|
17
28
|
instantiatedAuthenticator = container.resolve(instantiatedAuthenticator);
|
|
18
29
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authenticator.factory.js","sourceRoot":"","sources":["../../../../src/factories/authenticator.factory.ts"],"names":[],"mappings":";;;;;;;;;AAAA,uCAAyD;AAGzD,mGAA4F;
|
|
1
|
+
{"version":3,"file":"authenticator.factory.js","sourceRoot":"","sources":["../../../../src/factories/authenticator.factory.ts"],"names":[],"mappings":";;;;;;;;;AAAA,uCAAyD;AAGzD,mGAA4F;AAE5F;;GAEG;AAEH,IAAa,oBAAoB,GAAjC,MAAa,oBAAoB;IAE7B;;;;;OAKG;IACH,WAAW,CAAC,oBAAmD,EAAE,SAA8B;QAC3F,8CAA8C;QAC9C,IAAI,yBAAyB,GAA2B,oBAAoB,CAAC,aAAuC,CAAC;QAErH,uGAAuG;QACvG,kCAAkC;QAClC,IAAI,OAAO,yBAAyB,KAAK,UAAU,EAAE;YACjD,yBAAyB,GAAG,SAAS,CAAC,OAAO,CAAC,yBAAyB,CAAC,CAAC;SAC5E;QAED,uDAAuD;QACvD,IAAI,OAAO,yBAAyB,CAAC,YAAY,KAAK,UAAU,EAAE;YAC9D,MAAM,IAAI,mEAA+B,CAAC,oGAAoG,EAAE,yBAAyB,EAAE,oBAAoB,CAAC,CAAC;SACpM;QAED,qDAAqD;QACrD,IAAI,OAAO,yBAAyB,CAAC,UAAU,KAAK,UAAU,EAAE;YAC5D,MAAM,IAAI,mEAA+B,CAAC,kGAAkG,EAAE,yBAAyB,EAAE,oBAAoB,CAAC,CAAC;SAClM;QAED,OAAO,yBAAyB,CAAC;IACrC,CAAC;CACJ,CAAA;AA9BY,oBAAoB;IADhC,qBAAU,EAAE;GACA,oBAAoB,CA8BhC;AA9BY,oDAAoB"}
|
|
@@ -9,10 +9,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
9
9
|
exports.GuardFactory = void 0;
|
|
10
10
|
const tsyringe_1 = require("tsyringe");
|
|
11
11
|
const guard_instantiation_error_1 = require("../errors/guard-instantiation.error");
|
|
12
|
+
/**
|
|
13
|
+
* The GuardFactory returns the proper instantiated guard.
|
|
14
|
+
*/
|
|
12
15
|
let GuardFactory = class GuardFactory {
|
|
16
|
+
/**
|
|
17
|
+
* This function takes the guard context and returns the proper instantiated guard.
|
|
18
|
+
* It also validates that the guard is valid (it implements the GuardInterface).
|
|
19
|
+
* @param guardContext The guard context that contains the guard and the options to use.
|
|
20
|
+
* @param container The dependency container from which to retrieve the instantiated guard.
|
|
21
|
+
*/
|
|
13
22
|
fromContext(guardContext, container) {
|
|
14
23
|
// Check if the guard needs to be instantiated
|
|
15
24
|
let instantiatedGuard = guardContext.guard;
|
|
25
|
+
// If guardContext.guard is a function, we resolve that function through the container.
|
|
26
|
+
// TODO: validate if this is good.
|
|
16
27
|
if (typeof instantiatedGuard === 'function') {
|
|
17
28
|
instantiatedGuard = container.resolve(instantiatedGuard);
|
|
18
29
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guard.factory.js","sourceRoot":"","sources":["../../../../src/factories/guard.factory.ts"],"names":[],"mappings":";;;;;;;;;AAAA,uCAAyD;
|
|
1
|
+
{"version":3,"file":"guard.factory.js","sourceRoot":"","sources":["../../../../src/factories/guard.factory.ts"],"names":[],"mappings":";;;;;;;;;AAAA,uCAAyD;AAGzD,mFAA4E;AAE5E;;GAEG;AAEH,IAAa,YAAY,GAAzB,MAAa,YAAY;IAErB;;;;;OAKG;IACH,WAAW,CAAC,YAAmC,EAAE,SAA8B;QAC3E,8CAA8C;QAC9C,IAAI,iBAAiB,GAAmB,YAAY,CAAC,KAAuB,CAAC;QAE7E,wFAAwF;QACxF,kCAAkC;QAClC,IAAI,OAAO,iBAAiB,KAAK,UAAU,EAAE;YACzC,iBAAiB,GAAG,SAAS,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;SAC5D;QAED,uDAAuD;QACvD,IAAI,OAAO,iBAAiB,CAAC,YAAY,KAAK,UAAU,EAAE;YACtD,MAAM,IAAI,mDAAuB,CAAC,wDAAwD,EAAE,iBAAiB,EAAE,YAAY,CAAC,CAAC;SAChI;QAED,qDAAqD;QACrD,IAAI,OAAO,iBAAiB,CAAC,UAAU,KAAK,UAAU,EAAE;YACpD,MAAM,IAAI,mDAAuB,CAAC,sDAAsD,EAAE,iBAAiB,EAAE,YAAY,CAAC,CAAC;SAC9H;QAED,OAAO,iBAAiB,CAAC;IAC7B,CAAC;CACJ,CAAA;AA9BY,YAAY;IADxB,qBAAU,EAAE;GACA,YAAY,CA8BxB;AA9BY,oCAAY"}
|
|
@@ -23,33 +23,59 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
23
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
24
|
exports.RoleGuard = void 0;
|
|
25
25
|
const tsyringe_1 = require("tsyringe");
|
|
26
|
+
/**
|
|
27
|
+
* The role guard is a guard that validates if the identity making the request has the required roles.
|
|
28
|
+
*/
|
|
26
29
|
let RoleGuard = class RoleGuard {
|
|
30
|
+
/**
|
|
31
|
+
* The role guard is a guard that validates if the identity making the request has the required roles.
|
|
32
|
+
* @param rolesClaimKey The key in the claims of the access token where the roles are defined.
|
|
33
|
+
*/
|
|
27
34
|
constructor(rolesClaimKey) {
|
|
28
35
|
this.rolesClaimKey = rolesClaimKey;
|
|
36
|
+
/**
|
|
37
|
+
* The keyname of the guard.
|
|
38
|
+
*/
|
|
29
39
|
this.keyname = "role";
|
|
30
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* Sets the context for the guard.
|
|
43
|
+
* @param context The context for the guard to use.
|
|
44
|
+
*/
|
|
31
45
|
setContext(context) {
|
|
32
46
|
this.guardContext = context;
|
|
33
47
|
return Promise.resolve();
|
|
34
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* Returns whether or not the guard authorizes the request.
|
|
51
|
+
* For the role guard, it validates that the identity making the request has the requested roles.
|
|
52
|
+
* The identity needs all of the requested roles to be authorized.
|
|
53
|
+
* @param request The request to authorize.
|
|
54
|
+
* @param identity The identity making the request.
|
|
55
|
+
*/
|
|
35
56
|
isAuthorized(request, identity) {
|
|
36
57
|
var _a;
|
|
37
58
|
return __awaiter(this, void 0, void 0, function* () {
|
|
38
59
|
const neededRoles = [];
|
|
60
|
+
// If we have no context we deny.
|
|
39
61
|
if (this.guardContext === undefined) {
|
|
40
62
|
return false;
|
|
41
63
|
}
|
|
64
|
+
// Find what roles are needed based on the context.
|
|
42
65
|
if (this.guardContext.options && this.guardContext.options.hasOwnProperty("roles") && Array.isArray(this.guardContext.options.roles)) {
|
|
43
66
|
neededRoles.push(...this.guardContext.options.roles);
|
|
44
67
|
}
|
|
68
|
+
// If the identity does not have a roles claim, we deny.
|
|
45
69
|
if (neededRoles.length > 0 && (((_a = identity === null || identity === void 0 ? void 0 : identity.claims) === null || _a === void 0 ? void 0 : _a.hasOwnProperty(this.rolesClaimKey)) === false || !Array.isArray(identity === null || identity === void 0 ? void 0 : identity.claims[this.rolesClaimKey]))) {
|
|
46
70
|
return false;
|
|
47
71
|
}
|
|
72
|
+
// If the identity is missing one of the needed roles, we deny.
|
|
48
73
|
for (const role of neededRoles) {
|
|
49
74
|
if (!(identity === null || identity === void 0 ? void 0 : identity.claims[this.rolesClaimKey].includes(role))) {
|
|
50
75
|
return false;
|
|
51
76
|
}
|
|
52
77
|
}
|
|
78
|
+
// If the identity has all the requested roles we authorize.
|
|
53
79
|
return true;
|
|
54
80
|
});
|
|
55
81
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"role.guard.js","sourceRoot":"","sources":["../../../../src/guards/role.guard.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAA4C;
|
|
1
|
+
{"version":3,"file":"role.guard.js","sourceRoot":"","sources":["../../../../src/guards/role.guard.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAA4C;AAM5C;;GAEG;AAEH,IAAa,SAAS,GAAtB,MAAa,SAAS;IAWlB;;;OAGG;IACH,YAA0E,aAAqB;QAArB,kBAAa,GAAb,aAAa,CAAQ;QAd/F;;WAEG;QACI,YAAO,GAAG,MAAM,CAAC;IAYxB,CAAC;IAED;;;OAGG;IACH,UAAU,CAAC,OAAY;QACnB,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC;QAE5B,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC7B,CAAC;IAED;;;;;;OAMG;IACG,YAAY,CAAC,OAAgB,EAAE,QAA4B;;;YAC7D,MAAM,WAAW,GAAa,EAAE,CAAC;YAEjC,iCAAiC;YACjC,IAAG,IAAI,CAAC,YAAY,KAAK,SAAS,EAAE;gBAChC,OAAO,KAAK,CAAC;aAChB;YAED,mDAAmD;YACnD,IAAG,IAAI,CAAC,YAAY,CAAC,OAAO,IAAI,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,KAAK,CAAC,EAAC;gBAChI,WAAW,CAAC,IAAI,CAAC,GAAI,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;aACzD;YAED,wDAAwD;YACxD,IAAG,WAAW,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,CAAA,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,MAAM,0CAAE,cAAc,CAAC,IAAI,CAAC,aAAa,CAAC,MAAK,KAAK,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,EAAC;gBAClJ,OAAO,KAAK,CAAC;aAChB;YAED,+DAA+D;YAC/D,KAAI,MAAM,IAAI,IAAI,WAAW,EAAE;gBAC3B,IAAG,CAAC,CAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,MAAM,CAAC,IAAI,CAAC,aAAa,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAA,EAAC;oBACpD,OAAO,KAAK,CAAC;iBAChB;aACJ;YAED,4DAA4D;YAC5D,OAAO,IAAI,CAAC;;KACf;CACJ,CAAA;AA/DY,SAAS;IADrB,qBAAU,EAAE;IAgBI,WAAA,iBAAM,CAAC,mCAAmC,CAAC,CAAA;;GAf/C,SAAS,CA+DrB;AA/DY,8BAAS"}
|
|
@@ -12,8 +12,10 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
__exportStar(require("./authentication-manager.interface"), exports);
|
|
14
14
|
__exportStar(require("./authenticator.interface"), exports);
|
|
15
|
+
__exportStar(require("./authenticator-context.interface"), exports);
|
|
15
16
|
__exportStar(require("./authorizer-manager.interface"), exports);
|
|
16
17
|
__exportStar(require("./guard.interface"), exports);
|
|
17
18
|
__exportStar(require("./guard-context.interface"), exports);
|
|
19
|
+
__exportStar(require("./identity-provider.interface"), exports);
|
|
18
20
|
__exportStar(require("./voter.interface"), exports);
|
|
19
21
|
//# sourceMappingURL=interfaces.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../../src/interfaces/interfaces.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qEAAmD;AACnD,4DAA0C;AAC1C,iEAA+C;AAC/C,oDAAkC;AAClC,4DAA0C;AAC1C,oDAAkC"}
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../../src/interfaces/interfaces.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qEAAmD;AACnD,4DAA0C;AAC1C,oEAAkD;AAClD,iEAA+C;AAC/C,oDAAkC;AAClC,4DAA0C;AAC1C,gEAA8C;AAC9C,oDAAkC"}
|
|
@@ -26,12 +26,28 @@ const tsyringe_1 = require("tsyringe");
|
|
|
26
26
|
const common_1 = require("@pristine-ts/common");
|
|
27
27
|
const authenticator_factory_1 = require("../factories/authenticator.factory");
|
|
28
28
|
const security_module_keyname_1 = require("../security.module.keyname");
|
|
29
|
+
/**
|
|
30
|
+
* The authentication manager provides authentication by returning the identity executing the action.
|
|
31
|
+
* It is tagged and can be injected using AuthenticationManagerInterface which facilitates mocking.
|
|
32
|
+
*/
|
|
29
33
|
let AuthenticationManager = class AuthenticationManager {
|
|
34
|
+
/**
|
|
35
|
+
* The authentication manager provides authentication by returning the identity executing the action.
|
|
36
|
+
* @param identityProviders The identity providers to use to provide the identity. All services tagged with ServiceDefinitionTagEnum.IdentityProvider will be injected here.
|
|
37
|
+
* @param logHandler The log handler to output logs.
|
|
38
|
+
* @param authenticatorFactory The factory to create the authenticator.
|
|
39
|
+
*/
|
|
30
40
|
constructor(identityProviders, logHandler, authenticatorFactory) {
|
|
31
41
|
this.identityProviders = identityProviders;
|
|
32
42
|
this.logHandler = logHandler;
|
|
33
43
|
this.authenticatorFactory = authenticatorFactory;
|
|
34
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* Authenticates a request by providing the identity that made the request.
|
|
47
|
+
* @param request The request to authenticate
|
|
48
|
+
* @param routeContext The context associated with the route.
|
|
49
|
+
* @param container The dependency container from which to resolve the authenticator.
|
|
50
|
+
*/
|
|
35
51
|
authenticate(request, routeContext, container) {
|
|
36
52
|
return __awaiter(this, void 0, void 0, function* () {
|
|
37
53
|
if (!routeContext || routeContext.authenticator === undefined) {
|
|
@@ -53,7 +69,6 @@ let AuthenticationManager = class AuthenticationManager {
|
|
|
53
69
|
}
|
|
54
70
|
catch (e) {
|
|
55
71
|
this.logHandler.error(e.message, { e }, security_module_keyname_1.SecurityModuleKeyname);
|
|
56
|
-
identity = undefined;
|
|
57
72
|
throw e;
|
|
58
73
|
}
|
|
59
74
|
return identity;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authentication.manager.js","sourceRoot":"","sources":["../../../../src/managers/authentication.manager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAA4E;AAE5E,gDAAmG;AAInG,8EAAwE;AACxE,wEAAiE;
|
|
1
|
+
{"version":3,"file":"authentication.manager.js","sourceRoot":"","sources":["../../../../src/managers/authentication.manager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAA4E;AAE5E,gDAAmG;AAInG,8EAAwE;AACxE,wEAAiE;AAIjE;;;GAGG;AAIH,IAAa,qBAAqB,GAAlC,MAAa,qBAAqB;IAE9B;;;;;OAKG;IACH,YAC2E,iBAA8C,EACrE,UAA+B,EAC/C,oBAA0C;QAFH,sBAAiB,GAAjB,iBAAiB,CAA6B;QACrE,eAAU,GAAV,UAAU,CAAqB;QAC/C,yBAAoB,GAApB,oBAAoB,CAAsB;IAC9E,CAAC;IAED;;;;;OAKG;IACU,YAAY,CAAC,OAAgB,EAAE,YAAiB,EAAE,SAA8B;;YACzF,IAAG,CAAC,YAAY,IAAI,YAAY,CAAC,aAAa,KAAK,SAAS,EAAE;gBAC1D,OAAO,SAAS,CAAC;aACpB;YAED,IAAI,QAAuC,CAAC;YAE5C,MAAM,oBAAoB,GAAkC,YAAY,CAAC,aAAa,CAAC;YAEvF,IAAI;gBACA,MAAM,yBAAyB,GAA2B,IAAI,CAAC,oBAAoB,CAAC,WAAW,CAAC,oBAAoB,EAAE,SAAS,CAAC,CAAC;gBAEjI,MAAM,yBAAyB,CAAC,UAAU,CAAC,oBAAoB,CAAC,CAAC;gBAEjE,QAAQ,GAAG,MAAM,yBAAyB,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;gBAEjE,IAAG,QAAQ,IAAI,SAAS,EAAE;oBACtB,OAAO,QAAQ,CAAC;iBACnB;gBAED,mCAAmC;gBACnC,KAAK,MAAM,gBAAgB,IAAI,IAAI,CAAC,iBAAiB,EAAE;oBACnD,QAAQ,GAAG,MAAM,gBAAgB,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;iBACvD;aAEJ;YAAC,OAAO,CAAC,EAAE;gBACR,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,EAAE,EAAC,CAAC,EAAC,EAAE,+CAAqB,CAAC,CAAC;gBAC7D,MAAM,CAAC,CAAC;aACX;YAED,OAAO,QAAQ,CAAC;QACpB,CAAC;KAAA;CACJ,CAAA;AApDY,qBAAqB;IAHjC,qBAAY,CAAC,+CAAqB,CAAC;IACnC,YAAG,CAAC,gCAAgC,CAAC;IACrC,qBAAU,EAAE;IAUJ,WAAA,oBAAS,CAAC,iCAAwB,CAAC,gBAAgB,CAAC,CAAA;IACpD,WAAA,iBAAM,CAAC,qBAAqB,CAAC,CAAA;oDACwB,4CAAoB;GAXrE,qBAAqB,CAoDjC;AApDY,sDAAqB"}
|
|
@@ -26,11 +26,27 @@ const tsyringe_1 = require("tsyringe");
|
|
|
26
26
|
const common_1 = require("@pristine-ts/common");
|
|
27
27
|
const guard_factory_1 = require("../factories/guard.factory");
|
|
28
28
|
const security_module_keyname_1 = require("../security.module.keyname");
|
|
29
|
+
/**
|
|
30
|
+
* The authorizer manager provides authorization by authorizing the action.
|
|
31
|
+
* It is tagged and can be injected using AuthorizerManagerInterface which facilitates mocking.
|
|
32
|
+
*/
|
|
29
33
|
let AuthorizerManager = class AuthorizerManager {
|
|
34
|
+
/**
|
|
35
|
+
* The authorizer manager provides authorization by authorizing the action.
|
|
36
|
+
* @param logHandler The log handler to output logs.
|
|
37
|
+
* @param guardFactory The factory to create the guard.
|
|
38
|
+
*/
|
|
30
39
|
constructor(logHandler, guardFactory) {
|
|
31
40
|
this.logHandler = logHandler;
|
|
32
41
|
this.guardFactory = guardFactory;
|
|
33
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Returns whether or not the request is authorized to access the route.
|
|
45
|
+
* @param request The request to authorize.
|
|
46
|
+
* @param routeContext The route context.
|
|
47
|
+
* @param container The dependency container to resolve the guard from.
|
|
48
|
+
* @param identity The identity making the request.
|
|
49
|
+
*/
|
|
34
50
|
isAuthorized(request, routeContext, container, identity) {
|
|
35
51
|
return __awaiter(this, void 0, void 0, function* () {
|
|
36
52
|
// If there are no guards defined, we simply return that it is authorized.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authorizer.manager.js","sourceRoot":"","sources":["../../../../src/managers/authorizer.manager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAiE;AAEjE,gDAAyE;AAEzE,8DAAwD;AACxD,wEAAiE;
|
|
1
|
+
{"version":3,"file":"authorizer.manager.js","sourceRoot":"","sources":["../../../../src/managers/authorizer.manager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAiE;AAEjE,gDAAyE;AAEzE,8DAAwD;AACxD,wEAAiE;AAGjE;;;GAGG;AAIH,IAAa,iBAAiB,GAA9B,MAAa,iBAAiB;IAE1B;;;;OAIG;IACH,YAAmE,UAA+B,EAC9D,YAA0B;QADK,eAAU,GAAV,UAAU,CAAqB;QAC9D,iBAAY,GAAZ,YAAY,CAAc;IAC9D,CAAC;IAED;;;;;;OAMG;IACU,YAAY,CAAC,OAAgB,EAAE,YAAiB,EAAE,SAA8B,EAAE,QAA4B;;YACvH,0EAA0E;YAC1E,IAAG,CAAC,YAAY,IAAI,YAAY,CAAC,MAAM,KAAK,SAAS,IAAI,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,KAAK,KAAK,EAAE;gBACnG,OAAO,IAAI,CAAC;aACf;YAED,IAAI,YAAY,GAAG,IAAI,CAAC;YAExB,KAAK,MAAM,YAAY,IAAI,YAAY,CAAC,MAAM,EAAE;gBAC5C,IAAI;oBACA,MAAM,iBAAiB,GAAG,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC;oBAEjF,MAAM,iBAAiB,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;oBAEjD,MAAM,YAAY,GAAE,MAAM,iBAAiB,CAAC,YAAY,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;oBAC5E,YAAY,GAAG,YAAY,IAAI,YAAY,CAAC;iBAC/C;gBACD,OAAO,CAAC,EAAE;oBACN,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,EAAE,+CAAqB,CAAC,CAAC;oBACxD,YAAY,GAAG,KAAK,CAAC;iBACxB;aACJ;YAED,OAAO,YAAY,CAAC;QACxB,CAAC;KAAA;CACJ,CAAA;AA3CY,iBAAiB;IAH7B,qBAAY,CAAC,+CAAqB,CAAC;IACnC,YAAG,CAAC,4BAA4B,CAAC;IACjC,qBAAU,EAAE;IAQW,WAAA,iBAAM,CAAC,qBAAqB,CAAC,CAAA;6CACC,4BAAY;GARrD,iBAAiB,CA2C7B;AA3CY,8CAAiB"}
|
|
@@ -10,7 +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("./authorizer.manager"), exports);
|
|
14
13
|
__exportStar(require("./authentication.manager"), exports);
|
|
14
|
+
__exportStar(require("./authorizer.manager"), exports);
|
|
15
15
|
__exportStar(require("./permission.manager"), exports);
|
|
16
16
|
//# sourceMappingURL=managers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"managers.js","sourceRoot":"","sources":["../../../../src/managers/managers.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"managers.js","sourceRoot":"","sources":["../../../../src/managers/managers.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2DAAyC;AACzC,uDAAqC;AACrC,uDAAqC"}
|
|
@@ -27,11 +27,27 @@ const voting_strategy_enum_1 = require("../enums/voting-strategy.enum");
|
|
|
27
27
|
const vote_enum_1 = require("../enums/vote.enum");
|
|
28
28
|
const common_1 = require("@pristine-ts/common");
|
|
29
29
|
const security_module_keyname_1 = require("../security.module.keyname");
|
|
30
|
+
/**
|
|
31
|
+
* The permission manager verifies if the correct permission are there to access and take an action on a resource.
|
|
32
|
+
*/
|
|
30
33
|
let PermissionManager = class PermissionManager {
|
|
34
|
+
/**
|
|
35
|
+
* The permission manager verifies if the correct permission are there to access and take an action on a resource.
|
|
36
|
+
* @param voters The voters that determine if access is granted.
|
|
37
|
+
* All services with the tag ServiceDefinitionTagEnum.Voter will be injected here
|
|
38
|
+
* @param logHandler The log handler to output logs.
|
|
39
|
+
*/
|
|
31
40
|
constructor(voters, logHandler) {
|
|
32
41
|
this.voters = voters;
|
|
33
42
|
this.logHandler = logHandler;
|
|
34
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* Returns whether or not the permission manager grants access to the resource.
|
|
46
|
+
* @param identity The identity trying to have access to a resource.
|
|
47
|
+
* @param action The action trying to be executed on the resource.
|
|
48
|
+
* @param resource The resource being accessed.
|
|
49
|
+
* @param votingStrategy The voting strategy that defines how to merge the votes. Default is DenyOnUnanimousAbstention.
|
|
50
|
+
*/
|
|
35
51
|
hasAccessToResource(identity, action, resource, votingStrategy = voting_strategy_enum_1.VotingStrategyEnum.DenyOnUnanimousAbstention) {
|
|
36
52
|
return __awaiter(this, void 0, void 0, function* () {
|
|
37
53
|
if (this.voters.length === 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"permission.manager.js","sourceRoot":"","sources":["../../../../src/managers/permission.manager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAuD;AAEvD,wEAAiE;AAEjE,kDAA4C;AAC5C,gDAAgF;AAChF,wEAAiE;
|
|
1
|
+
{"version":3,"file":"permission.manager.js","sourceRoot":"","sources":["../../../../src/managers/permission.manager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAuD;AAEvD,wEAAiE;AAEjE,kDAA4C;AAC5C,gDAAgF;AAChF,wEAAiE;AAEjE;;GAEG;AAEH,IAAa,iBAAiB,GAA9B,MAAa,iBAAiB;IAE1B;;;;;OAKG;IACH,YAA+E,MAAwB,EACpC,UAA+B;QADnB,WAAM,GAAN,MAAM,CAAkB;QACpC,eAAU,GAAV,UAAU,CAAqB;IAClG,CAAC;IAED;;;;;;OAMG;IACG,mBAAmB,CAAC,QAA2B,EAAE,MAAc,EAAE,QAAgB,EAAE,iBAAqC,yCAAkB,CAAC,yBAAyB;;YAEtK,IAAG,IAAI,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,EAAC;gBACxB,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,4CAA4C,EAAE;oBAClE,QAAQ;oBACR,MAAM;oBACN,QAAQ;iBACX,EAAE,+CAAqB,CAAC,CAAC;aAC7B;YAED,MAAM,KAAK,GAAe,EAAE,CAAC;YAE7B,KAAI,MAAM,KAAK,IAAI,IAAI,CAAC,MAAM,EAAE;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,CAAC,EAAC;oBACtE,iBAAiB,GAAG,KAAK,CAAC;iBAC7B;aACJ;YAED,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,uBAAuB,GAAG,CAAC,iBAAiB,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,eAAe,GAAG,QAAQ,CAAC,WAAW,CAAC,IAAI,EAAE,EAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAC,EAAE,+CAAqB,CAAC,CAAC;YAE9L,OAAO,iBAAiB,CAAC;QAC7B,CAAC;KAAA;CACJ,CAAA;AA7DY,iBAAiB;IAD7B,qBAAU,EAAE;IASW,WAAA,oBAAS,CAAC,iCAAwB,CAAC,KAAK,CAAC,CAAA;IACzC,WAAA,iBAAM,CAAC,qBAAqB,CAAC,CAAA;;GATxC,iBAAiB,CA6D7B;AA7DY,8CAAiB"}
|
|
@@ -11,7 +11,9 @@ const common_1 = require("@pristine-ts/common");
|
|
|
11
11
|
const security_module_keyname_1 = require("../security.module.keyname");
|
|
12
12
|
const tsyringe_1 = require("tsyringe");
|
|
13
13
|
/**
|
|
14
|
+
* This default identity provider is here so that there is always at least one service tagged with IdentityProvider
|
|
14
15
|
* Until there's a fix for: https://github.com/microsoft/tsyringe/issues/63
|
|
16
|
+
* It resolves the same identity it is passed.
|
|
15
17
|
*/
|
|
16
18
|
let DefaultIdentityProvider = class DefaultIdentityProvider {
|
|
17
19
|
provide(identity) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default-identity.provider.js","sourceRoot":"","sources":["../../../../src/providers/default-identity.provider.ts"],"names":[],"mappings":";;;;;;;;;AAAA,gDAAmG;AACnG,wEAAiE;AACjE,uCAAoC;AAGpC
|
|
1
|
+
{"version":3,"file":"default-identity.provider.js","sourceRoot":"","sources":["../../../../src/providers/default-identity.provider.ts"],"names":[],"mappings":";;;;;;;;;AAAA,gDAAmG;AACnG,wEAAiE;AACjE,uCAAoC;AAGpC;;;;GAIG;AAIH,IAAa,uBAAuB,GAApC,MAAa,uBAAuB;IAChC,OAAO,CAAC,QAA2B;QAC/B,OAAO,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACrC,CAAC;CACJ,CAAA;AAJY,uBAAuB;IAHnC,qBAAU,EAAE;IACZ,YAAG,CAAC,iCAAwB,CAAC,gBAAgB,CAAC;IAC9C,qBAAY,CAAC,+CAAqB,CAAC;GACvB,uBAAuB,CAInC;AAJY,0DAAuB"}
|
|
@@ -30,6 +30,9 @@ exports.SecurityModule = {
|
|
|
30
30
|
],
|
|
31
31
|
providerRegistrations: [],
|
|
32
32
|
configurationDefinitions: [
|
|
33
|
+
/**
|
|
34
|
+
* The key in the claims of the access token where the roles are defined.
|
|
35
|
+
*/
|
|
33
36
|
{
|
|
34
37
|
parameterName: security_module_keyname_1.SecurityModuleKeyname + ".rolesClaimKey",
|
|
35
38
|
isRequired: false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"security.module.js","sourceRoot":"","sources":["../../../src/security.module.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA,uEAAgE;AAChE,kDAAmD;AACnD,8DAAuE;AAEvE,0DAAwC;AACxC,gDAA8B;AAC9B,kDAAgC;AAChC,wDAAsC;AACtC,kDAAgC;AAChC,0DAAwC;AACxC,sDAAoC;AACpC,wDAAsC;AACtC,4DAA0C;AAE7B,QAAA,cAAc,GAAoB;IAC3C,OAAO,EAAE,+CAAqB;IAC9B,aAAa,EAAE;QACX,uBAAa;KAChB;IACD,qBAAqB,EAAE,EAAE;IACzB,wBAAwB,EAAE;QACtB;YACI,aAAa,EAAE,+CAAqB,GAAG,gBAAgB;YACvD,UAAU,EAAE,KAAK;YACjB,YAAY,EAAE,OAAO;YACrB,gBAAgB,EAAE;gBACd,IAAI,2CAA2B,CAAC,mCAAmC,CAAC;aACvE;SACJ;KACJ;CAEJ,CAAA"}
|
|
1
|
+
{"version":3,"file":"security.module.js","sourceRoot":"","sources":["../../../src/security.module.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA,uEAAgE;AAChE,kDAAmD;AACnD,8DAAuE;AAEvE,0DAAwC;AACxC,gDAA8B;AAC9B,kDAAgC;AAChC,wDAAsC;AACtC,kDAAgC;AAChC,0DAAwC;AACxC,sDAAoC;AACpC,wDAAsC;AACtC,4DAA0C;AAE7B,QAAA,cAAc,GAAoB;IAC3C,OAAO,EAAE,+CAAqB;IAC9B,aAAa,EAAE;QACX,uBAAa;KAChB;IACD,qBAAqB,EAAE,EAAE;IACzB,wBAAwB,EAAE;QACtB;;WAEG;QACH;YACI,aAAa,EAAE,+CAAqB,GAAG,gBAAgB;YACvD,UAAU,EAAE,KAAK;YACjB,YAAY,EAAE,OAAO;YACrB,gBAAgB,EAAE;gBACd,IAAI,2CAA2B,CAAC,mCAAmC,CAAC;aACvE;SACJ;KACJ;CAEJ,CAAA"}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import { AuthenticatorDecoratorError } from "../errors/authenticator-decorator.error";
|
|
2
|
+
/**
|
|
3
|
+
* This decorator specifies the authenticator that should be used to authenticate a request.
|
|
4
|
+
* It should be used either on a controller class or directly on a method.
|
|
5
|
+
* @param authenticator The authenticator to use.
|
|
6
|
+
* @param options Any options that will be passed on to the authenticator.
|
|
7
|
+
*/
|
|
2
8
|
export const authenticator = (authenticator, options) => {
|
|
3
9
|
return (target, propertyKey, descriptor) => {
|
|
4
10
|
// This is the condition to check that the authenticator is valid.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authenticator.decorator.js","sourceRoot":"","sources":["../../../../src/decorators/authenticator.decorator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"authenticator.decorator.js","sourceRoot":"","sources":["../../../../src/decorators/authenticator.decorator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,2BAA2B,EAAC,MAAM,yCAAyC,CAAC;AAEpF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,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GAAG,oBAAoB,CAAC;SAC9G;IACL,CAAC,CAAA;AACL,CAAC,CAAA"}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import { GuardDecoratorError } from "../errors/guard-decorator.error";
|
|
2
|
+
/**
|
|
3
|
+
* This decorator specifies the guard that should be used to authorize a request.
|
|
4
|
+
* It should be used either on a controller class or directly on a method.
|
|
5
|
+
* @param guard
|
|
6
|
+
* @param options Any options that will be passed on to the guard.
|
|
7
|
+
*/
|
|
2
8
|
export const guard = (guard, options) => {
|
|
3
9
|
return (target, propertyKey, descriptor) => {
|
|
4
10
|
// Validate the interface of the guard
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guard.decorator.js","sourceRoot":"","sources":["../../../../src/decorators/guard.decorator.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,mBAAmB,EAAC,MAAM,iCAAiC,CAAC;AAGpE,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,KAAgC,EAAE,OAAa,EAAE,EAAE;IACrE,OAAO,CAAE,MAAW,EACX,WAAoB,EACpB,UAA+B,EAAE,EAAE;QAExC,sCAAsC;QACtC,IAAI,CAAC,CAAC,KAAK,IAAI,CACX,CAAC,OAAO,KAAK,KAAK,UAAU,IAAI,OAAO,KAAK,CAAC,SAAS,CAAC,YAAY,KAAK,UAAU,CAAC;YACnF,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,CAAC,YAAY,KAAK,UAAU,CAAC,CAC1E,CAAC,EAAE;YACA,MAAM,IAAI,mBAAmB,CAAC,4FAA4F,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC;SAChL;QAED,+BAA+B;QAC/B,MAAM,YAAY,GAA2B;YACzC,eAAe,EAAG,KAAa,CAAC,SAAS,CAAC,WAAW,CAAC,IAAI;YAC1D,KAAK;YACL,OAAO;SACV,CAAC;QAEF,gFAAgF;QAChF,IAAG,UAAU,IAAI,WAAW,E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