@celljs/security 3.0.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/LICENSE +21 -0
- package/README.md +1 -0
- package/cell.yml +36 -0
- package/lib/browser/index.d.ts +2 -0
- package/lib/browser/index.d.ts.map +1 -0
- package/lib/browser/index.js +18 -0
- package/lib/browser/index.js.map +1 -0
- package/lib/browser/module.d.ts +4 -0
- package/lib/browser/module.d.ts.map +1 -0
- package/lib/browser/module.js +6 -0
- package/lib/browser/module.js.map +1 -0
- package/lib/browser/user/index.d.ts +3 -0
- package/lib/browser/user/index.d.ts.map +1 -0
- package/lib/browser/user/index.js +19 -0
- package/lib/browser/user/index.js.map +1 -0
- package/lib/browser/user/user-manager.d.ts +23 -0
- package/lib/browser/user/user-manager.d.ts.map +1 -0
- package/lib/browser/user/user-manager.js +125 -0
- package/lib/browser/user/user-manager.js.map +1 -0
- package/lib/browser/user/user-protocol.d.ts +10 -0
- package/lib/browser/user/user-protocol.d.ts.map +1 -0
- package/lib/browser/user/user-protocol.js +5 -0
- package/lib/browser/user/user-protocol.js.map +1 -0
- package/lib/common/index.d.ts +2 -0
- package/lib/common/index.d.ts.map +1 -0
- package/lib/common/index.js +18 -0
- package/lib/common/index.js.map +1 -0
- package/lib/common/security-protocol.d.ts +60 -0
- package/lib/common/security-protocol.d.ts.map +1 -0
- package/lib/common/security-protocol.js +33 -0
- package/lib/common/security-protocol.js.map +1 -0
- package/lib/node/access/access-decision-manager.d.ts +9 -0
- package/lib/node/access/access-decision-manager.d.ts.map +1 -0
- package/lib/node/access/access-decision-manager.js +56 -0
- package/lib/node/access/access-decision-manager.js.map +1 -0
- package/lib/node/access/access-decision-utils.d.ts +5 -0
- package/lib/node/access/access-decision-utils.d.ts.map +1 -0
- package/lib/node/access/access-decision-utils.js +23 -0
- package/lib/node/access/access-decision-utils.js.map +1 -0
- package/lib/node/access/access-decision-voter.d.ts +14 -0
- package/lib/node/access/access-decision-voter.d.ts.map +1 -0
- package/lib/node/access/access-decision-voter.js +86 -0
- package/lib/node/access/access-decision-voter.js.map +1 -0
- package/lib/node/access/access-protocol.d.ts +75 -0
- package/lib/node/access/access-protocol.d.ts.map +1 -0
- package/lib/node/access/access-protocol.js +20 -0
- package/lib/node/access/access-protocol.js.map +1 -0
- package/lib/node/access/action-name-resolver.d.ts +5 -0
- package/lib/node/access/action-name-resolver.d.ts.map +1 -0
- package/lib/node/access/action-name-resolver.js +30 -0
- package/lib/node/access/action-name-resolver.js.map +1 -0
- package/lib/node/access/index.d.ts +12 -0
- package/lib/node/access/index.d.ts.map +1 -0
- package/lib/node/access/index.js +28 -0
- package/lib/node/access/index.js.map +1 -0
- package/lib/node/access/jexl-engine-provider.d.ts +6 -0
- package/lib/node/access/jexl-engine-provider.d.ts.map +1 -0
- package/lib/node/access/jexl-engine-provider.js +25 -0
- package/lib/node/access/jexl-engine-provider.js.map +1 -0
- package/lib/node/access/method-advice.d.ts +17 -0
- package/lib/node/access/method-advice.d.ts.map +1 -0
- package/lib/node/access/method-advice.js +81 -0
- package/lib/node/access/method-advice.js.map +1 -0
- package/lib/node/access/policy-provider.d.ts +17 -0
- package/lib/node/access/policy-provider.d.ts.map +1 -0
- package/lib/node/access/policy-provider.js +84 -0
- package/lib/node/access/policy-provider.js.map +1 -0
- package/lib/node/access/policy-resolver.d.ts +15 -0
- package/lib/node/access/policy-resolver.d.ts.map +1 -0
- package/lib/node/access/policy-resolver.js +91 -0
- package/lib/node/access/policy-resolver.js.map +1 -0
- package/lib/node/access/resource-name-resolver.d.ts +7 -0
- package/lib/node/access/resource-name-resolver.d.ts.map +1 -0
- package/lib/node/access/resource-name-resolver.js +57 -0
- package/lib/node/access/resource-name-resolver.js.map +1 -0
- package/lib/node/access/security-metadata-source.d.ts +7 -0
- package/lib/node/access/security-metadata-source.d.ts.map +1 -0
- package/lib/node/access/security-metadata-source.js +58 -0
- package/lib/node/access/security-metadata-source.js.map +1 -0
- package/lib/node/annotation/action.d.ts +2 -0
- package/lib/node/annotation/action.d.ts.map +1 -0
- package/lib/node/annotation/action.js +11 -0
- package/lib/node/annotation/action.js.map +1 -0
- package/lib/node/annotation/anonymous.d.ts +2 -0
- package/lib/node/annotation/anonymous.d.ts.map +1 -0
- package/lib/node/annotation/anonymous.js +10 -0
- package/lib/node/annotation/anonymous.js.map +1 -0
- package/lib/node/annotation/authenticated.d.ts +2 -0
- package/lib/node/annotation/authenticated.d.ts.map +1 -0
- package/lib/node/annotation/authenticated.js +10 -0
- package/lib/node/annotation/authenticated.js.map +1 -0
- package/lib/node/annotation/authorize.d.ts +11 -0
- package/lib/node/annotation/authorize.d.ts.map +1 -0
- package/lib/node/annotation/authorize.js +40 -0
- package/lib/node/annotation/authorize.js.map +1 -0
- package/lib/node/annotation/index.d.ts +8 -0
- package/lib/node/annotation/index.d.ts.map +1 -0
- package/lib/node/annotation/index.js +24 -0
- package/lib/node/annotation/index.js.map +1 -0
- package/lib/node/annotation/post-authorize.d.ts +2 -0
- package/lib/node/annotation/post-authorize.d.ts.map +1 -0
- package/lib/node/annotation/post-authorize.js +10 -0
- package/lib/node/annotation/post-authorize.js.map +1 -0
- package/lib/node/annotation/pre-authorize.d.ts +2 -0
- package/lib/node/annotation/pre-authorize.d.ts.map +1 -0
- package/lib/node/annotation/pre-authorize.js +10 -0
- package/lib/node/annotation/pre-authorize.js.map +1 -0
- package/lib/node/annotation/resource.d.ts +2 -0
- package/lib/node/annotation/resource.d.ts.map +1 -0
- package/lib/node/annotation/resource.js +16 -0
- package/lib/node/annotation/resource.js.map +1 -0
- package/lib/node/authentication/authentication-manager.d.ts +10 -0
- package/lib/node/authentication/authentication-manager.d.ts.map +1 -0
- package/lib/node/authentication/authentication-manager.js +81 -0
- package/lib/node/authentication/authentication-manager.js.map +1 -0
- package/lib/node/authentication/authentication-middleware.d.ts +8 -0
- package/lib/node/authentication/authentication-middleware.d.ts.map +1 -0
- package/lib/node/authentication/authentication-middleware.js +36 -0
- package/lib/node/authentication/authentication-middleware.js.map +1 -0
- package/lib/node/authentication/authentication-protocol.d.ts +30 -0
- package/lib/node/authentication/authentication-protocol.d.ts.map +1 -0
- package/lib/node/authentication/authentication-protocol.js +12 -0
- package/lib/node/authentication/authentication-protocol.js.map +1 -0
- package/lib/node/authentication/authentication-provider.d.ts +33 -0
- package/lib/node/authentication/authentication-provider.d.ts.map +1 -0
- package/lib/node/authentication/authentication-provider.js +174 -0
- package/lib/node/authentication/authentication-provider.js.map +1 -0
- package/lib/node/authentication/authentication-success-handler.d.ts +16 -0
- package/lib/node/authentication/authentication-success-handler.d.ts.map +1 -0
- package/lib/node/authentication/authentication-success-handler.js +97 -0
- package/lib/node/authentication/authentication-success-handler.js.map +1 -0
- package/lib/node/authentication/index.d.ts +6 -0
- package/lib/node/authentication/index.d.ts.map +1 -0
- package/lib/node/authentication/index.js +22 -0
- package/lib/node/authentication/index.js.map +1 -0
- package/lib/node/cache/cache-protocol.d.ts +16 -0
- package/lib/node/cache/cache-protocol.d.ts.map +1 -0
- package/lib/node/cache/cache-protocol.js +6 -0
- package/lib/node/cache/cache-protocol.js.map +1 -0
- package/lib/node/cache/index.d.ts +3 -0
- package/lib/node/cache/index.d.ts.map +1 -0
- package/lib/node/cache/index.js +19 -0
- package/lib/node/cache/index.js.map +1 -0
- package/lib/node/cache/request-cache.d.ts +10 -0
- package/lib/node/cache/request-cache.d.ts.map +1 -0
- package/lib/node/cache/request-cache.js +52 -0
- package/lib/node/cache/request-cache.js.map +1 -0
- package/lib/node/constants.d.ts +6 -0
- package/lib/node/constants.d.ts.map +1 -0
- package/lib/node/constants.js +9 -0
- package/lib/node/constants.js.map +1 -0
- package/lib/node/context/context-protocol.d.ts +22 -0
- package/lib/node/context/context-protocol.d.ts.map +1 -0
- package/lib/node/context/context-protocol.js +30 -0
- package/lib/node/context/context-protocol.js.map +1 -0
- package/lib/node/context/index.d.ts +5 -0
- package/lib/node/context/index.d.ts.map +1 -0
- package/lib/node/context/index.js +21 -0
- package/lib/node/context/index.js.map +1 -0
- package/lib/node/context/security-context-middleware.d.ts +9 -0
- package/lib/node/context/security-context-middleware.d.ts.map +1 -0
- package/lib/node/context/security-context-middleware.js +44 -0
- package/lib/node/context/security-context-middleware.js.map +1 -0
- package/lib/node/context/security-context-store.d.ts +8 -0
- package/lib/node/context/security-context-store.d.ts.map +1 -0
- package/lib/node/context/security-context-store.js +40 -0
- package/lib/node/context/security-context-store.js.map +1 -0
- package/lib/node/context/security-context-strategy.d.ts +9 -0
- package/lib/node/context/security-context-strategy.d.ts.map +1 -0
- package/lib/node/context/security-context-strategy.js +32 -0
- package/lib/node/context/security-context-strategy.js.map +1 -0
- package/lib/node/crypto/index.d.ts +3 -0
- package/lib/node/crypto/index.d.ts.map +1 -0
- package/lib/node/crypto/index.js +19 -0
- package/lib/node/crypto/index.js.map +1 -0
- package/lib/node/crypto/keygen/base64-string-key-generator.d.ts +6 -0
- package/lib/node/crypto/keygen/base64-string-key-generator.d.ts.map +1 -0
- package/lib/node/crypto/keygen/base64-string-key-generator.js +30 -0
- package/lib/node/crypto/keygen/base64-string-key-generator.js.map +1 -0
- package/lib/node/crypto/keygen/index.d.ts +3 -0
- package/lib/node/crypto/keygen/index.d.ts.map +1 -0
- package/lib/node/crypto/keygen/index.js +19 -0
- package/lib/node/crypto/keygen/index.js.map +1 -0
- package/lib/node/crypto/keygen/keygen-protocol.d.ts +5 -0
- package/lib/node/crypto/keygen/keygen-protocol.d.ts.map +1 -0
- package/lib/node/crypto/keygen/keygen-protocol.js +5 -0
- package/lib/node/crypto/keygen/keygen-protocol.js.map +1 -0
- package/lib/node/crypto/password/index.d.ts +3 -0
- package/lib/node/crypto/password/index.d.ts.map +1 -0
- package/lib/node/crypto/password/index.js +19 -0
- package/lib/node/crypto/password/index.js.map +1 -0
- package/lib/node/crypto/password/password-encoder.d.ts +9 -0
- package/lib/node/crypto/password/password-encoder.d.ts.map +1 -0
- package/lib/node/crypto/password/password-encoder.js +51 -0
- package/lib/node/crypto/password/password-encoder.js.map +1 -0
- package/lib/node/crypto/password/password-protocol.d.ts +6 -0
- package/lib/node/crypto/password/password-protocol.d.ts.map +1 -0
- package/lib/node/crypto/password/password-protocol.js +5 -0
- package/lib/node/crypto/password/password-protocol.js.map +1 -0
- package/lib/node/error/error-handler.d.ts +19 -0
- package/lib/node/error/error-handler.d.ts.map +1 -0
- package/lib/node/error/error-handler.js +81 -0
- package/lib/node/error/error-handler.js.map +1 -0
- package/lib/node/error/error-protocol.d.ts +3 -0
- package/lib/node/error/error-protocol.d.ts.map +1 -0
- package/lib/node/error/error-protocol.js +7 -0
- package/lib/node/error/error-protocol.js.map +1 -0
- package/lib/node/error/error.d.ts +21 -0
- package/lib/node/error/error.d.ts.map +1 -0
- package/lib/node/error/error.js +35 -0
- package/lib/node/error/error.js.map +1 -0
- package/lib/node/error/index.d.ts +4 -0
- package/lib/node/error/index.d.ts.map +1 -0
- package/lib/node/error/index.js +20 -0
- package/lib/node/error/index.js.map +1 -0
- package/lib/node/index.d.ts +11 -0
- package/lib/node/index.d.ts.map +1 -0
- package/lib/node/index.js +27 -0
- package/lib/node/index.js.map +1 -0
- package/lib/node/logout/index.d.ts +5 -0
- package/lib/node/logout/index.d.ts.map +1 -0
- package/lib/node/logout/index.js +21 -0
- package/lib/node/logout/index.js.map +1 -0
- package/lib/node/logout/logout-handler.d.ts +5 -0
- package/lib/node/logout/logout-handler.d.ts.map +1 -0
- package/lib/node/logout/logout-handler.js +22 -0
- package/lib/node/logout/logout-handler.js.map +1 -0
- package/lib/node/logout/logout-middleware.d.ts +16 -0
- package/lib/node/logout/logout-middleware.d.ts.map +1 -0
- package/lib/node/logout/logout-middleware.js +66 -0
- package/lib/node/logout/logout-middleware.js.map +1 -0
- package/lib/node/logout/logout-protocol.d.ts +12 -0
- package/lib/node/logout/logout-protocol.d.ts.map +1 -0
- package/lib/node/logout/logout-protocol.js +9 -0
- package/lib/node/logout/logout-protocol.js.map +1 -0
- package/lib/node/logout/logout-success-handler-provider.d.ts +8 -0
- package/lib/node/logout/logout-success-handler-provider.d.ts.map +1 -0
- package/lib/node/logout/logout-success-handler-provider.js +35 -0
- package/lib/node/logout/logout-success-handler-provider.js.map +1 -0
- package/lib/node/logout/logout-success-handler.d.ts +9 -0
- package/lib/node/logout/logout-success-handler.d.ts.map +1 -0
- package/lib/node/logout/logout-success-handler.js +39 -0
- package/lib/node/logout/logout-success-handler.js.map +1 -0
- package/lib/node/module.d.ts +5 -0
- package/lib/node/module.d.ts.map +1 -0
- package/lib/node/module.js +7 -0
- package/lib/node/module.js.map +1 -0
- package/lib/node/user/index.d.ts +6 -0
- package/lib/node/user/index.d.ts.map +1 -0
- package/lib/node/user/index.js +22 -0
- package/lib/node/user/index.js.map +1 -0
- package/lib/node/user/user-checker.d.ts +8 -0
- package/lib/node/user/user-checker.d.ts.map +1 -0
- package/lib/node/user/user-checker.js +44 -0
- package/lib/node/user/user-checker.js.map +1 -0
- package/lib/node/user/user-mapper.d.ts +9 -0
- package/lib/node/user/user-mapper.d.ts.map +1 -0
- package/lib/node/user/user-mapper.js +40 -0
- package/lib/node/user/user-mapper.js.map +1 -0
- package/lib/node/user/user-middleware.d.ts +11 -0
- package/lib/node/user/user-middleware.d.ts.map +1 -0
- package/lib/node/user/user-middleware.js +55 -0
- package/lib/node/user/user-middleware.js.map +1 -0
- package/lib/node/user/user-protocol.d.ts +15 -0
- package/lib/node/user/user-protocol.d.ts.map +1 -0
- package/lib/node/user/user-protocol.js +9 -0
- package/lib/node/user/user-protocol.js.map +1 -0
- package/lib/node/user/user-service.d.ts +7 -0
- package/lib/node/user/user-service.d.ts.map +1 -0
- package/lib/node/user/user-service.js +42 -0
- package/lib/node/user/user-service.js.map +1 -0
- package/lib/package.spec.d.ts +1 -0
- package/lib/package.spec.d.ts.map +1 -0
- package/lib/package.spec.js +4 -0
- package/lib/package.spec.js.map +1 -0
- package/package.json +53 -0
- package/src/browser/index.ts +1 -0
- package/src/browser/module.ts +4 -0
- package/src/browser/user/index.ts +2 -0
- package/src/browser/user/user-manager.ts +103 -0
- package/src/browser/user/user-protocol.ts +11 -0
- package/src/common/index.ts +1 -0
- package/src/common/security-protocol.ts +65 -0
- package/src/node/access/access-decision-manager.ts +43 -0
- package/src/node/access/access-decision-utils.ts +18 -0
- package/src/node/access/access-decision-voter.ts +73 -0
- package/src/node/access/access-protocol.ts +93 -0
- package/src/node/access/action-name-resolver.ts +19 -0
- package/src/node/access/index.ts +11 -0
- package/src/node/access/jexl-engine-provider.ts +18 -0
- package/src/node/access/method-advice.ts +64 -0
- package/src/node/access/policy-provider.ts +64 -0
- package/src/node/access/policy-resolver.ts +79 -0
- package/src/node/access/resource-name-resolver.ts +41 -0
- package/src/node/access/security-metadata-source.ts +47 -0
- package/src/node/annotation/action.ts +8 -0
- package/src/node/annotation/anonymous.ts +6 -0
- package/src/node/annotation/authenticated.ts +6 -0
- package/src/node/annotation/authorize.ts +39 -0
- package/src/node/annotation/index.ts +7 -0
- package/src/node/annotation/post-authorize.ts +6 -0
- package/src/node/annotation/pre-authorize.ts +6 -0
- package/src/node/annotation/resource.ts +12 -0
- package/src/node/authentication/authentication-manager.ts +61 -0
- package/src/node/authentication/authentication-middleware.ts +21 -0
- package/src/node/authentication/authentication-protocol.ts +37 -0
- package/src/node/authentication/authentication-provider.ts +155 -0
- package/src/node/authentication/authentication-success-handler.ts +83 -0
- package/src/node/authentication/index.ts +5 -0
- package/src/node/cache/cache-protocol.ts +17 -0
- package/src/node/cache/index.ts +2 -0
- package/src/node/cache/request-cache.ts +38 -0
- package/src/node/constants.ts +5 -0
- package/src/node/context/context-protocol.ts +43 -0
- package/src/node/context/index.ts +4 -0
- package/src/node/context/security-context-middleware.ts +28 -0
- package/src/node/context/security-context-store.ts +25 -0
- package/src/node/context/security-context-strategy.ts +24 -0
- package/src/node/crypto/index.ts +2 -0
- package/src/node/crypto/keygen/base64-string-key-generator.ts +15 -0
- package/src/node/crypto/keygen/index.ts +2 -0
- package/src/node/crypto/keygen/keygen-protocol.ts +7 -0
- package/src/node/crypto/password/index.ts +2 -0
- package/src/node/crypto/password/password-encoder.ts +39 -0
- package/src/node/crypto/password/password-protocol.ts +6 -0
- package/src/node/error/error-handler.ts +58 -0
- package/src/node/error/error-protocol.ts +5 -0
- package/src/node/error/error.ts +41 -0
- package/src/node/error/index.ts +3 -0
- package/src/node/index.ts +10 -0
- package/src/node/logout/index.ts +4 -0
- package/src/node/logout/logout-handler.ts +12 -0
- package/src/node/logout/logout-middleware.ts +49 -0
- package/src/node/logout/logout-protocol.ts +17 -0
- package/src/node/logout/logout-success-handler-provider.ts +21 -0
- package/src/node/logout/logout-success-handler.ts +22 -0
- package/src/node/module.ts +5 -0
- package/src/node/user/index.ts +6 -0
- package/src/node/user/user-checker.ts +37 -0
- package/src/node/user/user-mapper.ts +26 -0
- package/src/node/user/user-middleware.ts +40 -0
- package/src/node/user/user-protocol.ts +20 -0
- package/src/node/user/user-service.ts +28 -0
- package/src/package.spec.ts +4 -0
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.AclPolicyResolver = exports.ElPolicyResolver = void 0;
|
|
13
|
+
const access_protocol_1 = require("./access-protocol");
|
|
14
|
+
const core_1 = require("@celljs/core");
|
|
15
|
+
const node_1 = require("@celljs/web/lib/node");
|
|
16
|
+
const common_1 = require("../../common");
|
|
17
|
+
const micromatch_1 = require("micromatch");
|
|
18
|
+
let ElPolicyResolver = class ElPolicyResolver {
|
|
19
|
+
async resolve(policy, securityMetadata) {
|
|
20
|
+
const expression = this.jexlEngineProvider.provide().createExpression(policy.el);
|
|
21
|
+
// eslint-disable-next-line no-eval
|
|
22
|
+
const result = await expression.eval(policy.context || node_1.Context.getAttr(access_protocol_1.SECURITY_EXPRESSION_CONTEXT_KEY));
|
|
23
|
+
if (result === true) {
|
|
24
|
+
return access_protocol_1.ACCESS_GRANTED;
|
|
25
|
+
}
|
|
26
|
+
;
|
|
27
|
+
return access_protocol_1.ACCESS_DENIED;
|
|
28
|
+
}
|
|
29
|
+
async support(policy, securityMetadata) {
|
|
30
|
+
return policy.type === common_1.PolicyType.el;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
__decorate([
|
|
34
|
+
(0, core_1.Autowired)(access_protocol_1.JexlEngineProvider),
|
|
35
|
+
__metadata("design:type", Object)
|
|
36
|
+
], ElPolicyResolver.prototype, "jexlEngineProvider", void 0);
|
|
37
|
+
ElPolicyResolver = __decorate([
|
|
38
|
+
(0, core_1.Component)(access_protocol_1.PolicyResolver)
|
|
39
|
+
], ElPolicyResolver);
|
|
40
|
+
exports.ElPolicyResolver = ElPolicyResolver;
|
|
41
|
+
let AclPolicyResolver = class AclPolicyResolver {
|
|
42
|
+
match(pattern, resource) {
|
|
43
|
+
return (0, micromatch_1.contains)(resource, pattern);
|
|
44
|
+
}
|
|
45
|
+
toArray(value) {
|
|
46
|
+
return Array.isArray(value) ? value : [value];
|
|
47
|
+
}
|
|
48
|
+
async resolve(policy, securityMetadata) {
|
|
49
|
+
const acl = policy;
|
|
50
|
+
let grant = 0;
|
|
51
|
+
for (const statement of acl.statement) {
|
|
52
|
+
const result = this.resolveStatement(statement, securityMetadata);
|
|
53
|
+
if (result === access_protocol_1.ACCESS_DENIED) {
|
|
54
|
+
return access_protocol_1.ACCESS_DENIED;
|
|
55
|
+
}
|
|
56
|
+
else if (result === access_protocol_1.ACCESS_GRANTED) {
|
|
57
|
+
grant++;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
if (grant > 0) {
|
|
61
|
+
return access_protocol_1.ACCESS_GRANTED;
|
|
62
|
+
}
|
|
63
|
+
return access_protocol_1.ACCESS_ABSTAIN;
|
|
64
|
+
}
|
|
65
|
+
resolveStatement(statement, securityMetadata) {
|
|
66
|
+
const resources = this.toArray(statement.resource);
|
|
67
|
+
for (const pattern of resources) {
|
|
68
|
+
if (this.match(pattern, securityMetadata.resource)) {
|
|
69
|
+
const actions = this.toArray(statement.action);
|
|
70
|
+
for (const actionPattern of actions) {
|
|
71
|
+
if (this.match(actionPattern, securityMetadata.action)) {
|
|
72
|
+
if (statement.effect === common_1.Effect.Allow) {
|
|
73
|
+
return access_protocol_1.ACCESS_GRANTED;
|
|
74
|
+
}
|
|
75
|
+
return access_protocol_1.ACCESS_DENIED;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return access_protocol_1.ACCESS_ABSTAIN;
|
|
82
|
+
}
|
|
83
|
+
async support(policy, securityMetadata) {
|
|
84
|
+
return policy.type === common_1.PolicyType.acl;
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
AclPolicyResolver = __decorate([
|
|
88
|
+
(0, core_1.Component)(access_protocol_1.PolicyResolver)
|
|
89
|
+
], AclPolicyResolver);
|
|
90
|
+
exports.AclPolicyResolver = AclPolicyResolver;
|
|
91
|
+
//# sourceMappingURL=policy-resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"policy-resolver.js","sourceRoot":"","sources":["../../../src/node/access/policy-resolver.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uDAAyK;AACzK,uCAAoD;AACpD,+CAA+C;AAC/C,yCAA0F;AAC1F,2CAAsC;AAG/B,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAKzB,KAAK,CAAC,OAAO,CAAC,MAAgB,EAAE,gBAAkC;QAC9D,MAAM,UAAU,GAAG,IAAI,CAAC,kBAAkB,CAAC,OAAO,EAAE,CAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QACjF,mCAAmC;QACnC,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,IAAI,cAAO,CAAC,OAAO,CAAC,iDAA+B,CAAC,CAAC,CAAC;QACzG,IAAI,MAAM,KAAK,IAAI,EAAE;YACjB,OAAO,gCAAc,CAAC;SACzB;QAAA,CAAC;QACF,OAAO,+BAAa,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,MAAc,EAAE,gBAAkC;QAC5D,OAAO,MAAM,CAAC,IAAI,KAAK,mBAAU,CAAC,EAAE,CAAC;IACzC,CAAC;CACJ,CAAA;AAhBG;IAAC,IAAA,gBAAS,EAAC,oCAAkB,CAAC;;4DACiC;AAHtD,gBAAgB;IAD5B,IAAA,gBAAS,EAAC,gCAAc,CAAC;GACb,gBAAgB,CAkB5B;AAlBY,4CAAgB;AAqBtB,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAEhB,KAAK,CAAC,OAAe,EAAE,QAAgB;QAC7C,OAAO,IAAA,qBAAQ,EAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IACvC,CAAC;IAES,OAAO,CAAC,KAAwB;QACtC,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IAElD,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,MAAiB,EAAE,gBAAkC;QAC/D,MAAM,GAAG,GAAG,MAAmB,CAAC;QAChC,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,KAAK,MAAM,SAAS,IAAI,GAAG,CAAC,SAAS,EAAE;YACnC,MAAM,MAAM,GAAG,IAAI,CAAC,gBAAgB,CAAC,SAAS,EAAE,gBAAgB,CAAC,CAAC;YAClE,IAAI,MAAM,KAAK,+BAAa,EAAE;gBAC1B,OAAO,+BAAa,CAAC;aACxB;iBAAM,IAAI,MAAM,KAAK,gCAAc,EAAE;gBAClC,KAAK,EAAE,CAAC;aACX;SACJ;QACD,IAAI,KAAK,GAAG,CAAC,EAAE;YACX,OAAO,gCAAc,CAAC;SACzB;QACD,OAAO,gCAAc,CAAC;IAC1B,CAAC;IAES,gBAAgB,CAAC,SAAoB,EAAE,gBAAkC;QAC/E,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;QACnD,KAAK,MAAM,OAAO,IAAI,SAAS,EAAE;YAC7B,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,gBAAgB,CAAC,QAAQ,CAAC,EAAE;gBAChD,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;gBAC/C,KAAK,MAAM,aAAa,IAAI,OAAO,EAAE;oBACjC,IAAI,IAAI,CAAC,KAAK,CAAC,aAAa,EAAE,gBAAgB,CAAC,MAAM,CAAC,EAAE;wBACpD,IAAI,SAAS,CAAC,MAAM,KAAK,eAAM,CAAC,KAAK,EAAE;4BACnC,OAAO,gCAAc,CAAC;yBACzB;wBACD,OAAO,+BAAa,CAAC;qBACxB;iBACJ;gBACD,MAAM;aACT;SACJ;QACD,OAAO,gCAAc,CAAC;IAC1B,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,MAAc,EAAE,gBAAkC;QAC5D,OAAO,MAAM,CAAC,IAAI,KAAK,mBAAU,CAAC,GAAG,CAAC;IAC1C,CAAC;CACJ,CAAA;AAlDY,iBAAiB;IAD7B,IAAA,gBAAS,EAAC,gCAAc,CAAC;GACb,iBAAiB,CAkD7B;AAlDY,8CAAiB"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { MethodSecurityMetadataContext, ResourceNameResolver } from './access-protocol';
|
|
2
|
+
export declare class DefaultResourceNameResolver implements ResourceNameResolver {
|
|
3
|
+
protected tenantEnabled: boolean;
|
|
4
|
+
resolve(ctx: MethodSecurityMetadataContext): Promise<string[]>;
|
|
5
|
+
protected appendTenantIfNeed(resources: string[]): Promise<string[]>;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=resource-name-resolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource-name-resolver.d.ts","sourceRoot":"","sources":["../../../src/node/access/resource-name-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAMxF,qBACa,2BAA4B,YAAW,oBAAoB;IAGpE,SAAS,CAAC,aAAa,EAAE,OAAO,CAAC;IAE3B,OAAO,CAAC,GAAG,EAAE,6BAA6B,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;cAqBpD,kBAAkB,CAAC,SAAS,EAAE,MAAM,EAAE;CAOzD"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.DefaultResourceNameResolver = void 0;
|
|
13
|
+
const access_protocol_1 = require("./access-protocol");
|
|
14
|
+
const core_1 = require("@celljs/core");
|
|
15
|
+
const constants_1 = require("../constants");
|
|
16
|
+
const jexl_1 = require("jexl");
|
|
17
|
+
const node_1 = require("@celljs/web/lib/node");
|
|
18
|
+
let DefaultResourceNameResolver = class DefaultResourceNameResolver {
|
|
19
|
+
async resolve(ctx) {
|
|
20
|
+
const classResources = (0, core_1.getOwnMetadata)(constants_1.METADATA_KEY.resource, ctx.target.constructor);
|
|
21
|
+
const methodResources = (0, core_1.getOwnMetadata)(constants_1.METADATA_KEY.resource, ctx.target.constructor, ctx.method);
|
|
22
|
+
let resources = [];
|
|
23
|
+
if (classResources.length && methodResources.length) {
|
|
24
|
+
for (const resource of methodResources) {
|
|
25
|
+
// eslint-disable-next-line no-eval
|
|
26
|
+
resources.push(`${classResources[0]}:${(0, jexl_1.evalSync)(resource === null || resource === void 0 ? void 0 : resource.toString(), ctx)}`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
else if (methodResources.length) {
|
|
30
|
+
// eslint-disable-next-line no-eval
|
|
31
|
+
resources = methodResources.map(r => { var _a; return (_a = (0, jexl_1.evalSync)(r === null || r === void 0 ? void 0 : r.toString(), ctx)) === null || _a === void 0 ? void 0 : _a.toString(); });
|
|
32
|
+
}
|
|
33
|
+
else if (classResources.length) {
|
|
34
|
+
resources = classResources;
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
resources = [ctx.target.constructor.name];
|
|
38
|
+
}
|
|
39
|
+
return this.appendTenantIfNeed(resources);
|
|
40
|
+
}
|
|
41
|
+
async appendTenantIfNeed(resources) {
|
|
42
|
+
if (this.tenantEnabled) {
|
|
43
|
+
const tenant = node_1.Context.getTenant();
|
|
44
|
+
return resources.map(r => `${tenant}:${r}`);
|
|
45
|
+
}
|
|
46
|
+
return resources;
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
__decorate([
|
|
50
|
+
(0, core_1.Value)(core_1.TENANT_ENABLED),
|
|
51
|
+
__metadata("design:type", Boolean)
|
|
52
|
+
], DefaultResourceNameResolver.prototype, "tenantEnabled", void 0);
|
|
53
|
+
DefaultResourceNameResolver = __decorate([
|
|
54
|
+
(0, core_1.Component)(access_protocol_1.ResourceNameResolver)
|
|
55
|
+
], DefaultResourceNameResolver);
|
|
56
|
+
exports.DefaultResourceNameResolver = DefaultResourceNameResolver;
|
|
57
|
+
//# sourceMappingURL=resource-name-resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource-name-resolver.js","sourceRoot":"","sources":["../../../src/node/access/resource-name-resolver.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uDAAwF;AACxF,uCAAgF;AAChF,4CAA4C;AAC5C,+BAAgC;AAChC,+CAA+C;AAGxC,IAAM,2BAA2B,GAAjC,MAAM,2BAA2B;IAKpC,KAAK,CAAC,OAAO,CAAC,GAAkC;QAC5C,MAAM,cAAc,GAAa,IAAA,qBAAc,EAAC,wBAAY,CAAC,QAAQ,EAAE,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QAC/F,MAAM,eAAe,GAAa,IAAA,qBAAc,EAAC,wBAAY,CAAC,QAAQ,EAAE,GAAG,CAAC,MAAM,CAAC,WAAW,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;QAC5G,IAAI,SAAS,GAAa,EAAE,CAAC;QAC7B,IAAI,cAAc,CAAC,MAAM,IAAI,eAAe,CAAC,MAAM,EAAE;YACjD,KAAK,MAAM,QAAQ,IAAI,eAAe,EAAE;gBACpC,mCAAmC;gBACnC,SAAS,CAAC,IAAI,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,IAAI,IAAA,eAAQ,EAAC,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,QAAQ,EAAE,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;aACjF;SACJ;aAAM,IAAI,eAAe,CAAC,MAAM,EAAE;YAC/B,mCAAmC;YACnC,SAAS,GAAG,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,WAAC,OAAA,MAAA,IAAA,eAAQ,EAAC,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,QAAQ,EAAE,EAAE,GAAG,CAAC,0CAAE,QAAQ,EAAE,CAAA,EAAA,CAAC,CAAC;SAClF;aAAM,IAAI,cAAc,CAAC,MAAM,EAAE;YAC9B,SAAS,GAAG,cAAc,CAAC;SAC9B;aAAM;YACH,SAAS,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;SAC7C;QAED,OAAO,IAAI,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC;IAC9C,CAAC;IAES,KAAK,CAAC,kBAAkB,CAAC,SAAmB;QAClD,IAAI,IAAI,CAAC,aAAa,EAAE;YACpB,MAAM,MAAM,GAAG,cAAO,CAAC,SAAS,EAAE,CAAC;YACnC,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,MAAM,IAAI,CAAC,EAAE,CAAC,CAAC;SAC/C;QACD,OAAO,SAAS,CAAC;IACrB,CAAC;CACJ,CAAA;AA/BG;IAAC,IAAA,YAAK,EAAC,qBAAc,CAAC;;kEACW;AAHxB,2BAA2B;IADvC,IAAA,gBAAS,EAAC,sCAAoB,CAAC;GACnB,2BAA2B,CAiCvC;AAjCY,kEAA2B"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { SecurityMetadataSource, SecurityMetadata, MethodSecurityMetadataContext, SecurityExpressionContextHandler, ActionNameResolver } from './access-protocol';
|
|
2
|
+
export declare class MethodSecurityMetadataSource implements SecurityMetadataSource {
|
|
3
|
+
protected readonly securityExpressionContextHandler: SecurityExpressionContextHandler;
|
|
4
|
+
protected readonly actionNameResolver: ActionNameResolver;
|
|
5
|
+
load(context: MethodSecurityMetadataContext): Promise<SecurityMetadata>;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=security-metadata-source.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"security-metadata-source.d.ts","sourceRoot":"","sources":["../../../src/node/access/security-metadata-source.ts"],"names":[],"mappings":"AACA,OAAO,EACH,sBAAsB,EAAE,gBAAgB,EAAE,6BAA6B,EACvE,gCAAgC,EAAmC,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAMrH,qBACa,4BAA6B,YAAW,sBAAsB;IAGvE,SAAS,CAAC,QAAQ,CAAC,gCAAgC,EAAE,gCAAgC,CAAC;IAGtF,SAAS,CAAC,QAAQ,CAAC,kBAAkB,EAAE,kBAAkB,CAAC;IAEpD,IAAI,CAAC,OAAO,EAAE,6BAA6B,GAAG,OAAO,CAAC,gBAAgB,CAAC;CA4BhF"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.MethodSecurityMetadataSource = void 0;
|
|
13
|
+
const core_1 = require("@celljs/core");
|
|
14
|
+
const access_protocol_1 = require("./access-protocol");
|
|
15
|
+
const context_1 = require("../context");
|
|
16
|
+
const constants_1 = require("../constants");
|
|
17
|
+
const node_1 = require("@celljs/web/lib/node");
|
|
18
|
+
let MethodSecurityMetadataSource = class MethodSecurityMetadataSource {
|
|
19
|
+
async load(context) {
|
|
20
|
+
const classPolicies = (0, core_1.getOwnMetadata)(constants_1.METADATA_KEY.authorize, context.target.constructor);
|
|
21
|
+
const methodPolicies = (0, core_1.getOwnMetadata)(constants_1.METADATA_KEY.authorize, context.target.constructor, context.method);
|
|
22
|
+
const ctx = Object.assign(Object.assign({}, context), context_1.SecurityContext.getAuthentication());
|
|
23
|
+
if (this.securityExpressionContextHandler) {
|
|
24
|
+
await this.securityExpressionContextHandler.handle(ctx);
|
|
25
|
+
}
|
|
26
|
+
node_1.Context.setAttr(access_protocol_1.SECURITY_EXPRESSION_CONTEXT_KEY, ctx);
|
|
27
|
+
const policies = classPolicies.concat(...methodPolicies)
|
|
28
|
+
.filter(item => item.authorizeType === context.authorizeType);
|
|
29
|
+
const action = await this.actionNameResolver.resolve(context);
|
|
30
|
+
return {
|
|
31
|
+
authorizeType: context.authorizeType,
|
|
32
|
+
principal: context_1.SecurityContext.getAuthentication().principal,
|
|
33
|
+
action,
|
|
34
|
+
resource: '',
|
|
35
|
+
policies: policies,
|
|
36
|
+
get grant() {
|
|
37
|
+
return ctx.grant;
|
|
38
|
+
},
|
|
39
|
+
set grant(grant) {
|
|
40
|
+
ctx.grant = grant;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
__decorate([
|
|
46
|
+
(0, core_1.Autowired)(access_protocol_1.SecurityExpressionContextHandler),
|
|
47
|
+
(0, core_1.Optional)(),
|
|
48
|
+
__metadata("design:type", Object)
|
|
49
|
+
], MethodSecurityMetadataSource.prototype, "securityExpressionContextHandler", void 0);
|
|
50
|
+
__decorate([
|
|
51
|
+
(0, core_1.Autowired)(access_protocol_1.ActionNameResolver),
|
|
52
|
+
__metadata("design:type", Object)
|
|
53
|
+
], MethodSecurityMetadataSource.prototype, "actionNameResolver", void 0);
|
|
54
|
+
MethodSecurityMetadataSource = __decorate([
|
|
55
|
+
(0, core_1.Component)(access_protocol_1.SecurityMetadataSource)
|
|
56
|
+
], MethodSecurityMetadataSource);
|
|
57
|
+
exports.MethodSecurityMetadataSource = MethodSecurityMetadataSource;
|
|
58
|
+
//# sourceMappingURL=security-metadata-source.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"security-metadata-source.js","sourceRoot":"","sources":["../../../src/node/access/security-metadata-source.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uCAA8E;AAC9E,uDAEqH;AACrH,wCAA6C;AAC7C,4CAA4C;AAC5C,+CAA+C;AAIxC,IAAM,4BAA4B,GAAlC,MAAM,4BAA4B;IAQrC,KAAK,CAAC,IAAI,CAAC,OAAsC;QAC7C,MAAM,aAAa,GAAa,IAAA,qBAAc,EAAC,wBAAY,CAAC,SAAS,EAAE,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QACnG,MAAM,cAAc,GAAa,IAAA,qBAAc,EAAC,wBAAY,CAAC,SAAS,EAAE,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;QACpH,MAAM,GAAG,mCACF,OAAO,GACP,yBAAe,CAAC,iBAAiB,EAAE,CACzC,CAAC;QACF,IAAI,IAAI,CAAC,gCAAgC,EAAE;YACvC,MAAM,IAAI,CAAC,gCAAgC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;SAC3D;QACD,cAAO,CAAC,OAAO,CAAC,iDAA+B,EAAE,GAAG,CAAC,CAAC;QACtD,MAAM,QAAQ,GAAG,aAAa,CAAC,MAAM,CAAC,GAAG,cAAc,CAAC;aACnD,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,aAAa,KAAK,OAAO,CAAC,aAAa,CAAC,CAAC;QAClE,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAC9D,OAAO;YACH,aAAa,EAAE,OAAO,CAAC,aAAa;YACpC,SAAS,EAAE,yBAAe,CAAC,iBAAiB,EAAE,CAAC,SAAS;YACxD,MAAM;YACN,QAAQ,EAAE,EAAE;YACZ,QAAQ,EAAE,QAAQ;YAClB,IAAI,KAAK;gBACL,OAAO,GAAG,CAAC,KAAK,CAAC;YACrB,CAAC;YACD,IAAI,KAAK,CAAC,KAAa;gBACnB,GAAG,CAAC,KAAK,GAAG,KAAK,CAAC;YACtB,CAAC;SACJ,CAAC;IACN,CAAC;CACJ,CAAA;AAlCG;IAAC,IAAA,gBAAS,EAAC,kDAAgC,CAAC;IAAE,IAAA,eAAQ,GAAE;;sFAC8B;AAEtF;IAAC,IAAA,gBAAS,EAAC,oCAAkB,CAAC;;wEAC4B;AANjD,4BAA4B;IADxC,IAAA,gBAAS,EAAC,wCAAsB,CAAC;GACrB,4BAA4B,CAoCxC;AApCY,oEAA4B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action.d.ts","sourceRoot":"","sources":["../../../src/node/annotation/action.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,MAAM,SAAmB,MAAM,cACxB,GAAG,aAAa,MAAM,GAAG,MAAM,cAAc,GAAG,SAInE,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Action = void 0;
|
|
4
|
+
const constants_1 = require("../constants");
|
|
5
|
+
const Action = function (name) {
|
|
6
|
+
return (target, targetKey, descriptor) => {
|
|
7
|
+
Reflect.defineMetadata(constants_1.METADATA_KEY.action, name, target.constructor, targetKey);
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
exports.Action = Action;
|
|
11
|
+
//# sourceMappingURL=action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action.js","sourceRoot":"","sources":["../../../src/node/annotation/action.ts"],"names":[],"mappings":";;;AAAA,4CAA4C;AAErC,MAAM,MAAM,GAAG,UAAU,IAAY;IACxC,OAAO,CAAC,MAAW,EAAE,SAA0B,EAAE,UAAe,EAAE,EAAE;QAChE,OAAO,CAAC,cAAc,CAAC,wBAAY,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;IACrF,CAAC,CAAC;AAEN,CAAC,CAAC;AALW,QAAA,MAAM,UAKjB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"anonymous.d.ts","sourceRoot":"","sources":["../../../src/node/annotation/anonymous.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,SAAS,wFAErB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Anonymous = void 0;
|
|
4
|
+
const authorize_1 = require("./authorize");
|
|
5
|
+
const common_1 = require("../../common");
|
|
6
|
+
const Anonymous = function () {
|
|
7
|
+
return (0, authorize_1.Authorize)({ el: 'true', authorizeType: common_1.AuthorizeType.Pre });
|
|
8
|
+
};
|
|
9
|
+
exports.Anonymous = Anonymous;
|
|
10
|
+
//# sourceMappingURL=anonymous.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"anonymous.js","sourceRoot":"","sources":["../../../src/node/annotation/anonymous.ts"],"names":[],"mappings":";;;AAAA,2CAAwC;AACxC,yCAA6C;AAEtC,MAAM,SAAS,GAAG;IACrB,OAAO,IAAA,qBAAS,EAAC,EAAE,EAAE,EAAE,MAAM,EAAE,aAAa,EAAE,sBAAa,CAAC,GAAG,EAAE,CAAC,CAAC;AACvE,CAAC,CAAC;AAFW,QAAA,SAAS,aAEpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authenticated.d.ts","sourceRoot":"","sources":["../../../src/node/annotation/authenticated.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,aAAa,wFAEzB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Authenticated = void 0;
|
|
4
|
+
const common_1 = require("../../common");
|
|
5
|
+
const authorize_1 = require("./authorize");
|
|
6
|
+
const Authenticated = function () {
|
|
7
|
+
return (0, authorize_1.Authorize)({ el: 'authenticated', authorizeType: common_1.AuthorizeType.Pre });
|
|
8
|
+
};
|
|
9
|
+
exports.Authenticated = Authenticated;
|
|
10
|
+
//# sourceMappingURL=authenticated.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authenticated.js","sourceRoot":"","sources":["../../../src/node/annotation/authenticated.ts"],"names":[],"mappings":";;;AAAA,yCAA6C;AAC7C,2CAAwC;AAEjC,MAAM,aAAa,GAAG;IACzB,OAAO,IAAA,qBAAS,EAAC,EAAE,EAAE,EAAE,eAAe,EAAE,aAAa,EAAE,sBAAa,CAAC,GAAG,EAAE,CAAC,CAAC;AAChF,CAAC,CAAC;AAFW,QAAA,aAAa,iBAExB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AuthorizeType, Policy } from '../../common';
|
|
2
|
+
export interface ElOption {
|
|
3
|
+
el: string;
|
|
4
|
+
authorizeType: AuthorizeType;
|
|
5
|
+
}
|
|
6
|
+
export declare namespace ElOption {
|
|
7
|
+
function is(option: any): option is ElOption;
|
|
8
|
+
}
|
|
9
|
+
export declare const Authorize: (elOrElOptionOrPolicy: string | ElOption | Policy) => (target: any, targetKey?: string | symbol, descriptor?: any) => void;
|
|
10
|
+
export declare function getPolicy(elOrElOptionOrPolicy: string | ElOption | Policy): Policy;
|
|
11
|
+
//# sourceMappingURL=authorize.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authorize.d.ts","sourceRoot":"","sources":["../../../src/node/annotation/authorize.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,EAAc,MAAM,cAAc,CAAC;AAEjE,MAAM,WAAW,QAAQ;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,aAAa,EAAE,aAAa,CAAC;CAChC;AAED,yBAAiB,QAAQ,CAAC;IACtB,SAAgB,EAAE,CAAC,MAAM,EAAE,GAAG,GAAG,MAAM,IAAI,QAAQ,CAElD;CACJ;AAED,eAAO,MAAM,SAAS,yBAAmC,MAAM,GAAG,QAAQ,GAAG,MAAM,cAE/D,GAAG,cAAc,MAAM,GAAG,MAAM,eAAe,GAAG,SAYrE,CAAC;AAEF,wBAAgB,SAAS,CAAC,oBAAoB,EAAE,MAAM,GAAG,QAAQ,GAAG,MAAM,UAQzE"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPolicy = exports.Authorize = exports.ElOption = void 0;
|
|
4
|
+
const constants_1 = require("../constants");
|
|
5
|
+
const common_1 = require("../../common");
|
|
6
|
+
var ElOption;
|
|
7
|
+
(function (ElOption) {
|
|
8
|
+
function is(option) {
|
|
9
|
+
return option && (option.el !== undefined || option.authorizeType);
|
|
10
|
+
}
|
|
11
|
+
ElOption.is = is;
|
|
12
|
+
})(ElOption = exports.ElOption || (exports.ElOption = {}));
|
|
13
|
+
const Authorize = function (elOrElOptionOrPolicy) {
|
|
14
|
+
const policy = getPolicy(elOrElOptionOrPolicy);
|
|
15
|
+
return (target, targetKey, descriptor) => {
|
|
16
|
+
if (targetKey) {
|
|
17
|
+
const policies = Reflect.getOwnMetadata(constants_1.METADATA_KEY.authorize, target.constructor, targetKey) || [];
|
|
18
|
+
policies.push(policy);
|
|
19
|
+
Reflect.defineMetadata(constants_1.METADATA_KEY.authorize, policies, target.constructor, targetKey);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
const policies = Reflect.getOwnMetadata(constants_1.METADATA_KEY.authorize, target.constructor) || [];
|
|
23
|
+
policies.push(policy);
|
|
24
|
+
Reflect.defineMetadata(constants_1.METADATA_KEY.authorize, policies, target);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
exports.Authorize = Authorize;
|
|
29
|
+
function getPolicy(elOrElOptionOrPolicy) {
|
|
30
|
+
let policy = elOrElOptionOrPolicy;
|
|
31
|
+
if (typeof elOrElOptionOrPolicy === 'string') {
|
|
32
|
+
policy = { authorizeType: common_1.AuthorizeType.Pre, el: elOrElOptionOrPolicy, type: common_1.PolicyType.el };
|
|
33
|
+
}
|
|
34
|
+
else if (elOrElOptionOrPolicy.el) {
|
|
35
|
+
policy = Object.assign({ type: common_1.PolicyType.el }, elOrElOptionOrPolicy);
|
|
36
|
+
}
|
|
37
|
+
return policy;
|
|
38
|
+
}
|
|
39
|
+
exports.getPolicy = getPolicy;
|
|
40
|
+
//# sourceMappingURL=authorize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authorize.js","sourceRoot":"","sources":["../../../src/node/annotation/authorize.ts"],"names":[],"mappings":";;;AAAA,4CAA4C;AAC5C,yCAAiE;AAOjE,IAAiB,QAAQ,CAIxB;AAJD,WAAiB,QAAQ;IACrB,SAAgB,EAAE,CAAC,MAAW;QAC1B,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,EAAE,KAAK,SAAS,IAAI,MAAM,CAAC,aAAa,CAAC,CAAC;IACvE,CAAC;IAFe,WAAE,KAEjB,CAAA;AACL,CAAC,EAJgB,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAIxB;AAEM,MAAM,SAAS,GAAG,UAAU,oBAAgD;IAC/E,MAAM,MAAM,GAAG,SAAS,CAAC,oBAAoB,CAAC,CAAC;IAC/C,OAAO,CAAC,MAAW,EAAE,SAA2B,EAAE,UAAgB,EAAE,EAAE;QAClE,IAAI,SAAS,EAAE;YACX,MAAM,QAAQ,GAAa,OAAO,CAAC,cAAc,CAAC,wBAAY,CAAC,SAAS,EAAE,MAAM,CAAC,WAAW,EAAE,SAAS,CAAC,IAAI,EAAE,CAAC;YAC/G,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACtB,OAAO,CAAC,cAAc,CAAC,wBAAY,CAAC,SAAS,EAAE,QAAQ,EAAE,MAAM,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;SAC3F;aAAM;YACH,MAAM,QAAQ,GAAa,OAAO,CAAC,cAAc,CAAC,wBAAY,CAAC,SAAS,EAAE,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC;YACpG,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACtB,OAAO,CAAC,cAAc,CAAC,wBAAY,CAAC,SAAS,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;SACpE;IACL,CAAC,CAAC;AAEN,CAAC,CAAC;AAdW,QAAA,SAAS,aAcpB;AAEF,SAAgB,SAAS,CAAC,oBAAgD;IACtE,IAAI,MAAM,GAAW,oBAAoB,CAAC;IAC1C,IAAI,OAAO,oBAAoB,KAAK,QAAQ,EAAE;QAC1C,MAAM,GAAG,EAAE,aAAa,EAAE,sBAAa,CAAC,GAAG,EAAE,EAAE,EAAE,oBAAoB,EAAE,IAAI,EAAE,mBAAU,CAAC,EAAE,EAAE,CAAC;KAChG;SAAM,IAAI,oBAAoB,CAAC,EAAE,EAAE;QAChC,MAAM,mBAAK,IAAI,EAAE,mBAAU,CAAC,EAAE,IAAK,oBAAoB,CAAC,CAAC;KAC5D;IACD,OAAO,MAAM,CAAC;AAClB,CAAC;AARD,8BAQC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/node/annotation/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./anonymous"), exports);
|
|
18
|
+
__exportStar(require("./authenticated"), exports);
|
|
19
|
+
__exportStar(require("./authorize"), exports);
|
|
20
|
+
__exportStar(require("./post-authorize"), exports);
|
|
21
|
+
__exportStar(require("./pre-authorize"), exports);
|
|
22
|
+
__exportStar(require("./resource"), exports);
|
|
23
|
+
__exportStar(require("./action"), exports);
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/node/annotation/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,kDAAgC;AAChC,8CAA4B;AAC5B,mDAAiC;AACjC,kDAAgC;AAChC,6CAA2B;AAC3B,2CAAyB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"post-authorize.d.ts","sourceRoot":"","sources":["../../../src/node/annotation/post-authorize.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,aAAa,OAAiB,MAAM,qFAEhD,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PostAuthorize = void 0;
|
|
4
|
+
const authorize_1 = require("./authorize");
|
|
5
|
+
const common_1 = require("../../common");
|
|
6
|
+
const PostAuthorize = function (el) {
|
|
7
|
+
return (0, authorize_1.Authorize)({ el, authorizeType: common_1.AuthorizeType.Post });
|
|
8
|
+
};
|
|
9
|
+
exports.PostAuthorize = PostAuthorize;
|
|
10
|
+
//# sourceMappingURL=post-authorize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"post-authorize.js","sourceRoot":"","sources":["../../../src/node/annotation/post-authorize.ts"],"names":[],"mappings":";;;AAAA,2CAAwC;AACxC,yCAA6C;AAEtC,MAAM,aAAa,GAAG,UAAU,EAAU;IAC7C,OAAO,IAAA,qBAAS,EAAC,EAAE,EAAE,EAAE,aAAa,EAAE,sBAAa,CAAC,IAAI,EAAE,CAAC,CAAC;AAChE,CAAC,CAAC;AAFW,QAAA,aAAa,iBAExB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pre-authorize.d.ts","sourceRoot":"","sources":["../../../src/node/annotation/pre-authorize.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,YAAY,OAAiB,MAAM,qFAE/C,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PreAuthorize = void 0;
|
|
4
|
+
const authorize_1 = require("./authorize");
|
|
5
|
+
const common_1 = require("../../common");
|
|
6
|
+
const PreAuthorize = function (el) {
|
|
7
|
+
return (0, authorize_1.Authorize)({ el, authorizeType: common_1.AuthorizeType.Pre });
|
|
8
|
+
};
|
|
9
|
+
exports.PreAuthorize = PreAuthorize;
|
|
10
|
+
//# sourceMappingURL=pre-authorize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pre-authorize.js","sourceRoot":"","sources":["../../../src/node/annotation/pre-authorize.ts"],"names":[],"mappings":";;;AAAA,2CAAwC;AACxC,yCAA6C;AAEtC,MAAM,YAAY,GAAG,UAAU,EAAU;IAC5C,OAAO,IAAA,qBAAS,EAAC,EAAE,EAAE,EAAE,aAAa,EAAE,sBAAa,CAAC,GAAG,EAAE,CAAC,CAAC;AAC/D,CAAC,CAAC;AAFW,QAAA,YAAY,gBAEvB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../../../src/node/annotation/resource.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,QAAQ,iBAA2B,MAAM,EAAE,cACpC,GAAG,cAAc,MAAM,GAAG,MAAM,eAAe,GAAG,SAQrE,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Resource = void 0;
|
|
4
|
+
const constants_1 = require("../constants");
|
|
5
|
+
const Resource = function (...resources) {
|
|
6
|
+
return (target, targetKey, descriptor) => {
|
|
7
|
+
if (targetKey) {
|
|
8
|
+
Reflect.defineMetadata(constants_1.METADATA_KEY.resource, resources, target.constructor, targetKey);
|
|
9
|
+
}
|
|
10
|
+
else {
|
|
11
|
+
Reflect.defineMetadata(constants_1.METADATA_KEY.resource, resources, target);
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
exports.Resource = Resource;
|
|
16
|
+
//# sourceMappingURL=resource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource.js","sourceRoot":"","sources":["../../../src/node/annotation/resource.ts"],"names":[],"mappings":";;;AAAA,4CAA4C;AAErC,MAAM,QAAQ,GAAG,UAAU,GAAG,SAAmB;IACpD,OAAO,CAAC,MAAW,EAAE,SAA2B,EAAE,UAAgB,EAAE,EAAE;QAClE,IAAI,SAAS,EAAE;YACX,OAAO,CAAC,cAAc,CAAC,wBAAY,CAAC,QAAQ,EAAE,SAAS,EAAE,MAAM,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;SAC3F;aAAM;YACH,OAAO,CAAC,cAAc,CAAC,wBAAY,CAAC,QAAQ,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;SACpE;IACL,CAAC,CAAC;AAEN,CAAC,CAAC;AATW,QAAA,QAAQ,YASnB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AuthenticationProvider, AuthenticationManager, AuthenticationSuccessHandler } from './authentication-protocol';
|
|
2
|
+
export declare class AuthenticationManagerImpl implements AuthenticationManager {
|
|
3
|
+
protected prioritized: AuthenticationProvider[];
|
|
4
|
+
protected readonly authenticationProviders: AuthenticationProvider[];
|
|
5
|
+
protected readonly authenticationSuccessHandler: AuthenticationSuccessHandler;
|
|
6
|
+
init(): void;
|
|
7
|
+
authenticate(next: () => Promise<void>): Promise<void>;
|
|
8
|
+
support(): Promise<boolean>;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=authentication-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authentication-manager.d.ts","sourceRoot":"","sources":["../../../src/node/authentication/authentication-manager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAkB,4BAA4B,EAAE,MAAM,2BAA2B,CAAC;AAIxI,qBACa,yBAA0B,YAAW,qBAAqB;IAEnE,SAAS,CAAC,WAAW,EAAE,sBAAsB,EAAE,CAAC;IAGhD,SAAS,CAAC,QAAQ,CAAC,uBAAuB,EAAE,sBAAsB,EAAE,CAAC;IAGrE,SAAS,CAAC,QAAQ,CAAC,4BAA4B,EAAE,4BAA4B,CAAC;IAG9E,IAAI;IAIE,YAAY,CAAC,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IA+BtD,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC;CAQpC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.AuthenticationManagerImpl = void 0;
|
|
13
|
+
const core_1 = require("@celljs/core");
|
|
14
|
+
const authentication_protocol_1 = require("./authentication-protocol");
|
|
15
|
+
const error_1 = require("../error");
|
|
16
|
+
const context_1 = require("../context");
|
|
17
|
+
let AuthenticationManagerImpl = class AuthenticationManagerImpl {
|
|
18
|
+
init() {
|
|
19
|
+
this.prioritized = core_1.Prioritizeable.prioritizeAllSync(this.authenticationProviders).map(c => c.value);
|
|
20
|
+
}
|
|
21
|
+
async authenticate(next) {
|
|
22
|
+
let result;
|
|
23
|
+
let lastError;
|
|
24
|
+
for (const authenticationProvider of this.prioritized) {
|
|
25
|
+
try {
|
|
26
|
+
if (await authenticationProvider.support()) {
|
|
27
|
+
result = await authenticationProvider.authenticate();
|
|
28
|
+
if (result) {
|
|
29
|
+
await this.authenticationSuccessHandler.onAuthenticationSuccess(result);
|
|
30
|
+
context_1.SecurityContext.setAuthentication(result);
|
|
31
|
+
if (result.next) {
|
|
32
|
+
await next();
|
|
33
|
+
}
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
if (error instanceof error_1.AccountStatusError) {
|
|
40
|
+
throw error;
|
|
41
|
+
}
|
|
42
|
+
else if (error instanceof error_1.AuthenticationError) {
|
|
43
|
+
lastError = error;
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
throw error;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (lastError) {
|
|
51
|
+
throw lastError;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
async support() {
|
|
55
|
+
for (const authenticationProvider of this.prioritized) {
|
|
56
|
+
if (await authenticationProvider.support()) {
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
__decorate([
|
|
64
|
+
(0, core_1.Autowired)(authentication_protocol_1.AuthenticationProvider),
|
|
65
|
+
__metadata("design:type", Array)
|
|
66
|
+
], AuthenticationManagerImpl.prototype, "authenticationProviders", void 0);
|
|
67
|
+
__decorate([
|
|
68
|
+
(0, core_1.Autowired)(authentication_protocol_1.AuthenticationSuccessHandler),
|
|
69
|
+
__metadata("design:type", Object)
|
|
70
|
+
], AuthenticationManagerImpl.prototype, "authenticationSuccessHandler", void 0);
|
|
71
|
+
__decorate([
|
|
72
|
+
(0, core_1.PostConstruct)(),
|
|
73
|
+
__metadata("design:type", Function),
|
|
74
|
+
__metadata("design:paramtypes", []),
|
|
75
|
+
__metadata("design:returntype", void 0)
|
|
76
|
+
], AuthenticationManagerImpl.prototype, "init", null);
|
|
77
|
+
AuthenticationManagerImpl = __decorate([
|
|
78
|
+
(0, core_1.Component)(authentication_protocol_1.AuthenticationManager)
|
|
79
|
+
], AuthenticationManagerImpl);
|
|
80
|
+
exports.AuthenticationManagerImpl = AuthenticationManagerImpl;
|
|
81
|
+
//# sourceMappingURL=authentication-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authentication-manager.js","sourceRoot":"","sources":["../../../src/node/authentication/authentication-manager.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uCAAmF;AACnF,uEAAwI;AACxI,oCAAmE;AACnE,wCAA6C;AAGtC,IAAM,yBAAyB,GAA/B,MAAM,yBAAyB;IAWlC,IAAI;QACA,IAAI,CAAC,WAAW,GAAG,qBAAc,CAAC,iBAAiB,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IACxG,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,IAAyB;QACxC,IAAI,MAAkC,CAAC;QACvC,IAAI,SAAc,CAAC;QACnB,KAAK,MAAM,sBAAsB,IAAI,IAAI,CAAC,WAAW,EAAE;YACnD,IAAI;gBACA,IAAI,MAAM,sBAAsB,CAAC,OAAO,EAAE,EAAE;oBACxC,MAAM,GAAG,MAAM,sBAAsB,CAAC,YAAY,EAAE,CAAC;oBACrD,IAAI,MAAM,EAAE;wBACR,MAAM,IAAI,CAAC,4BAA4B,CAAC,uBAAuB,CAAC,MAAM,CAAC,CAAC;wBACxE,yBAAe,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;wBAC1C,IAAI,MAAM,CAAC,IAAI,EAAE;4BACb,MAAM,IAAI,EAAE,CAAC;yBAChB;wBACD,OAAO;qBACV;iBACJ;aACJ;YAAC,OAAO,KAAK,EAAE;gBACZ,IAAI,KAAK,YAAY,0BAAkB,EAAE;oBACrC,MAAM,KAAK,CAAC;iBACf;qBAAM,IAAI,KAAK,YAAY,2BAAmB,EAAE;oBAC7C,SAAS,GAAG,KAAK,CAAC;iBACrB;qBAAM;oBACH,MAAM,KAAK,CAAC;iBACf;aACJ;SACJ;QACD,IAAI,SAAS,EAAE;YACX,MAAM,SAAS,CAAC;SACnB;IACL,CAAC;IAED,KAAK,CAAC,OAAO;QACT,KAAK,MAAM,sBAAsB,IAAI,IAAI,CAAC,WAAW,EAAE;YACnD,IAAI,MAAM,sBAAsB,CAAC,OAAO,EAAE,EAAE;gBACxC,OAAO,IAAI,CAAC;aACf;SACJ;QACD,OAAO,KAAK,CAAC;IACjB,CAAC;CACJ,CAAA;AAlDG;IAAC,IAAA,gBAAS,EAAC,gDAAsB,CAAC;;0EACmC;AAErE;IAAC,IAAA,gBAAS,EAAC,sDAA4B,CAAC;;+EACsC;AAE9E;IAAC,IAAA,oBAAa,GAAE;;;;qDAGf;AAbQ,yBAAyB;IADrC,IAAA,gBAAS,EAAC,+CAAqB,CAAC;GACpB,yBAAyB,CAsDrC;AAtDY,8DAAyB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Middleware, Context } from '@celljs/web/lib/node';
|
|
2
|
+
import { AuthenticationManager } from './authentication-protocol';
|
|
3
|
+
export declare class AuthenticationMiddleware implements Middleware {
|
|
4
|
+
protected readonly authenticationManager: AuthenticationManager;
|
|
5
|
+
handle(ctx: Context, next: () => Promise<void>): Promise<void>;
|
|
6
|
+
readonly priority: number;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=authentication-middleware.d.ts.map
|