@celljs/security 3.7.8 → 3.9.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/esm/browser/index.d.ts +1 -0
- package/esm/browser/index.js +2 -0
- package/esm/browser/index.js.map +1 -0
- package/esm/browser/module.d.ts +3 -0
- package/esm/browser/module.js +4 -0
- package/esm/browser/module.js.map +1 -0
- package/esm/browser/user/index.d.ts +2 -0
- package/esm/browser/user/index.js +3 -0
- package/esm/browser/user/index.js.map +1 -0
- package/esm/browser/user/user-manager.d.ts +22 -0
- package/esm/browser/user/user-manager.js +122 -0
- package/esm/browser/user/user-manager.js.map +1 -0
- package/esm/browser/user/user-protocol.d.ts +9 -0
- package/esm/browser/user/user-protocol.js +2 -0
- package/esm/browser/user/user-protocol.js.map +1 -0
- package/esm/common/index.d.ts +1 -0
- package/esm/common/index.js +2 -0
- package/esm/common/index.js.map +1 -0
- package/esm/common/security-protocol.d.ts +59 -0
- package/esm/common/security-protocol.js +30 -0
- package/esm/common/security-protocol.js.map +1 -0
- package/esm/node/access/access-decision-manager.d.ts +8 -0
- package/esm/node/access/access-decision-manager.js +53 -0
- package/esm/node/access/access-decision-manager.js.map +1 -0
- package/esm/node/access/access-decision-utils.d.ts +4 -0
- package/esm/node/access/access-decision-utils.js +20 -0
- package/esm/node/access/access-decision-utils.js.map +1 -0
- package/esm/node/access/access-decision-voter.d.ts +13 -0
- package/esm/node/access/access-decision-voter.js +83 -0
- package/esm/node/access/access-decision-voter.js.map +1 -0
- package/esm/node/access/access-protocol.d.ts +74 -0
- package/esm/node/access/access-protocol.js +17 -0
- package/esm/node/access/access-protocol.js.map +1 -0
- package/esm/node/access/action-name-resolver.d.ts +4 -0
- package/esm/node/access/action-name-resolver.js +27 -0
- package/esm/node/access/action-name-resolver.js.map +1 -0
- package/esm/node/access/index.d.ts +11 -0
- package/esm/node/access/index.js +12 -0
- package/esm/node/access/index.js.map +1 -0
- package/esm/node/access/jexl-engine-provider.d.ts +5 -0
- package/esm/node/access/jexl-engine-provider.js +22 -0
- package/esm/node/access/jexl-engine-provider.js.map +1 -0
- package/esm/node/access/method-advice.d.ts +16 -0
- package/esm/node/access/method-advice.js +78 -0
- package/esm/node/access/method-advice.js.map +1 -0
- package/esm/node/access/policy-provider.d.ts +16 -0
- package/esm/node/access/policy-provider.js +82 -0
- package/esm/node/access/policy-provider.js.map +1 -0
- package/esm/node/access/policy-resolver.d.ts +14 -0
- package/esm/node/access/policy-resolver.js +88 -0
- package/esm/node/access/policy-resolver.js.map +1 -0
- package/esm/node/access/resource-name-resolver.d.ts +6 -0
- package/esm/node/access/resource-name-resolver.js +55 -0
- package/esm/node/access/resource-name-resolver.js.map +1 -0
- package/esm/node/access/security-metadata-source.d.ts +6 -0
- package/esm/node/access/security-metadata-source.js +58 -0
- package/esm/node/access/security-metadata-source.js.map +1 -0
- package/esm/node/annotation/action.d.ts +1 -0
- package/esm/node/annotation/action.js +7 -0
- package/esm/node/annotation/action.js.map +1 -0
- package/esm/node/annotation/anonymous.d.ts +1 -0
- package/esm/node/annotation/anonymous.js +6 -0
- package/esm/node/annotation/anonymous.js.map +1 -0
- package/esm/node/annotation/authenticated.d.ts +1 -0
- package/esm/node/annotation/authenticated.js +6 -0
- package/esm/node/annotation/authenticated.js.map +1 -0
- package/esm/node/annotation/authorize.d.ts +10 -0
- package/esm/node/annotation/authorize.js +35 -0
- package/esm/node/annotation/authorize.js.map +1 -0
- package/esm/node/annotation/index.d.ts +7 -0
- package/esm/node/annotation/index.js +8 -0
- package/esm/node/annotation/index.js.map +1 -0
- package/esm/node/annotation/post-authorize.d.ts +1 -0
- package/esm/node/annotation/post-authorize.js +6 -0
- package/esm/node/annotation/post-authorize.js.map +1 -0
- package/esm/node/annotation/pre-authorize.d.ts +1 -0
- package/esm/node/annotation/pre-authorize.js +6 -0
- package/esm/node/annotation/pre-authorize.js.map +1 -0
- package/esm/node/annotation/resource.d.ts +1 -0
- package/esm/node/annotation/resource.js +12 -0
- package/esm/node/annotation/resource.js.map +1 -0
- package/esm/node/authentication/authentication-manager.d.ts +9 -0
- package/esm/node/authentication/authentication-manager.js +78 -0
- package/esm/node/authentication/authentication-manager.js.map +1 -0
- package/esm/node/authentication/authentication-middleware.d.ts +7 -0
- package/esm/node/authentication/authentication-middleware.js +33 -0
- package/esm/node/authentication/authentication-middleware.js.map +1 -0
- package/esm/node/authentication/authentication-protocol.d.ts +29 -0
- package/esm/node/authentication/authentication-protocol.js +9 -0
- package/esm/node/authentication/authentication-protocol.js.map +1 -0
- package/esm/node/authentication/authentication-provider.d.ts +32 -0
- package/esm/node/authentication/authentication-provider.js +171 -0
- package/esm/node/authentication/authentication-provider.js.map +1 -0
- package/esm/node/authentication/authentication-success-handler.d.ts +15 -0
- package/esm/node/authentication/authentication-success-handler.js +94 -0
- package/esm/node/authentication/authentication-success-handler.js.map +1 -0
- package/esm/node/authentication/index.d.ts +5 -0
- package/esm/node/authentication/index.js +6 -0
- package/esm/node/authentication/index.js.map +1 -0
- package/esm/node/cache/cache-protocol.d.ts +15 -0
- package/esm/node/cache/cache-protocol.js +3 -0
- package/esm/node/cache/cache-protocol.js.map +1 -0
- package/esm/node/cache/index.d.ts +2 -0
- package/esm/node/cache/index.js +3 -0
- package/esm/node/cache/index.js.map +1 -0
- package/esm/node/cache/request-cache.d.ts +9 -0
- package/esm/node/cache/request-cache.js +49 -0
- package/esm/node/cache/request-cache.js.map +1 -0
- package/esm/node/constants.d.ts +5 -0
- package/esm/node/constants.js +6 -0
- package/esm/node/constants.js.map +1 -0
- package/esm/node/context/context-protocol.d.ts +21 -0
- package/esm/node/context/context-protocol.js +27 -0
- package/esm/node/context/context-protocol.js.map +1 -0
- package/esm/node/context/index.d.ts +4 -0
- package/esm/node/context/index.js +5 -0
- package/esm/node/context/index.js.map +1 -0
- package/esm/node/context/security-context-middleware.d.ts +8 -0
- package/esm/node/context/security-context-middleware.js +41 -0
- package/esm/node/context/security-context-middleware.js.map +1 -0
- package/esm/node/context/security-context-store.d.ts +7 -0
- package/esm/node/context/security-context-store.js +37 -0
- package/esm/node/context/security-context-store.js.map +1 -0
- package/esm/node/context/security-context-strategy.d.ts +8 -0
- package/esm/node/context/security-context-strategy.js +28 -0
- package/esm/node/context/security-context-strategy.js.map +1 -0
- package/esm/node/crypto/index.d.ts +2 -0
- package/esm/node/crypto/index.js +3 -0
- package/esm/node/crypto/index.js.map +1 -0
- package/esm/node/crypto/keygen/base64-string-key-generator.d.ts +5 -0
- package/esm/node/crypto/keygen/base64-string-key-generator.js +28 -0
- package/esm/node/crypto/keygen/base64-string-key-generator.js.map +1 -0
- package/esm/node/crypto/keygen/index.d.ts +2 -0
- package/esm/node/crypto/keygen/index.js +3 -0
- package/esm/node/crypto/keygen/index.js.map +1 -0
- package/esm/node/crypto/keygen/keygen-protocol.d.ts +4 -0
- package/esm/node/crypto/keygen/keygen-protocol.js +2 -0
- package/esm/node/crypto/keygen/keygen-protocol.js.map +1 -0
- package/esm/node/crypto/password/index.d.ts +2 -0
- package/esm/node/crypto/password/index.js +3 -0
- package/esm/node/crypto/password/index.js.map +1 -0
- package/esm/node/crypto/password/password-encoder.d.ts +8 -0
- package/esm/node/crypto/password/password-encoder.js +49 -0
- package/esm/node/crypto/password/password-encoder.js.map +1 -0
- package/esm/node/crypto/password/password-protocol.d.ts +5 -0
- package/esm/node/crypto/password/password-protocol.js +2 -0
- package/esm/node/crypto/password/password-protocol.js.map +1 -0
- package/esm/node/error/error-handler.d.ts +18 -0
- package/esm/node/error/error-handler.js +78 -0
- package/esm/node/error/error-handler.js.map +1 -0
- package/esm/node/error/error-protocol.d.ts +2 -0
- package/esm/node/error/error-protocol.js +4 -0
- package/esm/node/error/error-protocol.js.map +1 -0
- package/esm/node/error/error.d.ts +20 -0
- package/esm/node/error/error.js +23 -0
- package/esm/node/error/error.js.map +1 -0
- package/esm/node/error/index.d.ts +3 -0
- package/esm/node/error/index.js +4 -0
- package/esm/node/error/index.js.map +1 -0
- package/esm/node/index.d.ts +10 -0
- package/esm/node/index.js +11 -0
- package/esm/node/index.js.map +1 -0
- package/esm/node/logout/index.d.ts +4 -0
- package/esm/node/logout/index.js +5 -0
- package/esm/node/logout/index.js.map +1 -0
- package/esm/node/logout/logout-handler.d.ts +4 -0
- package/esm/node/logout/logout-handler.js +19 -0
- package/esm/node/logout/logout-handler.js.map +1 -0
- package/esm/node/logout/logout-middleware.d.ts +15 -0
- package/esm/node/logout/logout-middleware.js +63 -0
- package/esm/node/logout/logout-middleware.js.map +1 -0
- package/esm/node/logout/logout-protocol.d.ts +11 -0
- package/esm/node/logout/logout-protocol.js +6 -0
- package/esm/node/logout/logout-protocol.js.map +1 -0
- package/esm/node/logout/logout-success-handler-provider.d.ts +7 -0
- package/esm/node/logout/logout-success-handler-provider.js +32 -0
- package/esm/node/logout/logout-success-handler-provider.js.map +1 -0
- package/esm/node/logout/logout-success-handler.d.ts +8 -0
- package/esm/node/logout/logout-success-handler.js +36 -0
- package/esm/node/logout/logout-success-handler.js.map +1 -0
- package/esm/node/module.d.ts +4 -0
- package/esm/node/module.js +5 -0
- package/esm/node/module.js.map +1 -0
- package/esm/node/user/index.d.ts +5 -0
- package/esm/node/user/index.js +6 -0
- package/esm/node/user/index.js.map +1 -0
- package/esm/node/user/user-checker.d.ts +7 -0
- package/esm/node/user/user-checker.js +41 -0
- package/esm/node/user/user-checker.js.map +1 -0
- package/esm/node/user/user-mapper.d.ts +8 -0
- package/esm/node/user/user-mapper.js +37 -0
- package/esm/node/user/user-mapper.js.map +1 -0
- package/esm/node/user/user-middleware.d.ts +10 -0
- package/esm/node/user/user-middleware.js +52 -0
- package/esm/node/user/user-middleware.js.map +1 -0
- package/esm/node/user/user-protocol.d.ts +14 -0
- package/esm/node/user/user-protocol.js +6 -0
- package/esm/node/user/user-protocol.js.map +1 -0
- package/esm/node/user/user-service.d.ts +6 -0
- package/esm/node/user/user-service.js +39 -0
- package/esm/node/user/user-service.js.map +1 -0
- package/esm/package.json +3 -0
- package/lib/browser/module.d.ts.map +1 -1
- package/lib/browser/module.js.map +1 -1
- package/lib/browser/user/user-manager.d.ts.map +1 -1
- package/lib/browser/user/user-manager.js.map +1 -1
- package/lib/common/security-protocol.js.map +1 -1
- package/lib/node/access/access-decision-manager.d.ts.map +1 -1
- package/lib/node/access/access-decision-manager.js.map +1 -1
- package/lib/node/access/access-decision-utils.js.map +1 -1
- package/lib/node/access/access-decision-voter.d.ts.map +1 -1
- package/lib/node/access/access-decision-voter.js.map +1 -1
- package/lib/node/access/access-protocol.js.map +1 -1
- package/lib/node/access/action-name-resolver.d.ts.map +1 -1
- package/lib/node/access/action-name-resolver.js.map +1 -1
- package/lib/node/access/jexl-engine-provider.d.ts.map +1 -1
- package/lib/node/access/jexl-engine-provider.js.map +1 -1
- package/lib/node/access/method-advice.d.ts.map +1 -1
- package/lib/node/access/method-advice.js.map +1 -1
- package/lib/node/access/policy-provider.d.ts.map +1 -1
- package/lib/node/access/policy-provider.js.map +1 -1
- package/lib/node/access/policy-resolver.d.ts +1 -1
- package/lib/node/access/policy-resolver.d.ts.map +1 -1
- package/lib/node/access/policy-resolver.js.map +1 -1
- package/lib/node/access/resource-name-resolver.d.ts.map +1 -1
- package/lib/node/access/resource-name-resolver.js.map +1 -1
- package/lib/node/access/security-metadata-source.d.ts.map +1 -1
- package/lib/node/access/security-metadata-source.js.map +1 -1
- package/lib/node/annotation/action.d.ts.map +1 -1
- package/lib/node/annotation/action.js.map +1 -1
- package/lib/node/annotation/anonymous.js.map +1 -1
- package/lib/node/annotation/authenticated.js.map +1 -1
- package/lib/node/annotation/authorize.d.ts.map +1 -1
- package/lib/node/annotation/authorize.js.map +1 -1
- package/lib/node/annotation/post-authorize.d.ts.map +1 -1
- package/lib/node/annotation/post-authorize.js.map +1 -1
- package/lib/node/annotation/pre-authorize.d.ts.map +1 -1
- package/lib/node/annotation/pre-authorize.js.map +1 -1
- package/lib/node/annotation/resource.d.ts.map +1 -1
- package/lib/node/annotation/resource.js.map +1 -1
- package/lib/node/authentication/authentication-manager.d.ts.map +1 -1
- package/lib/node/authentication/authentication-manager.js.map +1 -1
- package/lib/node/authentication/authentication-middleware.d.ts.map +1 -1
- package/lib/node/authentication/authentication-middleware.js.map +1 -1
- package/lib/node/authentication/authentication-protocol.js.map +1 -1
- package/lib/node/authentication/authentication-provider.d.ts.map +1 -1
- package/lib/node/authentication/authentication-provider.js.map +1 -1
- package/lib/node/authentication/authentication-success-handler.d.ts.map +1 -1
- package/lib/node/authentication/authentication-success-handler.js.map +1 -1
- package/lib/node/cache/request-cache.d.ts.map +1 -1
- package/lib/node/cache/request-cache.js +34 -1
- package/lib/node/cache/request-cache.js.map +1 -1
- package/lib/node/constants.d.ts.map +1 -1
- package/lib/node/context/context-protocol.js.map +1 -1
- package/lib/node/context/security-context-middleware.d.ts.map +1 -1
- package/lib/node/context/security-context-middleware.js.map +1 -1
- package/lib/node/context/security-context-store.d.ts.map +1 -1
- package/lib/node/context/security-context-store.js.map +1 -1
- package/lib/node/context/security-context-strategy.d.ts.map +1 -1
- package/lib/node/context/security-context-strategy.js.map +1 -1
- package/lib/node/crypto/keygen/base64-string-key-generator.d.ts.map +1 -1
- package/lib/node/crypto/keygen/base64-string-key-generator.js.map +1 -1
- package/lib/node/crypto/password/password-encoder.d.ts.map +1 -1
- package/lib/node/crypto/password/password-encoder.js.map +1 -1
- package/lib/node/error/error-handler.d.ts.map +1 -1
- package/lib/node/error/error-handler.js.map +1 -1
- package/lib/node/error/error-protocol.js.map +1 -1
- package/lib/node/error/error.d.ts.map +1 -1
- package/lib/node/error/error.js.map +1 -1
- package/lib/node/logout/logout-handler.d.ts.map +1 -1
- package/lib/node/logout/logout-handler.js.map +1 -1
- package/lib/node/logout/logout-middleware.d.ts.map +1 -1
- package/lib/node/logout/logout-middleware.js.map +1 -1
- package/lib/node/logout/logout-success-handler-provider.d.ts.map +1 -1
- package/lib/node/logout/logout-success-handler-provider.js.map +1 -1
- package/lib/node/logout/logout-success-handler.d.ts.map +1 -1
- package/lib/node/logout/logout-success-handler.js.map +1 -1
- package/lib/node/module.d.ts.map +1 -1
- package/lib/node/module.js.map +1 -1
- package/lib/node/user/user-checker.d.ts.map +1 -1
- package/lib/node/user/user-checker.js.map +1 -1
- package/lib/node/user/user-mapper.d.ts.map +1 -1
- package/lib/node/user/user-mapper.js.map +1 -1
- package/lib/node/user/user-middleware.d.ts.map +1 -1
- package/lib/node/user/user-middleware.js.map +1 -1
- package/lib/node/user/user-service.d.ts.map +1 -1
- package/lib/node/user/user-service.js.map +1 -1
- package/lib/package.spec.d.ts +1 -0
- package/lib/package.spec.js +5 -2
- package/lib/package.spec.js.map +1 -1
- package/package.json +103 -11
- package/src/package.spec.ts +1 -0
- package/LICENSE +0 -21
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { METADATA_KEY } from '../constants.js';
|
|
2
|
+
import { AuthorizeType, PolicyType } from '../../common/index.js';
|
|
3
|
+
export var ElOption;
|
|
4
|
+
(function (ElOption) {
|
|
5
|
+
function is(option) {
|
|
6
|
+
return option && (option.el !== undefined || option.authorizeType);
|
|
7
|
+
}
|
|
8
|
+
ElOption.is = is;
|
|
9
|
+
})(ElOption || (ElOption = {}));
|
|
10
|
+
export const Authorize = function (elOrElOptionOrPolicy) {
|
|
11
|
+
const policy = getPolicy(elOrElOptionOrPolicy);
|
|
12
|
+
return (target, targetKey, descriptor) => {
|
|
13
|
+
if (targetKey) {
|
|
14
|
+
const policies = Reflect.getOwnMetadata(METADATA_KEY.authorize, target.constructor, targetKey) || [];
|
|
15
|
+
policies.push(policy);
|
|
16
|
+
Reflect.defineMetadata(METADATA_KEY.authorize, policies, target.constructor, targetKey);
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
const policies = Reflect.getOwnMetadata(METADATA_KEY.authorize, target.constructor) || [];
|
|
20
|
+
policies.push(policy);
|
|
21
|
+
Reflect.defineMetadata(METADATA_KEY.authorize, policies, target);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export function getPolicy(elOrElOptionOrPolicy) {
|
|
26
|
+
let policy = elOrElOptionOrPolicy;
|
|
27
|
+
if (typeof elOrElOptionOrPolicy === 'string') {
|
|
28
|
+
policy = { authorizeType: AuthorizeType.Pre, el: elOrElOptionOrPolicy, type: PolicyType.el };
|
|
29
|
+
}
|
|
30
|
+
else if (elOrElOptionOrPolicy.el) {
|
|
31
|
+
policy = { type: PolicyType.el, ...elOrElOptionOrPolicy };
|
|
32
|
+
}
|
|
33
|
+
return policy;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=authorize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authorize.js","sourceRoot":"","sources":["../../../src/node/annotation/authorize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAU,UAAU,EAAE,MAAM,cAAc,CAAC;AAOjE,MAAM,KAAW,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,SAAA,EAAE,KAEjB,CAAA;AACL,CAAC,EAJgB,QAAQ,KAAR,QAAQ,QAIxB;AAED,MAAM,CAAC,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,CAAC;YACZ,MAAM,QAAQ,GAAa,OAAO,CAAC,cAAc,CAAC,YAAY,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,YAAY,CAAC,SAAS,EAAE,QAAQ,EAAE,MAAM,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;QAC5F,CAAC;aAAM,CAAC;YACJ,MAAM,QAAQ,GAAa,OAAO,CAAC,cAAc,CAAC,YAAY,CAAC,SAAS,EAAE,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC;YACpG,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACtB,OAAO,CAAC,cAAc,CAAC,YAAY,CAAC,SAAS,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;QACrE,CAAC;IACL,CAAC,CAAC;AAEN,CAAC,CAAC;AAEF,MAAM,UAAU,SAAS,CAAC,oBAAgD;IACtE,IAAI,MAAM,GAAW,oBAAoB,CAAC;IAC1C,IAAI,OAAO,oBAAoB,KAAK,QAAQ,EAAE,CAAC;QAC3C,MAAM,GAAG,EAAE,aAAa,EAAE,aAAa,CAAC,GAAG,EAAE,EAAE,EAAE,oBAAoB,EAAE,IAAI,EAAE,UAAU,CAAC,EAAE,EAAE,CAAC;IACjG,CAAC;SAAM,IAAI,oBAAoB,CAAC,EAAE,EAAE,CAAC;QACjC,MAAM,GAAG,EAAE,IAAI,EAAE,UAAU,CAAC,EAAE,EAAE,GAAG,oBAAoB,EAAC,CAAC;IAC7D,CAAC;IACD,OAAO,MAAM,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './anonymous.js';
|
|
2
|
+
export * from './authenticated.js';
|
|
3
|
+
export * from './authorize.js';
|
|
4
|
+
export * from './post-authorize.js';
|
|
5
|
+
export * from './pre-authorize.js';
|
|
6
|
+
export * from './resource.js';
|
|
7
|
+
export * from './action.js';
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","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 @@
|
|
|
1
|
+
export declare const PostAuthorize: (el: string) => (target: any, targetKey?: string | symbol, descriptor?: any) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"post-authorize.js","sourceRoot":"","sources":["../../../src/node/annotation/post-authorize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,MAAM,CAAC,MAAM,aAAa,GAAG,UAAU,EAAU;IAC7C,OAAO,SAAS,CAAC,EAAE,EAAE,EAAE,aAAa,EAAE,aAAa,CAAC,IAAI,EAAE,CAAC,CAAC;AAChE,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const PreAuthorize: (el: string) => (target: any, targetKey?: string | symbol, descriptor?: any) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pre-authorize.js","sourceRoot":"","sources":["../../../src/node/annotation/pre-authorize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,MAAM,CAAC,MAAM,YAAY,GAAG,UAAU,EAAU;IAC5C,OAAO,SAAS,CAAC,EAAE,EAAE,EAAE,aAAa,EAAE,aAAa,CAAC,GAAG,EAAE,CAAC,CAAC;AAC/D,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const Resource: (...resources: string[]) => (target: any, targetKey?: string | symbol, descriptor?: any) => void;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { METADATA_KEY } from '../constants.js';
|
|
2
|
+
export const Resource = function (...resources) {
|
|
3
|
+
return (target, targetKey, descriptor) => {
|
|
4
|
+
if (targetKey) {
|
|
5
|
+
Reflect.defineMetadata(METADATA_KEY.resource, resources, target.constructor, targetKey);
|
|
6
|
+
}
|
|
7
|
+
else {
|
|
8
|
+
Reflect.defineMetadata(METADATA_KEY.resource, resources, target);
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=resource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource.js","sourceRoot":"","sources":["../../../src/node/annotation/resource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,MAAM,CAAC,MAAM,QAAQ,GAAG,UAAU,GAAG,SAAmB;IACpD,OAAO,CAAC,MAAW,EAAE,SAA2B,EAAE,UAAgB,EAAE,EAAE;QAClE,IAAI,SAAS,EAAE,CAAC;YACZ,OAAO,CAAC,cAAc,CAAC,YAAY,CAAC,QAAQ,EAAE,SAAS,EAAE,MAAM,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;QAC5F,CAAC;aAAM,CAAC;YACJ,OAAO,CAAC,cAAc,CAAC,YAAY,CAAC,QAAQ,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;QACrE,CAAC;IACL,CAAC,CAAC;AAEN,CAAC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AuthenticationProvider, AuthenticationManager, AuthenticationSuccessHandler } from './authentication-protocol.js';
|
|
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
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
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;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { Component, Autowired, Prioritizeable, PostConstruct } from '@celljs/core';
|
|
11
|
+
import { AuthenticationProvider, AuthenticationManager, AuthenticationSuccessHandler } from './authentication-protocol.js';
|
|
12
|
+
import { AccountStatusError, AuthenticationError } from '../error/index.js';
|
|
13
|
+
import { SecurityContext } from '../context/index.js';
|
|
14
|
+
let AuthenticationManagerImpl = class AuthenticationManagerImpl {
|
|
15
|
+
init() {
|
|
16
|
+
this.prioritized = Prioritizeable.prioritizeAllSync(this.authenticationProviders).map(c => c.value);
|
|
17
|
+
}
|
|
18
|
+
async authenticate(next) {
|
|
19
|
+
let result;
|
|
20
|
+
let lastError;
|
|
21
|
+
for (const authenticationProvider of this.prioritized) {
|
|
22
|
+
try {
|
|
23
|
+
if (await authenticationProvider.support()) {
|
|
24
|
+
result = await authenticationProvider.authenticate();
|
|
25
|
+
if (result) {
|
|
26
|
+
await this.authenticationSuccessHandler.onAuthenticationSuccess(result);
|
|
27
|
+
SecurityContext.setAuthentication(result);
|
|
28
|
+
if (result.next) {
|
|
29
|
+
await next();
|
|
30
|
+
}
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
if (error instanceof AccountStatusError) {
|
|
37
|
+
throw error;
|
|
38
|
+
}
|
|
39
|
+
else if (error instanceof AuthenticationError) {
|
|
40
|
+
lastError = error;
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
throw error;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (lastError) {
|
|
48
|
+
throw lastError;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
async support() {
|
|
52
|
+
for (const authenticationProvider of this.prioritized) {
|
|
53
|
+
if (await authenticationProvider.support()) {
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
__decorate([
|
|
61
|
+
Autowired(AuthenticationProvider),
|
|
62
|
+
__metadata("design:type", Array)
|
|
63
|
+
], AuthenticationManagerImpl.prototype, "authenticationProviders", void 0);
|
|
64
|
+
__decorate([
|
|
65
|
+
Autowired(AuthenticationSuccessHandler),
|
|
66
|
+
__metadata("design:type", Object)
|
|
67
|
+
], AuthenticationManagerImpl.prototype, "authenticationSuccessHandler", void 0);
|
|
68
|
+
__decorate([
|
|
69
|
+
PostConstruct(),
|
|
70
|
+
__metadata("design:type", Function),
|
|
71
|
+
__metadata("design:paramtypes", []),
|
|
72
|
+
__metadata("design:returntype", void 0)
|
|
73
|
+
], AuthenticationManagerImpl.prototype, "init", null);
|
|
74
|
+
AuthenticationManagerImpl = __decorate([
|
|
75
|
+
Component(AuthenticationManager)
|
|
76
|
+
], AuthenticationManagerImpl);
|
|
77
|
+
export { AuthenticationManagerImpl };
|
|
78
|
+
//# sourceMappingURL=authentication-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authentication-manager.js","sourceRoot":"","sources":["../../../src/node/authentication/authentication-man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K,YAAY,mBAAmB,EAAE,CAAC;oBAC9C,SAAS,GAAG,KAAK,CAAC;gBACtB,CAAC;qBAAM,CAAC;oBACJ,MAAM,KAAK,CAAC;gBAChB,CAAC;YACL,CAAC;QACL,CAAC;QACD,IAAI,SAAS,EAAE,CAAC;YACZ,MAAM,SAAS,CAAC;QACpB,CAAC;IACL,CAAC;IAED,KAAK,CAAC,OAAO;QACT,KAAK,MAAM,sBAAsB,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACpD,IAAI,MAAM,sBAAsB,CAAC,OAAO,EAAE,EAAE,CAAC;gBACzC,OAAO,IAAI,CAAC;YAChB,CAAC;QACL,CAAC;QACD,OAAO,KAAK,CAAC;IACjB,CAAC;CACJ,CAAA;AAjDsB;IADlB,SAAS,CAAC,sBAAsB,CAAC;;0EACmC;AAGlD;IADlB,SAAS,CAAC,4BAA4B,CAAC;;+EACsC;AAG9E;IADC,aAAa,EAAE;;;;qDAGf;AAbQ,yBAAyB;IADrC,SAAS,CAAC,qBAAqB,CAAC;GACpB,yBAAyB,CAsDrC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Middleware, Context } from '@celljs/web/lib/node';
|
|
2
|
+
import { AuthenticationManager } from './authentication-protocol.js';
|
|
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
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
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;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { Middleware } from '@celljs/web/lib/node';
|
|
11
|
+
import { Component, Autowired } from '@celljs/core';
|
|
12
|
+
import { AuthenticationManager, AUTHENTICATION_MIDDLE_PRIORITY } from './authentication-protocol.js';
|
|
13
|
+
let AuthenticationMiddleware = class AuthenticationMiddleware {
|
|
14
|
+
constructor() {
|
|
15
|
+
this.priority = AUTHENTICATION_MIDDLE_PRIORITY;
|
|
16
|
+
}
|
|
17
|
+
async handle(ctx, next) {
|
|
18
|
+
if (await this.authenticationManager.support()) {
|
|
19
|
+
await this.authenticationManager.authenticate(next);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
await next();
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
__decorate([
|
|
26
|
+
Autowired(AuthenticationManager),
|
|
27
|
+
__metadata("design:type", Object)
|
|
28
|
+
], AuthenticationMiddleware.prototype, "authenticationManager", void 0);
|
|
29
|
+
AuthenticationMiddleware = __decorate([
|
|
30
|
+
Component(Middleware)
|
|
31
|
+
], AuthenticationMiddleware);
|
|
32
|
+
export { AuthenticationMiddleware };
|
|
33
|
+
//# sourceMappingURL=authentication-middleware.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authentication-middleware.js","sourceRoot":"","sources":["../../../src/node/authentication/authentication-middleware.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAW,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAE,8BAA8B,EAAE,MAAM,2BAA2B,CAAC;AAG3F,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;IAA9B;QAaM,aAAQ,GAAW,8BAA8B,CAAC;IAE/D,CAAC;IAVG,KAAK,CAAC,MAAM,CAAC,GAAY,EAAE,IAAyB;QAChD,IAAI,MAAM,IAAI,CAAC,qBAAqB,CAAC,OAAO,EAAE,EAAE,CAAC;YAC7C,MAAM,IAAI,CAAC,qBAAqB,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;YACpD,OAAO;QACX,CAAC;QACD,MAAM,IAAI,EAAE,CAAC;IACjB,CAAC;CAIJ,CAAA;AAZsB;IADlB,SAAS,CAAC,qBAAqB,CAAC;;uEAC+B;AAHvD,wBAAwB;IADpC,SAAS,CAAC,UAAU,CAAC;GACT,wBAAwB,CAepC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Policy } from '../../common/index.js';
|
|
2
|
+
export declare const AuthenticationProvider: unique symbol;
|
|
3
|
+
export declare const AuthenticationManager: unique symbol;
|
|
4
|
+
export declare const AuthenticationSuccessHandler: unique symbol;
|
|
5
|
+
export declare const AUTHENTICATION_SCHEME_BASIC = "Basic";
|
|
6
|
+
export declare const AUTHENTICATION_MIDDLE_PRIORITY: number;
|
|
7
|
+
export declare const USERNAME_PASSWORD_AUTHENTICATION_PROVIDER_PRIORITY = 2000;
|
|
8
|
+
export declare const BASE_AUTHENTICATION_PROVIDER_PRIORITY: number;
|
|
9
|
+
export interface AuthenticationManager {
|
|
10
|
+
authenticate(next: () => Promise<void>): Promise<void>;
|
|
11
|
+
support(): Promise<boolean>;
|
|
12
|
+
}
|
|
13
|
+
export interface AuthenticationProvider {
|
|
14
|
+
readonly priority: number;
|
|
15
|
+
authenticate(): Promise<Authentication | undefined>;
|
|
16
|
+
support(): Promise<boolean>;
|
|
17
|
+
}
|
|
18
|
+
export interface Authentication {
|
|
19
|
+
name: string;
|
|
20
|
+
policies: Policy[];
|
|
21
|
+
credentials: any;
|
|
22
|
+
details?: any;
|
|
23
|
+
principal: any;
|
|
24
|
+
next?: boolean;
|
|
25
|
+
authenticated: boolean;
|
|
26
|
+
}
|
|
27
|
+
export interface AuthenticationSuccessHandler {
|
|
28
|
+
onAuthenticationSuccess(authentication: Authentication): Promise<void>;
|
|
29
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { SECURITY_CONTEXT_MIDDLEWARE_PRIORITY } from '../context/index.js';
|
|
2
|
+
export const AuthenticationProvider = Symbol('AuthenticationProvider');
|
|
3
|
+
export const AuthenticationManager = Symbol('AuthenticationManager');
|
|
4
|
+
export const AuthenticationSuccessHandler = Symbol('AuthenticationSuccessHandler');
|
|
5
|
+
export const AUTHENTICATION_SCHEME_BASIC = 'Basic';
|
|
6
|
+
export const AUTHENTICATION_MIDDLE_PRIORITY = SECURITY_CONTEXT_MIDDLEWARE_PRIORITY - 100;
|
|
7
|
+
export const USERNAME_PASSWORD_AUTHENTICATION_PROVIDER_PRIORITY = 2000;
|
|
8
|
+
export const BASE_AUTHENTICATION_PROVIDER_PRIORITY = USERNAME_PASSWORD_AUTHENTICATION_PROVIDER_PRIORITY - 100;
|
|
9
|
+
//# sourceMappingURL=authentication-protocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authentication-protocol.js","sourceRoot":"","sources":["../../../src/node/authentication/authentication-protocol.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oCAAoC,EAAE,MAAM,YAAY,CAAC;AAElE,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC,wBAAwB,CAAC,CAAC;AACvE,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC,uBAAuB,CAAC,CAAC;AACrE,MAAM,CAAC,MAAM,4BAA4B,GAAG,MAAM,CAAC,8BAA8B,CAAC,CAAC;AACnF,MAAM,CAAC,MAAM,2BAA2B,GAAG,OAAO,CAAC;AAEnD,MAAM,CAAC,MAAM,8BAA8B,GAAG,oCAAoC,GAAG,GAAG,CAAC;AAEzF,MAAM,CAAC,MAAM,kDAAkD,GAAI,IAAI,CAAC;AACxE,MAAM,CAAC,MAAM,qCAAqC,GAAI,kDAAkD,GAAG,GAAG,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { AuthenticationProvider, Authentication } from './authentication-protocol.js';
|
|
2
|
+
import { RequestMatcher, RedirectStrategy } from '@celljs/web/lib/node';
|
|
3
|
+
import { PasswordEncoder } from '../crypto/index.js';
|
|
4
|
+
import { UserService, UserChecker, UserMapper } from '../user/index.js';
|
|
5
|
+
import { PathResolver } from '@celljs/web';
|
|
6
|
+
import { User } from '../../common/index.js';
|
|
7
|
+
export declare class UsernamePasswordAuthenticationProvider implements AuthenticationProvider {
|
|
8
|
+
protected readonly options: any;
|
|
9
|
+
protected readonly passwordEncoder: PasswordEncoder;
|
|
10
|
+
protected readonly userService: UserService<string, User>;
|
|
11
|
+
protected readonly userChecker: UserChecker;
|
|
12
|
+
protected readonly userMapper: UserMapper;
|
|
13
|
+
protected readonly requestMatcher: RequestMatcher;
|
|
14
|
+
protected readonly pathResolver: PathResolver;
|
|
15
|
+
protected readonly redirectStrategy: RedirectStrategy;
|
|
16
|
+
priority: number;
|
|
17
|
+
authenticate(): Promise<Authentication | undefined>;
|
|
18
|
+
protected doGetValue(key: string): string;
|
|
19
|
+
support(): Promise<boolean>;
|
|
20
|
+
}
|
|
21
|
+
export declare class BasicAuthenticationProvider implements AuthenticationProvider {
|
|
22
|
+
protected readonly passwordEncoder: PasswordEncoder;
|
|
23
|
+
protected readonly userService: UserService<string, User>;
|
|
24
|
+
protected readonly userChecker: UserChecker;
|
|
25
|
+
protected readonly userMapper: UserMapper;
|
|
26
|
+
protected readonly requestMatcher: RequestMatcher;
|
|
27
|
+
protected readonly pathResolver: PathResolver;
|
|
28
|
+
protected readonly redirectStrategy: RedirectStrategy;
|
|
29
|
+
priority: number;
|
|
30
|
+
authenticate(): Promise<Authentication | undefined>;
|
|
31
|
+
support(): Promise<boolean>;
|
|
32
|
+
}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
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;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { Component, Autowired, Value } from '@celljs/core';
|
|
11
|
+
import { AuthenticationProvider, USERNAME_PASSWORD_AUTHENTICATION_PROVIDER_PRIORITY, BASE_AUTHENTICATION_PROVIDER_PRIORITY, AUTHENTICATION_SCHEME_BASIC } from './authentication-protocol.js';
|
|
12
|
+
import { Context, RequestMatcher, RedirectStrategy } from '@celljs/web/lib/node';
|
|
13
|
+
import { PasswordEncoder } from '../crypto/index.js';
|
|
14
|
+
import { UserService, UserChecker, UserMapper } from '../user/index.js';
|
|
15
|
+
import { BadCredentialsError } from '../error/index.js';
|
|
16
|
+
import { HttpHeaders } from '@celljs/http';
|
|
17
|
+
import { PathResolver } from '@celljs/web';
|
|
18
|
+
let UsernamePasswordAuthenticationProvider = class UsernamePasswordAuthenticationProvider {
|
|
19
|
+
constructor() {
|
|
20
|
+
this.priority = USERNAME_PASSWORD_AUTHENTICATION_PROVIDER_PRIORITY;
|
|
21
|
+
}
|
|
22
|
+
async authenticate() {
|
|
23
|
+
const username = this.doGetValue(this.options.usernameKey);
|
|
24
|
+
const password = this.doGetValue(this.options.passwordKey);
|
|
25
|
+
if (!password || !username) {
|
|
26
|
+
throw new BadCredentialsError('Bad credentials');
|
|
27
|
+
}
|
|
28
|
+
const user = await this.userService.load(username);
|
|
29
|
+
await this.userChecker.check(user);
|
|
30
|
+
if (!await this.passwordEncoder.matches(password, user.password)) {
|
|
31
|
+
throw new BadCredentialsError('Bad credentials');
|
|
32
|
+
}
|
|
33
|
+
await this.userMapper.map(user);
|
|
34
|
+
return {
|
|
35
|
+
name: user.username,
|
|
36
|
+
principal: user,
|
|
37
|
+
credentials: '',
|
|
38
|
+
policies: user.policies,
|
|
39
|
+
authenticated: true
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
doGetValue(key) {
|
|
43
|
+
const request = Context.getRequest();
|
|
44
|
+
if (request.body) {
|
|
45
|
+
return request.body[key];
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
return request.query[key];
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
async support() {
|
|
52
|
+
return !!await this.requestMatcher.match(await this.pathResolver.resolve(this.options.loginUrl), this.options.loginMethod);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
__decorate([
|
|
56
|
+
Value('cell.security'),
|
|
57
|
+
__metadata("design:type", Object)
|
|
58
|
+
], UsernamePasswordAuthenticationProvider.prototype, "options", void 0);
|
|
59
|
+
__decorate([
|
|
60
|
+
Autowired(PasswordEncoder),
|
|
61
|
+
__metadata("design:type", Object)
|
|
62
|
+
], UsernamePasswordAuthenticationProvider.prototype, "passwordEncoder", void 0);
|
|
63
|
+
__decorate([
|
|
64
|
+
Autowired(UserService),
|
|
65
|
+
__metadata("design:type", Object)
|
|
66
|
+
], UsernamePasswordAuthenticationProvider.prototype, "userService", void 0);
|
|
67
|
+
__decorate([
|
|
68
|
+
Autowired(UserChecker),
|
|
69
|
+
__metadata("design:type", Object)
|
|
70
|
+
], UsernamePasswordAuthenticationProvider.prototype, "userChecker", void 0);
|
|
71
|
+
__decorate([
|
|
72
|
+
Autowired(UserMapper),
|
|
73
|
+
__metadata("design:type", Object)
|
|
74
|
+
], UsernamePasswordAuthenticationProvider.prototype, "userMapper", void 0);
|
|
75
|
+
__decorate([
|
|
76
|
+
Autowired(RequestMatcher),
|
|
77
|
+
__metadata("design:type", Object)
|
|
78
|
+
], UsernamePasswordAuthenticationProvider.prototype, "requestMatcher", void 0);
|
|
79
|
+
__decorate([
|
|
80
|
+
Autowired(PathResolver),
|
|
81
|
+
__metadata("design:type", Object)
|
|
82
|
+
], UsernamePasswordAuthenticationProvider.prototype, "pathResolver", void 0);
|
|
83
|
+
__decorate([
|
|
84
|
+
Autowired(RedirectStrategy),
|
|
85
|
+
__metadata("design:type", Object)
|
|
86
|
+
], UsernamePasswordAuthenticationProvider.prototype, "redirectStrategy", void 0);
|
|
87
|
+
UsernamePasswordAuthenticationProvider = __decorate([
|
|
88
|
+
Component(AuthenticationProvider)
|
|
89
|
+
], UsernamePasswordAuthenticationProvider);
|
|
90
|
+
export { UsernamePasswordAuthenticationProvider };
|
|
91
|
+
let BasicAuthenticationProvider = class BasicAuthenticationProvider {
|
|
92
|
+
constructor() {
|
|
93
|
+
this.priority = BASE_AUTHENTICATION_PROVIDER_PRIORITY;
|
|
94
|
+
}
|
|
95
|
+
async authenticate() {
|
|
96
|
+
const request = Context.getRequest();
|
|
97
|
+
const header = request.get(HttpHeaders.AUTHORIZATION).trim();
|
|
98
|
+
const token = Buffer.from(header.substring(6), 'base64').toString('utf8');
|
|
99
|
+
if (!token) {
|
|
100
|
+
throw new BadCredentialsError('Empty basic authentication token');
|
|
101
|
+
}
|
|
102
|
+
const delim = token.indexOf(':');
|
|
103
|
+
if (delim === -1) {
|
|
104
|
+
throw new BadCredentialsError('Invalid basic authentication token');
|
|
105
|
+
}
|
|
106
|
+
const username = token.substring(0, delim);
|
|
107
|
+
const password = token.substring(delim);
|
|
108
|
+
if (!password || !username) {
|
|
109
|
+
throw new BadCredentialsError('Bad credentials');
|
|
110
|
+
}
|
|
111
|
+
const user = await this.userService.load(username);
|
|
112
|
+
await this.userChecker.check(user);
|
|
113
|
+
if (!await this.passwordEncoder.matches(password, user.password)) {
|
|
114
|
+
throw new BadCredentialsError('Bad credentials');
|
|
115
|
+
}
|
|
116
|
+
await this.userMapper.map(user);
|
|
117
|
+
return {
|
|
118
|
+
name: user.username,
|
|
119
|
+
principal: user,
|
|
120
|
+
credentials: '',
|
|
121
|
+
policies: user.policies,
|
|
122
|
+
authenticated: true,
|
|
123
|
+
next: true
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
async support() {
|
|
127
|
+
const request = Context.getRequest();
|
|
128
|
+
let header = request.get(HttpHeaders.AUTHORIZATION);
|
|
129
|
+
if (!header) {
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
header = header.trim();
|
|
133
|
+
if (header.toLowerCase().startsWith(AUTHENTICATION_SCHEME_BASIC.toLowerCase())) {
|
|
134
|
+
return true;
|
|
135
|
+
}
|
|
136
|
+
return false;
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
__decorate([
|
|
140
|
+
Autowired(PasswordEncoder),
|
|
141
|
+
__metadata("design:type", Object)
|
|
142
|
+
], BasicAuthenticationProvider.prototype, "passwordEncoder", void 0);
|
|
143
|
+
__decorate([
|
|
144
|
+
Autowired(UserService),
|
|
145
|
+
__metadata("design:type", Object)
|
|
146
|
+
], BasicAuthenticationProvider.prototype, "userService", void 0);
|
|
147
|
+
__decorate([
|
|
148
|
+
Autowired(UserChecker),
|
|
149
|
+
__metadata("design:type", Object)
|
|
150
|
+
], BasicAuthenticationProvider.prototype, "userChecker", void 0);
|
|
151
|
+
__decorate([
|
|
152
|
+
Autowired(UserMapper),
|
|
153
|
+
__metadata("design:type", Object)
|
|
154
|
+
], BasicAuthenticationProvider.prototype, "userMapper", void 0);
|
|
155
|
+
__decorate([
|
|
156
|
+
Autowired(RequestMatcher),
|
|
157
|
+
__metadata("design:type", Object)
|
|
158
|
+
], BasicAuthenticationProvider.prototype, "requestMatcher", void 0);
|
|
159
|
+
__decorate([
|
|
160
|
+
Autowired(PathResolver),
|
|
161
|
+
__metadata("design:type", Object)
|
|
162
|
+
], BasicAuthenticationProvider.prototype, "pathResolver", void 0);
|
|
163
|
+
__decorate([
|
|
164
|
+
Autowired(RedirectStrategy),
|
|
165
|
+
__metadata("design:type", Object)
|
|
166
|
+
], BasicAuthenticationProvider.prototype, "redirectStrategy", void 0);
|
|
167
|
+
BasicAuthenticationProvider = __decorate([
|
|
168
|
+
Component(AuthenticationProvider)
|
|
169
|
+
], BasicAuthenticationProvider);
|
|
170
|
+
export { BasicAuthenticationProvider };
|
|
171
|
+
//# sourceMappingURL=authentication-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authentication-provider.js","sourceRoot":"","sources":["../../../src/node/authentication/authentication-provider.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,sBAAsB,EAAkB,kDAAkD,EAC/F,qCAAqC,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAC;AAC1G,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACjF,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAKpC,IAAM,sCAAsC,GAA5C,MAAM,sCAAsC;IAA5C;QA0BH,aAAQ,GAAG,kDAAkD,CAAC;IAqClE,CAAC;IAnCG,KAAK,CAAC,YAAY;QACd,MAAM,QAAQ,GAAG,IAAI,CAAC,UAAU,C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W,EAAE,CAAC,EAAE,CAAC;YAC7E,OAAO,IAAI,CAAC;QAChB,CAAC;QACD,OAAO,KAAK,CAAC;IACjB,CAAC;CAEJ,CAAA;AAvEsB;IADlB,SAAS,CAAC,eAAe,CAAC;;oEACyB;AAGjC;IADlB,SAAS,CAAC,WAAW,CAAC;;gEACmC;AAGvC;IADlB,SAAS,CAAC,WAAW,CAAC;;gEACqB;AAGzB;IADlB,SAAS,CAAC,UAAU,CAAC;;+DACoB;AAGvB;IADlB,SAAS,CAAC,cAAc,CAAC;;mEACwB;AAG/B;IADlB,SAAS,CAAC,YAAY,CAAC;;iEACsB;AAG3B;IADlB,SAAS,CAAC,gBAAgB,CAAC;;qEAC0B;AArB7C,2BAA2B;IADvC,SAAS,CAAC,sBAAsB,CAAC;GACrB,2BAA2B,CA0EvC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { AuthenticationSuccessHandler, Authentication } from './authentication-protocol.js';
|
|
2
|
+
import { Logger } from '@celljs/core';
|
|
3
|
+
import { RedirectStrategy } from '@celljs/web/lib/node';
|
|
4
|
+
import { RequestCache } from '../cache/index.js';
|
|
5
|
+
export declare class DefaultAuthenticationSuccessHandler implements AuthenticationSuccessHandler {
|
|
6
|
+
protected readonly targetUrlParameter: string;
|
|
7
|
+
protected readonly loginSuccessUrl: string;
|
|
8
|
+
protected readonly alwaysUseLoginSuccessUrl: boolean;
|
|
9
|
+
protected readonly useReferer: boolean;
|
|
10
|
+
protected readonly logger: Logger;
|
|
11
|
+
protected readonly redirectStrategy: RedirectStrategy;
|
|
12
|
+
protected readonly requestCache: RequestCache;
|
|
13
|
+
onAuthenticationSuccess(authentication: Authentication): Promise<void>;
|
|
14
|
+
protected determineTargetUrl(authentication: Authentication): Promise<string>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
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;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { AuthenticationSuccessHandler } from './authentication-protocol.js';
|
|
11
|
+
import { Component, Value, Autowired, Logger } from '@celljs/core';
|
|
12
|
+
import { Context, RedirectStrategy } from '@celljs/web/lib/node';
|
|
13
|
+
import { HttpHeaders, XML_HTTP_REQUEST } from '@celljs/http';
|
|
14
|
+
import { RequestCache } from '../cache/index.js';
|
|
15
|
+
let DefaultAuthenticationSuccessHandler = class DefaultAuthenticationSuccessHandler {
|
|
16
|
+
async onAuthenticationSuccess(authentication) {
|
|
17
|
+
const response = Context.getResponse();
|
|
18
|
+
if (Context.getRequest().get(HttpHeaders.X_REQUESTED_WITH) === XML_HTTP_REQUEST) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
if (!this.loginSuccessUrl) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const targetUrl = await this.determineTargetUrl(authentication);
|
|
25
|
+
if (response.writableEnded) {
|
|
26
|
+
this.logger.debug(`Response has already been committed. Unable to redirect to ${targetUrl}`);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
await this.redirectStrategy.send(targetUrl);
|
|
30
|
+
}
|
|
31
|
+
async determineTargetUrl(authentication) {
|
|
32
|
+
if (this.alwaysUseLoginSuccessUrl) {
|
|
33
|
+
return this.loginSuccessUrl;
|
|
34
|
+
}
|
|
35
|
+
let targetUrl;
|
|
36
|
+
const request = Context.getRequest();
|
|
37
|
+
if (this.targetUrlParameter) {
|
|
38
|
+
targetUrl = request.query[this.targetUrlParameter];
|
|
39
|
+
if (targetUrl) {
|
|
40
|
+
this.logger.debug(`Found targetUrlParameter in request: ${targetUrl}`);
|
|
41
|
+
return targetUrl;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (this.useReferer) {
|
|
45
|
+
const referer = request.get(HttpHeaders.REFERER);
|
|
46
|
+
targetUrl = (referer === null || referer === void 0 ? void 0 : referer.length) ? referer[0] : '';
|
|
47
|
+
this.logger.debug(`Using Referer header: ${targetUrl}`);
|
|
48
|
+
}
|
|
49
|
+
const savedRequest = await this.requestCache.get();
|
|
50
|
+
if (savedRequest) {
|
|
51
|
+
await this.requestCache.remove();
|
|
52
|
+
targetUrl = savedRequest.redirectUrl;
|
|
53
|
+
this.logger.debug(`Redirecting to SavedRequest Url: ${targetUrl}`);
|
|
54
|
+
}
|
|
55
|
+
if (!targetUrl) {
|
|
56
|
+
targetUrl = this.loginSuccessUrl;
|
|
57
|
+
this.logger.debug(`Using default Url: ${targetUrl}`);
|
|
58
|
+
}
|
|
59
|
+
return targetUrl;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
__decorate([
|
|
63
|
+
Value('cell.security.targetUrlParameter'),
|
|
64
|
+
__metadata("design:type", String)
|
|
65
|
+
], DefaultAuthenticationSuccessHandler.prototype, "targetUrlParameter", void 0);
|
|
66
|
+
__decorate([
|
|
67
|
+
Value('cell.security.loginSuccessUrl'),
|
|
68
|
+
__metadata("design:type", String)
|
|
69
|
+
], DefaultAuthenticationSuccessHandler.prototype, "loginSuccessUrl", void 0);
|
|
70
|
+
__decorate([
|
|
71
|
+
Value('cell.security.alwaysUseLoginSuccessUrl'),
|
|
72
|
+
__metadata("design:type", Boolean)
|
|
73
|
+
], DefaultAuthenticationSuccessHandler.prototype, "alwaysUseLoginSuccessUrl", void 0);
|
|
74
|
+
__decorate([
|
|
75
|
+
Value('cell.security.useReferer'),
|
|
76
|
+
__metadata("design:type", Boolean)
|
|
77
|
+
], DefaultAuthenticationSuccessHandler.prototype, "useReferer", void 0);
|
|
78
|
+
__decorate([
|
|
79
|
+
Autowired(Logger),
|
|
80
|
+
__metadata("design:type", Object)
|
|
81
|
+
], DefaultAuthenticationSuccessHandler.prototype, "logger", void 0);
|
|
82
|
+
__decorate([
|
|
83
|
+
Autowired(RedirectStrategy),
|
|
84
|
+
__metadata("design:type", Object)
|
|
85
|
+
], DefaultAuthenticationSuccessHandler.prototype, "redirectStrategy", void 0);
|
|
86
|
+
__decorate([
|
|
87
|
+
Autowired(RequestCache),
|
|
88
|
+
__metadata("design:type", Object)
|
|
89
|
+
], DefaultAuthenticationSuccessHandler.prototype, "requestCache", void 0);
|
|
90
|
+
DefaultAuthenticationSuccessHandler = __decorate([
|
|
91
|
+
Component(AuthenticationSuccessHandler)
|
|
92
|
+
], DefaultAuthenticationSuccessHandler);
|
|
93
|
+
export { DefaultAuthenticationSuccessHandler };
|
|
94
|
+
//# sourceMappingURL=authentication-success-handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authentication-success-handler.js","sourceRoot":"","sources":["../../../src/node/authentication/authentication-success-handler.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,4BAA4B,EAAkB,MAAM,2BAA2B,CAAC;AACzF,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACnE,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAGjC,IAAM,mCAAmC,GAAzC,MAAM,mCAAmC;IAuB5C,KAAK,CAAC,uBAAuB,CAAC,cAA8B;QACxD,MAAM,QAAQ,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