@celljs/security 3.9.0 → 4.1.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/README.md +111 -1
- package/cell.yml +12 -7
- package/esm/node/access/access-protocol.d.ts +0 -4
- package/esm/node/access/access-protocol.js +0 -1
- package/esm/node/access/access-protocol.js.map +1 -1
- package/esm/node/access/index.d.ts +0 -1
- package/esm/node/access/index.js +0 -1
- package/esm/node/access/index.js.map +1 -1
- package/esm/node/access/policy-provider.js +2 -2
- package/esm/node/access/policy-resolver.d.ts +2 -1
- package/esm/node/access/policy-resolver.js +4 -4
- package/esm/node/access/policy-resolver.js.map +1 -1
- package/esm/node/access/resource-name-resolver.d.ts +3 -0
- package/esm/node/access/resource-name-resolver.js +10 -5
- package/esm/node/access/resource-name-resolver.js.map +1 -1
- package/esm/node/authentication/authentication-provider.d.ts +8 -0
- package/esm/node/authentication/authentication-provider.js +29 -2
- package/esm/node/authentication/authentication-provider.js.map +1 -1
- package/esm/node/authentication/authentication-success-handler.js +4 -0
- package/esm/node/authentication/authentication-success-handler.js.map +1 -1
- package/esm/node/crypto/keygen/base64-string-key-generator.d.ts +4 -0
- package/esm/node/crypto/keygen/base64-string-key-generator.js +6 -4
- package/esm/node/crypto/keygen/base64-string-key-generator.js.map +1 -1
- package/esm/node/crypto/password/password-encoder.d.ts +40 -3
- package/esm/node/crypto/password/password-encoder.js +80 -24
- package/esm/node/crypto/password/password-encoder.js.map +1 -1
- package/esm/node/crypto/password/password-protocol.d.ts +6 -0
- package/esm/node/module.d.ts +0 -1
- package/esm/node/module.js +0 -1
- package/esm/node/module.js.map +1 -1
- package/esm/node/user/user-protocol.d.ts +5 -0
- package/esm/node/user/user-service.d.ts +14 -0
- package/esm/node/user/user-service.js +33 -2
- package/esm/node/user/user-service.js.map +1 -1
- package/lib/node/access/access-protocol.d.ts +0 -4
- package/lib/node/access/access-protocol.d.ts.map +1 -1
- package/lib/node/access/access-protocol.js +1 -2
- package/lib/node/access/access-protocol.js.map +1 -1
- package/lib/node/access/expression-resolvers.spec.d.ts +2 -0
- package/lib/node/access/expression-resolvers.spec.d.ts.map +1 -0
- package/lib/node/access/expression-resolvers.spec.js +57 -0
- package/lib/node/access/expression-resolvers.spec.js.map +1 -0
- package/lib/node/access/index.d.ts +0 -1
- package/lib/node/access/index.d.ts.map +1 -1
- package/lib/node/access/index.js +0 -1
- package/lib/node/access/index.js.map +1 -1
- package/lib/node/access/policy-resolver.d.ts +2 -1
- package/lib/node/access/policy-resolver.d.ts.map +1 -1
- package/lib/node/access/policy-resolver.js +1 -1
- package/lib/node/access/policy-resolver.js.map +1 -1
- package/lib/node/access/resource-name-resolver.d.ts +3 -0
- package/lib/node/access/resource-name-resolver.d.ts.map +1 -1
- package/lib/node/access/resource-name-resolver.js +9 -3
- package/lib/node/access/resource-name-resolver.js.map +1 -1
- package/lib/node/authentication/authentication-provider.d.ts +8 -0
- package/lib/node/authentication/authentication-provider.d.ts.map +1 -1
- package/lib/node/authentication/authentication-provider.js +29 -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 +4 -0
- package/lib/node/authentication/authentication-success-handler.js.map +1 -1
- package/lib/node/authentication/basic-authentication.spec.d.ts +2 -0
- package/lib/node/authentication/basic-authentication.spec.d.ts.map +1 -0
- package/lib/node/authentication/basic-authentication.spec.js +65 -0
- package/lib/node/authentication/basic-authentication.spec.js.map +1 -0
- package/lib/node/crypto/keygen/base64-string-key-generator.d.ts +4 -0
- package/lib/node/crypto/keygen/base64-string-key-generator.d.ts.map +1 -1
- package/lib/node/crypto/keygen/base64-string-key-generator.js +6 -3
- package/lib/node/crypto/keygen/base64-string-key-generator.js.map +1 -1
- package/lib/node/crypto/keygen/base64-string-key-generator.spec.d.ts +2 -0
- package/lib/node/crypto/keygen/base64-string-key-generator.spec.d.ts.map +1 -0
- package/lib/node/crypto/keygen/base64-string-key-generator.spec.js +15 -0
- package/lib/node/crypto/keygen/base64-string-key-generator.spec.js.map +1 -0
- package/lib/node/crypto/password/password-encoder.d.ts +40 -3
- package/lib/node/crypto/password/password-encoder.d.ts.map +1 -1
- package/lib/node/crypto/password/password-encoder.js +80 -23
- package/lib/node/crypto/password/password-encoder.js.map +1 -1
- package/lib/node/crypto/password/password-encoder.spec.d.ts +2 -0
- package/lib/node/crypto/password/password-encoder.spec.d.ts.map +1 -0
- package/lib/node/crypto/password/password-encoder.spec.js +147 -0
- package/lib/node/crypto/password/password-encoder.spec.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 -1
- package/lib/node/module.d.ts +0 -1
- package/lib/node/module.d.ts.map +1 -1
- package/lib/node/module.js +0 -1
- package/lib/node/module.js.map +1 -1
- package/lib/node/user/user-protocol.d.ts +5 -0
- package/lib/node/user/user-protocol.d.ts.map +1 -1
- package/lib/node/user/user-service.d.ts +14 -0
- package/lib/node/user/user-service.d.ts.map +1 -1
- package/lib/node/user/user-service.js +33 -2
- package/lib/node/user/user-service.js.map +1 -1
- package/lib/node/user/user-service.spec.d.ts +2 -0
- package/lib/node/user/user-service.spec.d.ts.map +1 -0
- package/lib/node/user/user-service.spec.js +44 -0
- package/lib/node/user/user-service.spec.js.map +1 -0
- package/package.json +17 -31
- package/src/node/access/access-protocol.ts +0 -5
- package/src/node/access/expression-resolvers.spec.ts +37 -0
- package/src/node/access/index.ts +0 -1
- package/src/node/access/policy-resolver.ts +2 -2
- package/src/node/access/resource-name-resolver.ts +10 -4
- package/src/node/authentication/authentication-provider.ts +26 -2
- package/src/node/authentication/authentication-success-handler.ts +4 -0
- package/src/node/authentication/basic-authentication.spec.ts +68 -0
- package/src/node/crypto/keygen/base64-string-key-generator.spec.ts +13 -0
- package/src/node/crypto/keygen/base64-string-key-generator.ts +6 -3
- package/src/node/crypto/password/password-encoder.spec.ts +162 -0
- package/src/node/crypto/password/password-encoder.ts +99 -21
- package/src/node/crypto/password/password-protocol.ts +6 -0
- package/src/node/module.ts +0 -1
- package/src/node/user/user-protocol.ts +5 -0
- package/src/node/user/user-service.spec.ts +46 -0
- package/src/node/user/user-service.ts +32 -2
- package/esm/node/access/jexl-engine-provider.d.ts +0 -5
- package/esm/node/access/jexl-engine-provider.js +0 -22
- package/esm/node/access/jexl-engine-provider.js.map +0 -1
- package/lib/node/access/jexl-engine-provider.d.ts +0 -6
- package/lib/node/access/jexl-engine-provider.d.ts.map +0 -1
- package/lib/node/access/jexl-engine-provider.js +0 -25
- package/lib/node/access/jexl-engine-provider.js.map +0 -1
- package/src/node/access/jexl-engine-provider.ts +0 -18
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
import { UserService } from './user-protocol';
|
|
2
|
-
import { Value, Component } from '@celljs/core';
|
|
2
|
+
import { Value, Component, Autowired, Logger, ApplicationLifecycle, Application } from '@celljs/core';
|
|
3
3
|
import { UsernameNotFoundError } from '../error';
|
|
4
4
|
import { User, UserType } from '../../common';
|
|
5
5
|
|
|
6
|
+
/** The one user of `cell.security.username` / `password`, when they are configured. */
|
|
6
7
|
@Component(UserService)
|
|
7
8
|
export class UserServiceImpl implements UserService<string, User> {
|
|
8
9
|
|
|
9
10
|
@Value('cell.security')
|
|
10
11
|
protected readonly options: any;
|
|
11
12
|
|
|
13
|
+
/** Whether `cell.security` configures a user. */
|
|
14
|
+
get hasConfiguredUser(): boolean {
|
|
15
|
+
return !!this.options?.username && !!this.options?.password;
|
|
16
|
+
}
|
|
17
|
+
|
|
12
18
|
async load(username: string): Promise<User> {
|
|
13
|
-
if (this.options.username === username) {
|
|
19
|
+
if (this.hasConfiguredUser && this.options.username === username) {
|
|
14
20
|
return {
|
|
15
21
|
type: UserType.Memery,
|
|
16
22
|
username,
|
|
@@ -26,3 +32,27 @@ export class UserServiceImpl implements UserService<string, User> {
|
|
|
26
32
|
throw new UsernameNotFoundError(`Could not find: ${username}`);
|
|
27
33
|
}
|
|
28
34
|
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Warns at startup when the login (form or Basic) has no user to check: the default UserService is in
|
|
38
|
+
* use and `cell.security` configures no user. A warning, not an error: an application may log in with
|
|
39
|
+
* OAuth2 only, or use @celljs/security for authorization alone.
|
|
40
|
+
*/
|
|
41
|
+
@Component(ApplicationLifecycle)
|
|
42
|
+
export class UserSourceCheck implements ApplicationLifecycle<Application> {
|
|
43
|
+
|
|
44
|
+
@Autowired(UserService)
|
|
45
|
+
protected readonly userService: UserService<string, User>;
|
|
46
|
+
|
|
47
|
+
@Autowired(Logger)
|
|
48
|
+
protected readonly logger: Logger;
|
|
49
|
+
|
|
50
|
+
initialize(): void {
|
|
51
|
+
if (this.userService instanceof UserServiceImpl && !this.userService.hasConfiguredUser) {
|
|
52
|
+
this.logger.warn(
|
|
53
|
+
'No user can log in: @celljs/security has no built-in user. Set cell.security.username and cell.security.password ' +
|
|
54
|
+
'(a hash made by the PasswordEncoder) in cell.yml, or bind a UserService of your own.'
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -1,22 +0,0 @@
|
|
|
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
|
-
import { Component } from '@celljs/core';
|
|
8
|
-
import { JexlEngineProvider } from './access-protocol.js';
|
|
9
|
-
import { Jexl } from 'jexl';
|
|
10
|
-
let JexlEngineProviderImpl = class JexlEngineProviderImpl {
|
|
11
|
-
provide() {
|
|
12
|
-
if (!this.jexlEngine) {
|
|
13
|
-
this.jexlEngine = new Jexl();
|
|
14
|
-
}
|
|
15
|
-
return this.jexlEngine;
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
JexlEngineProviderImpl = __decorate([
|
|
19
|
-
Component(JexlEngineProvider)
|
|
20
|
-
], JexlEngineProviderImpl);
|
|
21
|
-
export { JexlEngineProviderImpl };
|
|
22
|
-
//# sourceMappingURL=jexl-engine-provider.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"jexl-engine-provider.js","sourceRoot":"","sources":["../../../src/node/access/jexl-engine-provider.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAGrB,IAAM,sBAAsB,GAA5B,MAAM,sBAAsB;IAI/B,OAAO;QAEH,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;YACnB,IAAI,CAAC,UAAU,GAAG,IAAI,IAAI,EAAE,CAAC;QACjC,CAAC;QACD,OAAO,IAAI,CAAC,UAAU,CAAC;IAC3B,CAAC;CAEJ,CAAA;AAZY,sBAAsB;IADlC,SAAS,CAAC,kBAAkB,CAAC;GACjB,sBAAsB,CAYlC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"jexl-engine-provider.d.ts","sourceRoot":"","sources":["../../../src/node/access/jexl-engine-provider.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAGvD,qBACa,sBAAuB,YAAW,kBAAkB,CAAC,GAAG,CAAC;IAElE,SAAS,CAAC,UAAU,EAAE,GAAG,CAAC;IAE1B,OAAO,IAAI,GAAG,CAMb;CAEJ"}
|
|
@@ -1,25 +0,0 @@
|
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.JexlEngineProviderImpl = void 0;
|
|
10
|
-
const core_1 = require("@celljs/core");
|
|
11
|
-
const access_protocol_1 = require("./access-protocol");
|
|
12
|
-
const jexl_1 = require("jexl");
|
|
13
|
-
let JexlEngineProviderImpl = class JexlEngineProviderImpl {
|
|
14
|
-
provide() {
|
|
15
|
-
if (!this.jexlEngine) {
|
|
16
|
-
this.jexlEngine = new jexl_1.Jexl();
|
|
17
|
-
}
|
|
18
|
-
return this.jexlEngine;
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
exports.JexlEngineProviderImpl = JexlEngineProviderImpl;
|
|
22
|
-
exports.JexlEngineProviderImpl = JexlEngineProviderImpl = __decorate([
|
|
23
|
-
(0, core_1.Component)(access_protocol_1.JexlEngineProvider)
|
|
24
|
-
], JexlEngineProviderImpl);
|
|
25
|
-
//# sourceMappingURL=jexl-engine-provider.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"jexl-engine-provider.js","sourceRoot":"","sources":["../../../src/node/access/jexl-engine-provider.ts"],"names":[],"mappings":";;;;;;;;;AAAA,uCAAyC;AACzC,uDAAuD;AACvD,+BAA4B;AAGrB,IAAM,sBAAsB,GAA5B,MAAM,sBAAsB;IAI/B,OAAO;QAEH,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;YACnB,IAAI,CAAC,UAAU,GAAG,IAAI,WAAI,EAAE,CAAC;QACjC,CAAC;QACD,OAAO,IAAI,CAAC,UAAU,CAAC;IAC3B,CAAC;CAEJ,CAAA;;iCAZY,sBAAsB;IADlC,IAAA,gBAAS,EAAC,oCAAkB,CAAC;GACjB,sBAAsB,CAYlC"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { Component } from '@celljs/core';
|
|
2
|
-
import { JexlEngineProvider } from './access-protocol';
|
|
3
|
-
import { Jexl } from 'jexl';
|
|
4
|
-
|
|
5
|
-
@Component(JexlEngineProvider)
|
|
6
|
-
export class JexlEngineProviderImpl implements JexlEngineProvider<any> {
|
|
7
|
-
|
|
8
|
-
protected jexlEngine: any;
|
|
9
|
-
|
|
10
|
-
provide(): any {
|
|
11
|
-
|
|
12
|
-
if (!this.jexlEngine) {
|
|
13
|
-
this.jexlEngine = new Jexl();
|
|
14
|
-
}
|
|
15
|
-
return this.jexlEngine;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
}
|