@celljs/security 4.0.0 → 4.2.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 +113 -1
- package/cell.yml +1 -2
- package/esm/browser/module.d.ts +1 -1
- package/esm/browser/user/behavior-subject.d.ts +16 -0
- package/esm/browser/user/behavior-subject.js +28 -0
- package/esm/browser/user/behavior-subject.js.map +1 -0
- package/esm/browser/user/index.d.ts +1 -0
- package/esm/browser/user/index.js +1 -0
- package/esm/browser/user/index.js.map +1 -1
- package/esm/browser/user/user-manager.d.ts +1 -1
- package/esm/browser/user/user-manager.js +2 -3
- package/esm/browser/user/user-manager.js.map +1 -1
- package/esm/browser/user/user-protocol.d.ts +1 -1
- 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 +1 -1
- package/esm/node/access/index.js +1 -1
- package/esm/node/access/index.js.map +1 -1
- package/esm/node/access/method-advice.js +3 -7
- package/esm/node/access/method-advice.js.map +1 -1
- package/esm/node/access/pattern-util.d.ts +8 -0
- package/esm/node/access/pattern-util.js +78 -0
- package/esm/node/access/pattern-util.js.map +1 -0
- package/esm/node/access/policy-provider.js +2 -3
- package/esm/node/access/policy-provider.js.map +1 -1
- package/esm/node/access/policy-resolver.d.ts +3 -2
- package/esm/node/access/policy-resolver.js +8 -11
- 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 -7
- 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/cache/request-cache.d.ts +2 -0
- package/esm/node/cache/request-cache.js +7 -2
- package/esm/node/cache/request-cache.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 +1 -2
- 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/browser/module.d.ts +1 -1
- package/lib/browser/user/behavior-subject.d.ts +17 -0
- package/lib/browser/user/behavior-subject.d.ts.map +1 -0
- package/lib/browser/user/behavior-subject.js +32 -0
- package/lib/browser/user/behavior-subject.js.map +1 -0
- package/lib/browser/user/behavior-subject.spec.d.ts +2 -0
- package/lib/browser/user/behavior-subject.spec.d.ts.map +1 -0
- package/lib/browser/user/behavior-subject.spec.js +20 -0
- package/lib/browser/user/behavior-subject.spec.js.map +1 -0
- package/lib/browser/user/index.d.ts +1 -0
- package/lib/browser/user/index.d.ts.map +1 -1
- package/lib/browser/user/index.js +1 -0
- package/lib/browser/user/index.js.map +1 -1
- package/lib/browser/user/user-manager.d.ts +1 -1
- package/lib/browser/user/user-manager.d.ts.map +1 -1
- package/lib/browser/user/user-manager.js +3 -4
- package/lib/browser/user/user-manager.js.map +1 -1
- package/lib/browser/user/user-protocol.d.ts +1 -1
- package/lib/browser/user/user-protocol.d.ts.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 +1 -1
- package/lib/node/access/index.d.ts.map +1 -1
- package/lib/node/access/index.js +1 -1
- package/lib/node/access/index.js.map +1 -1
- package/lib/node/access/method-advice.d.ts.map +1 -1
- package/lib/node/access/method-advice.js +2 -5
- package/lib/node/access/method-advice.js.map +1 -1
- package/lib/node/access/pattern-util.d.ts +9 -0
- package/lib/node/access/pattern-util.d.ts.map +1 -0
- package/lib/node/access/pattern-util.js +81 -0
- package/lib/node/access/pattern-util.js.map +1 -0
- package/lib/node/access/pattern-util.spec.d.ts +2 -0
- package/lib/node/access/pattern-util.spec.d.ts.map +1 -0
- package/lib/node/access/pattern-util.spec.js +35 -0
- package/lib/node/access/pattern-util.spec.js.map +1 -0
- package/lib/node/access/policy-provider.js +2 -2
- package/lib/node/access/policy-provider.js.map +1 -1
- package/lib/node/access/policy-resolver.d.ts +3 -2
- package/lib/node/access/policy-resolver.d.ts.map +1 -1
- package/lib/node/access/policy-resolver.js +6 -8
- 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 -5
- 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/cache/request-cache.d.ts +2 -0
- package/lib/node/cache/request-cache.d.ts.map +1 -1
- package/lib/node/cache/request-cache.js +7 -35
- package/lib/node/cache/request-cache.js.map +1 -1
- package/lib/node/cache/request-cache.spec.d.ts +2 -0
- package/lib/node/cache/request-cache.spec.d.ts.map +1 -0
- package/lib/node/cache/request-cache.spec.js +16 -0
- package/lib/node/cache/request-cache.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 +1 -2
- 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 +7 -17
- package/src/browser/user/behavior-subject.spec.ts +18 -0
- package/src/browser/user/behavior-subject.ts +36 -0
- package/src/browser/user/index.ts +2 -1
- package/src/browser/user/user-manager.ts +3 -5
- package/src/browser/user/user-protocol.ts +2 -2
- 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 +1 -1
- package/src/node/access/method-advice.ts +1 -2
- package/src/node/access/pattern-util.spec.ts +33 -0
- package/src/node/access/pattern-util.ts +71 -0
- package/src/node/access/policy-provider.ts +3 -3
- package/src/node/access/policy-resolver.ts +8 -10
- package/src/node/access/resource-name-resolver.ts +11 -7
- 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/cache/request-cache.spec.ts +14 -0
- package/src/node/cache/request-cache.ts +8 -3
- 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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource-name-resolver.js","sourceRoot":"","sources":["../../../src/node/access/resource-name-resolver.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAiC,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACxF,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"resource-name-resolver.js","sourceRoot":"","sources":["../../../src/node/access/resource-name-resolver.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAiC,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACxF,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAC7G,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAGxC,IAAM,2BAA2B,GAAjC,MAAM,2BAA2B;IAQ1B,QAAQ,CAAC,UAAkB,EAAE,GAAkC;QACrE,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;IACjD,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,GAAkC;QAC5C,MAAM,cAAc,GAAa,cAAc,CAAC,YAAY,CAAC,QAAQ,EAAE,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QAC/F,MAAM,eAAe,GAAa,cAAc,CAAC,YAAY,CAAC,QAAQ,EAAE,GAAG,CAAC,MAAM,CAAC,WAAW,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;QAC5G,IAAI,SAAS,GAAa,EAAE,CAAC;QAC7B,IAAI,cAAc,CAAC,M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C,SAAS,CAAC,oBAAoB,CAAC;GACnB,2BAA2B,CAsCvC"}
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
+
import { Logger } from '@celljs/core';
|
|
1
2
|
import { AuthenticationProvider, Authentication } from './authentication-protocol.js';
|
|
2
3
|
import { RequestMatcher, RedirectStrategy } from '@celljs/web/lib/node';
|
|
3
4
|
import { PasswordEncoder } from '../crypto/index.js';
|
|
4
5
|
import { UserService, UserChecker, UserMapper } from '../user/index.js';
|
|
5
6
|
import { PathResolver } from '@celljs/web';
|
|
6
7
|
import { User } from '../../common/index.js';
|
|
8
|
+
/**
|
|
9
|
+
* After a password matched: when its stored hash is in a legacy format and the UserService can store
|
|
10
|
+
* passwords, store a new hash of it. A failure is logged and does not fail the login.
|
|
11
|
+
*/
|
|
12
|
+
export declare function upgradePasswordHash(passwordEncoder: PasswordEncoder, userService: UserService<any, User>, user: User, rawPassword: string, logger: Logger): Promise<void>;
|
|
7
13
|
export declare class UsernamePasswordAuthenticationProvider implements AuthenticationProvider {
|
|
8
14
|
protected readonly options: any;
|
|
9
15
|
protected readonly passwordEncoder: PasswordEncoder;
|
|
@@ -13,6 +19,7 @@ export declare class UsernamePasswordAuthenticationProvider implements Authentic
|
|
|
13
19
|
protected readonly requestMatcher: RequestMatcher;
|
|
14
20
|
protected readonly pathResolver: PathResolver;
|
|
15
21
|
protected readonly redirectStrategy: RedirectStrategy;
|
|
22
|
+
protected readonly logger: Logger;
|
|
16
23
|
priority: number;
|
|
17
24
|
authenticate(): Promise<Authentication | undefined>;
|
|
18
25
|
protected doGetValue(key: string): string;
|
|
@@ -26,6 +33,7 @@ export declare class BasicAuthenticationProvider implements AuthenticationProvid
|
|
|
26
33
|
protected readonly requestMatcher: RequestMatcher;
|
|
27
34
|
protected readonly pathResolver: PathResolver;
|
|
28
35
|
protected readonly redirectStrategy: RedirectStrategy;
|
|
36
|
+
protected readonly logger: Logger;
|
|
29
37
|
priority: number;
|
|
30
38
|
authenticate(): Promise<Authentication | undefined>;
|
|
31
39
|
support(): Promise<boolean>;
|
|
@@ -7,7 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
9
|
};
|
|
10
|
-
import { Component, Autowired, Value } from '@celljs/core';
|
|
10
|
+
import { Component, Autowired, Value, Logger } from '@celljs/core';
|
|
11
11
|
import { AuthenticationProvider, USERNAME_PASSWORD_AUTHENTICATION_PROVIDER_PRIORITY, BASE_AUTHENTICATION_PROVIDER_PRIORITY, AUTHENTICATION_SCHEME_BASIC } from './authentication-protocol.js';
|
|
12
12
|
import { Context, RequestMatcher, RedirectStrategy } from '@celljs/web/lib/node';
|
|
13
13
|
import { PasswordEncoder } from '../crypto/index.js';
|
|
@@ -15,6 +15,23 @@ import { UserService, UserChecker, UserMapper } from '../user/index.js';
|
|
|
15
15
|
import { BadCredentialsError } from '../error/index.js';
|
|
16
16
|
import { HttpHeaders } from '@celljs/http';
|
|
17
17
|
import { PathResolver } from '@celljs/web';
|
|
18
|
+
/**
|
|
19
|
+
* After a password matched: when its stored hash is in a legacy format and the UserService can store
|
|
20
|
+
* passwords, store a new hash of it. A failure is logged and does not fail the login.
|
|
21
|
+
*/
|
|
22
|
+
export async function upgradePasswordHash(passwordEncoder, userService, user, rawPassword, logger) {
|
|
23
|
+
var _a;
|
|
24
|
+
var _b;
|
|
25
|
+
if (!userService.updatePassword || !((_a = passwordEncoder.needsUpgrade) === null || _a === void 0 ? void 0 : _a.call(passwordEncoder, user.password))) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
try {
|
|
29
|
+
await userService.updatePassword(user, await passwordEncoder.encode(rawPassword));
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
logger.warn(`Could not upgrade the password hash of ${user.username}: ${(_b = error === null || error === void 0 ? void 0 : error.message) !== null && _b !== void 0 ? _b : error}`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
18
35
|
let UsernamePasswordAuthenticationProvider = class UsernamePasswordAuthenticationProvider {
|
|
19
36
|
constructor() {
|
|
20
37
|
this.priority = USERNAME_PASSWORD_AUTHENTICATION_PROVIDER_PRIORITY;
|
|
@@ -30,6 +47,7 @@ let UsernamePasswordAuthenticationProvider = class UsernamePasswordAuthenticatio
|
|
|
30
47
|
if (!await this.passwordEncoder.matches(password, user.password)) {
|
|
31
48
|
throw new BadCredentialsError('Bad credentials');
|
|
32
49
|
}
|
|
50
|
+
await upgradePasswordHash(this.passwordEncoder, this.userService, user, password, this.logger);
|
|
33
51
|
await this.userMapper.map(user);
|
|
34
52
|
return {
|
|
35
53
|
name: user.username,
|
|
@@ -84,6 +102,10 @@ __decorate([
|
|
|
84
102
|
Autowired(RedirectStrategy),
|
|
85
103
|
__metadata("design:type", Object)
|
|
86
104
|
], UsernamePasswordAuthenticationProvider.prototype, "redirectStrategy", void 0);
|
|
105
|
+
__decorate([
|
|
106
|
+
Autowired(Logger),
|
|
107
|
+
__metadata("design:type", Object)
|
|
108
|
+
], UsernamePasswordAuthenticationProvider.prototype, "logger", void 0);
|
|
87
109
|
UsernamePasswordAuthenticationProvider = __decorate([
|
|
88
110
|
Component(AuthenticationProvider)
|
|
89
111
|
], UsernamePasswordAuthenticationProvider);
|
|
@@ -104,7 +126,7 @@ let BasicAuthenticationProvider = class BasicAuthenticationProvider {
|
|
|
104
126
|
throw new BadCredentialsError('Invalid basic authentication token');
|
|
105
127
|
}
|
|
106
128
|
const username = token.substring(0, delim);
|
|
107
|
-
const password = token.substring(delim);
|
|
129
|
+
const password = token.substring(delim + 1);
|
|
108
130
|
if (!password || !username) {
|
|
109
131
|
throw new BadCredentialsError('Bad credentials');
|
|
110
132
|
}
|
|
@@ -113,6 +135,7 @@ let BasicAuthenticationProvider = class BasicAuthenticationProvider {
|
|
|
113
135
|
if (!await this.passwordEncoder.matches(password, user.password)) {
|
|
114
136
|
throw new BadCredentialsError('Bad credentials');
|
|
115
137
|
}
|
|
138
|
+
await upgradePasswordHash(this.passwordEncoder, this.userService, user, password, this.logger);
|
|
116
139
|
await this.userMapper.map(user);
|
|
117
140
|
return {
|
|
118
141
|
name: user.username,
|
|
@@ -164,6 +187,10 @@ __decorate([
|
|
|
164
187
|
Autowired(RedirectStrategy),
|
|
165
188
|
__metadata("design:type", Object)
|
|
166
189
|
], BasicAuthenticationProvider.prototype, "redirectStrategy", void 0);
|
|
190
|
+
__decorate([
|
|
191
|
+
Autowired(Logger),
|
|
192
|
+
__metadata("design:type", Object)
|
|
193
|
+
], BasicAuthenticationProvider.prototype, "logger", void 0);
|
|
167
194
|
BasicAuthenticationProvider = __decorate([
|
|
168
195
|
Component(AuthenticationProvider)
|
|
169
196
|
], BasicAuthenticationProvider);
|
|
@@ -1 +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;
|
|
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,EAAE,MAAM,cAAc,CAAC;AACnE,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,M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YAC7E,OAAO,IAAI,CAAC;QAChB,CAAC;QACD,OAAO,KAAK,CAAC;IACjB,CAAC;CAEJ,CAAA;AA3EsB;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;AAGnC;IADlB,SAAS,CAAC,MAAM,CAAC;;2DACgB;AAxBzB,2BAA2B;IADvC,SAAS,CAAC,sBAAsB,CAAC;GACrB,2BAA2B,CA8EvC"}
|
|
@@ -14,6 +14,10 @@ import { HttpHeaders, XML_HTTP_REQUEST } from '@celljs/http';
|
|
|
14
14
|
import { RequestCache } from '../cache/index.js';
|
|
15
15
|
let DefaultAuthenticationSuccessHandler = class DefaultAuthenticationSuccessHandler {
|
|
16
16
|
async onAuthenticationSuccess(authentication) {
|
|
17
|
+
// Authentication that goes on to the requested resource (Basic): nothing to redirect to.
|
|
18
|
+
if (authentication.next) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
17
21
|
const response = Context.getResponse();
|
|
18
22
|
if (Context.getRequest().get(HttpHeaders.X_REQUESTED_WITH) === XML_HTTP_REQUEST) {
|
|
19
23
|
return;
|
|
@@ -1 +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,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BACvE,OAAO,SAAS,CAAC;YACrB,CAAC;QACL,CAAC;QAED,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YAClB,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;YACjD,SAAS,GAAG,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,MAAM,EAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAC9C,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,yBAAyB,SAAS,EAAE,CAAC,CAAC;QAC5D,CAAC;QAED,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,GAAG,EAAE,CAAC;QACnD,IAAI,YAAY,EAAE,CAAC;YACf,MAAM,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC;YACjC,SAAS,GAAG,YAAY,CAAC,WAAW,CAAC;YACrC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,oCAAoC,SAAS,EAAE,CAAC,CAAC;QACvE,CAAC;QAED,IAAI,CAAC,SAAS,EAAE,CAAC;YACb,SAAS,GAAG,IAAI,CAAC,eAAe,CAAC;YACjC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,sBAAsB,SAAS,EAAE,CAAC,CAAC;QACzD,CAAC;QAED,OAAO,SAAS,CAAC;IACrB,CAAC;CAEJ,CAAA;
|
|
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,gBAA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C;IAD/C,SAAS,CAAC,4BAA4B,CAAC;GAC3B,mCAAmC,CA+E/C"}
|
|
@@ -4,6 +4,8 @@ export declare class HttpSessionRequestCache implements RequestCache {
|
|
|
4
4
|
protected readonly endpoint: string;
|
|
5
5
|
protected readonly pathResolver: PathResolver;
|
|
6
6
|
save(savedRequest?: SavedRequest): Promise<void>;
|
|
7
|
+
/** `?a=1` of the URL as the client sent it, or `''`. */
|
|
8
|
+
protected queryString(url?: string): string;
|
|
7
9
|
get(): Promise<SavedRequest | undefined>;
|
|
8
10
|
remove(): Promise<void>;
|
|
9
11
|
}
|
|
@@ -11,18 +11,23 @@ import { RequestCache, SAVED_REQUEST } from './cache-protocol.js';
|
|
|
11
11
|
import { AttributeScope, Context } from '@celljs/web/lib/node';
|
|
12
12
|
import { Component, Value, Autowired } from '@celljs/core';
|
|
13
13
|
import { ENDPOINT, PathResolver } from '@celljs/web';
|
|
14
|
-
import * as qs from 'qs';
|
|
15
14
|
let HttpSessionRequestCache = class HttpSessionRequestCache {
|
|
16
15
|
async save(savedRequest) {
|
|
16
|
+
var _a;
|
|
17
17
|
if (Context.getSession()) {
|
|
18
18
|
const request = Context.getRequest();
|
|
19
19
|
Context.setAttr(SAVED_REQUEST, savedRequest || {
|
|
20
|
-
redirectUrl: await this.pathResolver.resolve(this.endpoint, request.path,
|
|
20
|
+
redirectUrl: await this.pathResolver.resolve(this.endpoint, request.path, this.queryString((_a = request.originalUrl) !== null && _a !== void 0 ? _a : request.url)),
|
|
21
21
|
method: request.method.toUpperCase(),
|
|
22
22
|
query: { ...request.query }
|
|
23
23
|
}, AttributeScope.Session);
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
+
/** `?a=1` of the URL as the client sent it, or `''`. */
|
|
27
|
+
queryString(url = '') {
|
|
28
|
+
const index = url.indexOf('?');
|
|
29
|
+
return index < 0 || index === url.length - 1 ? '' : url.slice(index);
|
|
30
|
+
}
|
|
26
31
|
async get() {
|
|
27
32
|
if (Context.getSession()) {
|
|
28
33
|
return Context.getAttr(SAVED_REQUEST, AttributeScope.Session);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request-cache.js","sourceRoot":"","sources":["../../../src/node/cache/request-cache.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,YAAY,EAAgB,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC7E,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"request-cache.js","sourceRoot":"","sources":["../../../src/node/cache/request-cache.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,YAAY,EAAgB,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC7E,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAG9C,IAAM,uBAAuB,GAA7B,MAAM,uBAAuB;IAQhC,KAAK,CAAC,IAAI,CAAC,YAA2B;;QAClC,IAAI,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC;YACvB,MAAM,OAAO,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;YACrC,OAAO,CAAC,OAAO,CAAC,aAAa,EAAE,YAAY,IAAI;gBAC3C,WAAW,EAAE,MAAM,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,OAAC,OAAO,CAAC,WAAW,mCAAI,OAAO,CAAC,GAAG,CAAC,CAAC;gBAC/H,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE;gBACpC,KAAK,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,EAAE;aAC9B,EAAE,cAAc,CAAC,OAAO,CAAC,CAAC;QAC/B,CAAC;IACL,CAAC;IACD,wDAAwD;IAC9C,WAAW,CAAC,GAAG,GAAG,EAAE;QAC1B,MAAM,KAAK,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAC/B,OAAO,KAAK,GAAG,CAAC,IAAI,KAAK,KAAK,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACzE,CAAC;IAED,KAAK,CAAC,GAAG;QACL,IAAI,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC;YACvB,OAAO,OAAO,CAAC,OAAO,CAAe,aAAa,EAAE,cAAc,CAAC,OAAO,CAAC,CAAC;QAChF,CAAC;IACL,CAAC;IAED,KAAK,CAAC,MAAM;QACR,IAAI,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC;YACvB,OAAO,CAAC,OAAO,CAAC,aAAa,EAAE,SAAS,EAAE,cAAc,CAAC,OAAO,CAAC,CAAC;QACtE,CAAC;IACL,CAAC;CAEJ,CAAA;AAjCsB;IADlB,KAAK,CAAC,QAAQ,CAAC;;yDACoB;AAGjB;IADlB,SAAS,CAAC,YAAY,CAAC;;6DACsB;AANrC,uBAAuB;IADnC,SAAS,CAAC,YAAY,CAAC;GACX,uBAAuB,CAoCnC"}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { StringKeyGenerator } from './keygen-protocol.js';
|
|
2
|
+
/**
|
|
3
|
+
* Random keys (OAuth2 `state`, PKCE `code_verifier`, OIDC `nonce`) in base64url without padding,
|
|
4
|
+
* so they can go into a URL as they are (RFC 7636 §4.1 allows only unreserved characters).
|
|
5
|
+
*/
|
|
2
6
|
export declare class Base64StringKeyGenerator implements StringKeyGenerator {
|
|
3
7
|
protected readonly keyLength: number;
|
|
4
8
|
generateKey(keyLength?: number): Promise<string>;
|
|
@@ -7,14 +7,16 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
9
|
};
|
|
10
|
+
import { randomBytes } from 'node:crypto';
|
|
10
11
|
import { StringKeyGenerator } from './keygen-protocol.js';
|
|
11
|
-
import __cellCjs1 from 'crypto-js';
|
|
12
|
-
const { enc, lib } = __cellCjs1;
|
|
13
12
|
import { Value, Component } from '@celljs/core';
|
|
13
|
+
/**
|
|
14
|
+
* Random keys (OAuth2 `state`, PKCE `code_verifier`, OIDC `nonce`) in base64url without padding,
|
|
15
|
+
* so they can go into a URL as they are (RFC 7636 §4.1 allows only unreserved characters).
|
|
16
|
+
*/
|
|
14
17
|
let Base64StringKeyGenerator = class Base64StringKeyGenerator {
|
|
15
18
|
async generateKey(keyLength) {
|
|
16
|
-
|
|
17
|
-
return enc.Base64.stringify(key);
|
|
19
|
+
return randomBytes(keyLength || this.keyLength).toString('base64url');
|
|
18
20
|
}
|
|
19
21
|
};
|
|
20
22
|
__decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base64-string-key-generator.js","sourceRoot":"","sources":["../../../../src/node/crypto/keygen/base64-string-key-generator.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"base64-string-key-generator.js","sourceRoot":"","sources":["../../../../src/node/crypto/keygen/base64-string-key-generator.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEhD;;;GAGG;AAEI,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;IAKjC,KAAK,CAAC,WAAW,CAAC,SAAkB;QAChC,OAAO,WAAW,CAAC,SAAS,IAAI,IAAI,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;IAC1E,CAAC;CACJ,CAAA;AALsB;IADlB,KAAK,CAAC,qCAAqC,CAAC;;2DACR;AAH5B,wBAAwB;IADpC,SAAS,CAAC,kBAAkB,CAAC;GACjB,wBAAwB,CAQpC"}
|
|
@@ -1,8 +1,45 @@
|
|
|
1
1
|
import { PasswordEncoder } from './password-protocol.js';
|
|
2
|
+
export interface Pbkdf2PasswordEncoderOptions {
|
|
3
|
+
/** Optional pepper. New hashes mix it into the salt when it is set; legacy hashes were made with `String(secret)`. */
|
|
4
|
+
secret?: string | number;
|
|
5
|
+
/** Legacy hashes only: they are base64 of the hex text. */
|
|
6
|
+
encodeHashAsBase64?: boolean;
|
|
7
|
+
/** Legacy hashes only: PBKDF2 iterations they were made with. Default 250000 (crypto-js 4.2.0). */
|
|
8
|
+
iterations?: number;
|
|
9
|
+
/** Legacy hashes only: derived key length in 32-bit words. Default 4 (16 bytes, crypto-js 4.2.0). */
|
|
10
|
+
keySize?: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Password hashes with PBKDF2-HMAC-SHA256 on node:crypto, compared in constant time.
|
|
14
|
+
*
|
|
15
|
+
* New hashes: `pbkdf2-sha256$<iterations>$<salt, base64>$<key, base64>` with 600000 iterations, a 16-byte
|
|
16
|
+
* random salt (followed by the UTF-8 bytes of `secret` when one is set) and a 32-byte key.
|
|
17
|
+
*
|
|
18
|
+
* Legacy hashes (no prefix), as the crypto-js 4.2.0 implementation of 4.x stored them, keep matching:
|
|
19
|
+
* optionally base64 of a text that is a 16-character hex salt followed by the hex key; the key is
|
|
20
|
+
* PBKDF2(password, salt + String(secret)) with SHA-256, `iterations` (default 250000) and `keySize` words
|
|
21
|
+
* (default 4). Without a secret the salt text ends in `undefined`, which is how those hashes were made.
|
|
22
|
+
* Hashes made with crypto-js 4.1 or older (SHA-1, 1 iteration) are not supported.
|
|
23
|
+
* {@link needsUpgrade} is true for legacy hashes, so a login replaces them with a new hash.
|
|
24
|
+
*/
|
|
2
25
|
export declare class Pbkdf2PasswordEncoder implements PasswordEncoder {
|
|
3
|
-
|
|
26
|
+
static readonly PREFIX = "pbkdf2-sha256";
|
|
27
|
+
static readonly ITERATIONS = 600000;
|
|
28
|
+
static readonly SALT_BYTES = 16;
|
|
29
|
+
static readonly KEY_BYTES = 32;
|
|
30
|
+
static readonly LEGACY_ITERATIONS = 250000;
|
|
31
|
+
static readonly LEGACY_KEY_SIZE = 4;
|
|
32
|
+
static readonly LEGACY_SALT_LENGTH = 16;
|
|
33
|
+
protected readonly options: Pbkdf2PasswordEncoderOptions | undefined;
|
|
34
|
+
/** Iterations of new hashes. */
|
|
35
|
+
protected get iterations(): number;
|
|
4
36
|
encode(rawPassword: string): Promise<string>;
|
|
5
|
-
protected doEncode(rawPassword: string, salt: string): string;
|
|
6
37
|
matches(rawPassword: string, encodedPassword: string): Promise<boolean>;
|
|
7
|
-
|
|
38
|
+
needsUpgrade(encodedPassword: string): boolean;
|
|
39
|
+
protected isCurrent(encodedPassword: string): boolean;
|
|
40
|
+
protected pepper(salt: Buffer): Buffer;
|
|
41
|
+
protected matchesCurrent(rawPassword: string, encodedPassword: string): Promise<boolean>;
|
|
42
|
+
protected matchesLegacy(rawPassword: string, encodedPassword: string): Promise<boolean>;
|
|
43
|
+
/** The text the crypto-js implementation stored (before the optional base64): salt + hex key. */
|
|
44
|
+
protected legacyEncode(rawPassword: string, salt: string): Promise<string>;
|
|
8
45
|
}
|
|
@@ -7,42 +7,98 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
9
|
};
|
|
10
|
-
|
|
11
|
-
import
|
|
12
|
-
|
|
10
|
+
var Pbkdf2PasswordEncoder_1;
|
|
11
|
+
import { pbkdf2, randomBytes, timingSafeEqual } from 'node:crypto';
|
|
12
|
+
import { promisify } from 'node:util';
|
|
13
13
|
import { Value, Component } from '@celljs/core';
|
|
14
|
-
|
|
14
|
+
import { PasswordEncoder } from './password-protocol.js';
|
|
15
|
+
const pbkdf2Async = promisify(pbkdf2);
|
|
16
|
+
/**
|
|
17
|
+
* Password hashes with PBKDF2-HMAC-SHA256 on node:crypto, compared in constant time.
|
|
18
|
+
*
|
|
19
|
+
* New hashes: `pbkdf2-sha256$<iterations>$<salt, base64>$<key, base64>` with 600000 iterations, a 16-byte
|
|
20
|
+
* random salt (followed by the UTF-8 bytes of `secret` when one is set) and a 32-byte key.
|
|
21
|
+
*
|
|
22
|
+
* Legacy hashes (no prefix), as the crypto-js 4.2.0 implementation of 4.x stored them, keep matching:
|
|
23
|
+
* optionally base64 of a text that is a 16-character hex salt followed by the hex key; the key is
|
|
24
|
+
* PBKDF2(password, salt + String(secret)) with SHA-256, `iterations` (default 250000) and `keySize` words
|
|
25
|
+
* (default 4). Without a secret the salt text ends in `undefined`, which is how those hashes were made.
|
|
26
|
+
* Hashes made with crypto-js 4.1 or older (SHA-1, 1 iteration) are not supported.
|
|
27
|
+
* {@link needsUpgrade} is true for legacy hashes, so a login replaces them with a new hash.
|
|
28
|
+
*/
|
|
29
|
+
let Pbkdf2PasswordEncoder = Pbkdf2PasswordEncoder_1 = class Pbkdf2PasswordEncoder {
|
|
30
|
+
/** Iterations of new hashes. */
|
|
31
|
+
get iterations() {
|
|
32
|
+
return Pbkdf2PasswordEncoder_1.ITERATIONS;
|
|
33
|
+
}
|
|
15
34
|
async encode(rawPassword) {
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
35
|
+
const salt = randomBytes(Pbkdf2PasswordEncoder_1.SALT_BYTES);
|
|
36
|
+
const key = await pbkdf2Async(rawPassword, this.pepper(salt), this.iterations, Pbkdf2PasswordEncoder_1.KEY_BYTES, 'sha256');
|
|
37
|
+
return [Pbkdf2PasswordEncoder_1.PREFIX, this.iterations, salt.toString('base64'), key.toString('base64')].join('$');
|
|
38
|
+
}
|
|
39
|
+
async matches(rawPassword, encodedPassword) {
|
|
40
|
+
if (typeof encodedPassword !== 'string' || typeof rawPassword !== 'string') {
|
|
41
|
+
return false;
|
|
21
42
|
}
|
|
22
|
-
return
|
|
43
|
+
return this.isCurrent(encodedPassword) ? this.matchesCurrent(rawPassword, encodedPassword) : this.matchesLegacy(rawPassword, encodedPassword);
|
|
23
44
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
45
|
+
needsUpgrade(encodedPassword) {
|
|
46
|
+
if (!this.isCurrent(encodedPassword)) {
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
return Number(encodedPassword.split('$')[1]) < this.iterations;
|
|
27
50
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
51
|
+
isCurrent(encodedPassword) {
|
|
52
|
+
return encodedPassword.startsWith(`${Pbkdf2PasswordEncoder_1.PREFIX}$`);
|
|
53
|
+
}
|
|
54
|
+
pepper(salt) {
|
|
55
|
+
var _a;
|
|
56
|
+
const secret = (_a = this.options) === null || _a === void 0 ? void 0 : _a.secret;
|
|
57
|
+
return secret === undefined || secret === null || secret === '' ? salt : Buffer.concat([salt, Buffer.from(String(secret), 'utf8')]);
|
|
58
|
+
}
|
|
59
|
+
async matchesCurrent(rawPassword, encodedPassword) {
|
|
60
|
+
const [, iterationsText, saltText, keyText, ...rest] = encodedPassword.split('$');
|
|
61
|
+
const iterations = Number(iterationsText);
|
|
62
|
+
if (rest.length > 0 || !Number.isSafeInteger(iterations) || iterations < 1 || !saltText || !keyText) {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
const expected = Buffer.from(keyText, 'base64');
|
|
66
|
+
if (expected.length !== Pbkdf2PasswordEncoder_1.KEY_BYTES) {
|
|
67
|
+
return false;
|
|
37
68
|
}
|
|
38
|
-
|
|
69
|
+
const actual = await pbkdf2Async(rawPassword, this.pepper(Buffer.from(saltText, 'base64')), iterations, Pbkdf2PasswordEncoder_1.KEY_BYTES, 'sha256');
|
|
70
|
+
return timingSafeEqual(actual, expected);
|
|
71
|
+
}
|
|
72
|
+
async matchesLegacy(rawPassword, encodedPassword) {
|
|
73
|
+
var _a;
|
|
74
|
+
const digested = ((_a = this.options) === null || _a === void 0 ? void 0 : _a.encodeHashAsBase64) ? Buffer.from(encodedPassword, 'base64').toString('utf8') : encodedPassword;
|
|
75
|
+
if (digested.length <= Pbkdf2PasswordEncoder_1.LEGACY_SALT_LENGTH) {
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
const expected = Buffer.from(await this.legacyEncode(rawPassword, digested.substring(0, Pbkdf2PasswordEncoder_1.LEGACY_SALT_LENGTH)), 'utf8');
|
|
79
|
+
const actual = Buffer.from(digested, 'utf8');
|
|
80
|
+
return actual.length === expected.length && timingSafeEqual(actual, expected);
|
|
81
|
+
}
|
|
82
|
+
/** The text the crypto-js implementation stored (before the optional base64): salt + hex key. */
|
|
83
|
+
async legacyEncode(rawPassword, salt) {
|
|
84
|
+
var _a;
|
|
85
|
+
const { secret, iterations, keySize } = (_a = this.options) !== null && _a !== void 0 ? _a : {};
|
|
86
|
+
const key = await pbkdf2Async(rawPassword, `${salt}${secret}`, Number(iterations !== null && iterations !== void 0 ? iterations : Pbkdf2PasswordEncoder_1.LEGACY_ITERATIONS), Number(keySize !== null && keySize !== void 0 ? keySize : Pbkdf2PasswordEncoder_1.LEGACY_KEY_SIZE) * 4, 'sha256');
|
|
87
|
+
return salt + key.toString('hex');
|
|
39
88
|
}
|
|
40
89
|
};
|
|
90
|
+
Pbkdf2PasswordEncoder.PREFIX = 'pbkdf2-sha256';
|
|
91
|
+
Pbkdf2PasswordEncoder.ITERATIONS = 600000;
|
|
92
|
+
Pbkdf2PasswordEncoder.SALT_BYTES = 16;
|
|
93
|
+
Pbkdf2PasswordEncoder.KEY_BYTES = 32;
|
|
94
|
+
Pbkdf2PasswordEncoder.LEGACY_ITERATIONS = 250000;
|
|
95
|
+
Pbkdf2PasswordEncoder.LEGACY_KEY_SIZE = 4;
|
|
96
|
+
Pbkdf2PasswordEncoder.LEGACY_SALT_LENGTH = 16;
|
|
41
97
|
__decorate([
|
|
42
98
|
Value('cell.security.passwordEncoder'),
|
|
43
99
|
__metadata("design:type", Object)
|
|
44
100
|
], Pbkdf2PasswordEncoder.prototype, "options", void 0);
|
|
45
|
-
Pbkdf2PasswordEncoder = __decorate([
|
|
101
|
+
Pbkdf2PasswordEncoder = Pbkdf2PasswordEncoder_1 = __decorate([
|
|
46
102
|
Component(PasswordEncoder)
|
|
47
103
|
], Pbkdf2PasswordEncoder);
|
|
48
104
|
export { Pbkdf2PasswordEncoder };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"password-encoder.js","sourceRoot":"","sources":["../../../../src/node/crypto/password/password-encoder.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"password-encoder.js","sourceRoot":"","sources":["../../../../src/node/crypto/password/password-encoder.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,MAAM,WAAW,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC;AAatC;;;;;;;;;;;;GAYG;AAEI,IAAM,qBAAqB,6BAA3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CACX,CAAC;QACF,OAAO,IAAI,GAAG,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACtC,CAAC;CACJ,CAAA;AAlFmB,4BAAM,GAAG,eAAe,AAAlB,CAAmB;AACzB,gCAAU,GAAG,MAAM,AAAT,CAAU;AACpB,gCAAU,GAAG,EAAE,AAAL,CAAM;AAChB,+BAAS,GAAG,EAAE,AAAL,CAAM;AAEf,uCAAiB,GAAG,MAAM,AAAT,CAAU;AAC3B,qCAAe,GAAG,CAAC,AAAJ,CAAK;AACpB,wCAAkB,GAAG,EAAE,AAAL,CAAM;AAGrB;IADlB,KAAK,CAAC,+BAA+B,CAAC;;sDAC8B;AAZ5D,qBAAqB;IADjC,SAAS,CAAC,eAAe,CAAC;GACd,qBAAqB,CAoFjC"}
|
|
@@ -2,4 +2,10 @@ export declare const PasswordEncoder: unique symbol;
|
|
|
2
2
|
export interface PasswordEncoder {
|
|
3
3
|
encode(rawPassword: string): Promise<string>;
|
|
4
4
|
matches(rawPassword: string, encodedPassword: string): Promise<boolean>;
|
|
5
|
+
/**
|
|
6
|
+
* Whether a stored hash should be replaced by `encode()` of the password once it matched (a legacy
|
|
7
|
+
* format, or weaker parameters than new hashes get). Login does so when the UserService can
|
|
8
|
+
* store passwords (`UserService.updatePassword`).
|
|
9
|
+
*/
|
|
10
|
+
needsUpgrade?(encodedPassword: string): boolean;
|
|
5
11
|
}
|
package/esm/node/module.d.ts
CHANGED
package/esm/node/module.js
CHANGED
package/esm/node/module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.js","sourceRoot":"","sources":["../../src/node/module.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"module.js","sourceRoot":"","sources":["../../src/node/module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,SAAS,CAAC;AAEjB,eAAe,QAAQ,EAAE,CAAC"}
|
|
@@ -5,6 +5,11 @@ export declare const UserMapper: unique symbol;
|
|
|
5
5
|
export declare const USER_MIDDLEWARE_PRIORITY: number;
|
|
6
6
|
export interface UserService<R, U extends User> {
|
|
7
7
|
load(userRequest: R): Promise<U>;
|
|
8
|
+
/**
|
|
9
|
+
* Stores a new password hash of `user`. Optional: when a service has it, a login whose stored hash
|
|
10
|
+
* `PasswordEncoder.needsUpgrade()` saves the hash in the current format.
|
|
11
|
+
*/
|
|
12
|
+
updatePassword?(user: U, encodedPassword: string): Promise<void>;
|
|
8
13
|
}
|
|
9
14
|
export interface UserChecker {
|
|
10
15
|
check(user: User): Promise<void>;
|
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
import { UserService } from './user-protocol.js';
|
|
2
|
+
import { Logger, ApplicationLifecycle, Application } from '@celljs/core';
|
|
2
3
|
import { User } from '../../common/index.js';
|
|
4
|
+
/** The one user of `cell.security.username` / `password`, when they are configured. */
|
|
3
5
|
export declare class UserServiceImpl implements UserService<string, User> {
|
|
4
6
|
protected readonly options: any;
|
|
7
|
+
/** Whether `cell.security` configures a user. */
|
|
8
|
+
get hasConfiguredUser(): boolean;
|
|
5
9
|
load(username: string): Promise<User>;
|
|
6
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* Warns at startup when the login (form or Basic) has no user to check: the default UserService is in
|
|
13
|
+
* use and `cell.security` configures no user. A warning, not an error: an application may log in with
|
|
14
|
+
* OAuth2 only, or use @celljs/security for authorization alone.
|
|
15
|
+
*/
|
|
16
|
+
export declare class UserSourceCheck implements ApplicationLifecycle<Application> {
|
|
17
|
+
protected readonly userService: UserService<string, User>;
|
|
18
|
+
protected readonly logger: Logger;
|
|
19
|
+
initialize(): void;
|
|
20
|
+
}
|
|
@@ -8,12 +8,18 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
8
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
9
|
};
|
|
10
10
|
import { UserService } from './user-protocol.js';
|
|
11
|
-
import { Value, Component } from '@celljs/core';
|
|
11
|
+
import { Value, Component, Autowired, Logger, ApplicationLifecycle } from '@celljs/core';
|
|
12
12
|
import { UsernameNotFoundError } from '../error/index.js';
|
|
13
13
|
import { UserType } from '../../common/index.js';
|
|
14
|
+
/** The one user of `cell.security.username` / `password`, when they are configured. */
|
|
14
15
|
let UserServiceImpl = class UserServiceImpl {
|
|
16
|
+
/** Whether `cell.security` configures a user. */
|
|
17
|
+
get hasConfiguredUser() {
|
|
18
|
+
var _a, _b;
|
|
19
|
+
return !!((_a = this.options) === null || _a === void 0 ? void 0 : _a.username) && !!((_b = this.options) === null || _b === void 0 ? void 0 : _b.password);
|
|
20
|
+
}
|
|
15
21
|
async load(username) {
|
|
16
|
-
if (this.options.username === username) {
|
|
22
|
+
if (this.hasConfiguredUser && this.options.username === username) {
|
|
17
23
|
return {
|
|
18
24
|
type: UserType.Memery,
|
|
19
25
|
username,
|
|
@@ -36,4 +42,29 @@ UserServiceImpl = __decorate([
|
|
|
36
42
|
Component(UserService)
|
|
37
43
|
], UserServiceImpl);
|
|
38
44
|
export { UserServiceImpl };
|
|
45
|
+
/**
|
|
46
|
+
* Warns at startup when the login (form or Basic) has no user to check: the default UserService is in
|
|
47
|
+
* use and `cell.security` configures no user. A warning, not an error: an application may log in with
|
|
48
|
+
* OAuth2 only, or use @celljs/security for authorization alone.
|
|
49
|
+
*/
|
|
50
|
+
let UserSourceCheck = class UserSourceCheck {
|
|
51
|
+
initialize() {
|
|
52
|
+
if (this.userService instanceof UserServiceImpl && !this.userService.hasConfiguredUser) {
|
|
53
|
+
this.logger.warn('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
|
+
__decorate([
|
|
59
|
+
Autowired(UserService),
|
|
60
|
+
__metadata("design:type", Object)
|
|
61
|
+
], UserSourceCheck.prototype, "userService", void 0);
|
|
62
|
+
__decorate([
|
|
63
|
+
Autowired(Logger),
|
|
64
|
+
__metadata("design:type", Object)
|
|
65
|
+
], UserSourceCheck.prototype, "logger", void 0);
|
|
66
|
+
UserSourceCheck = __decorate([
|
|
67
|
+
Component(ApplicationLifecycle)
|
|
68
|
+
], UserSourceCheck);
|
|
69
|
+
export { UserSourceCheck };
|
|
39
70
|
//# sourceMappingURL=user-service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-service.js","sourceRoot":"","sources":["../../../src/node/user/user-service.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"user-service.js","sourceRoot":"","sources":["../../../src/node/user/user-service.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,oBAAoB,EAAe,MAAM,cAAc,CAAC;AACtG,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,EAAQ,QAAQ,EAAE,MAAM,cAAc,CAAC;AAE9C,uFAAuF;AAEhF,IAAM,eAAe,GAArB,MAAM,eAAe;IAKxB,iDAAiD;IACjD,IAAI,iBAAiB;;QACjB,OAAO,CAAC,EAAC,MAAA,IAAI,CAAC,OAAO,0CAAE,QAAQ,CAAA,IAAI,CAAC,EAAC,MAAA,IAAI,CAAC,OAAO,0CAAE,QAAQ,CAAA,CAAC;IAChE,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,QAAgB;QACvB,IAAI,IAAI,CAAC,iBAAiB,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;YAC/D,OAAO;gBACH,IAAI,EAAE,QAAQ,CAAC,MAAM;gBACrB,QAAQ;gBACR,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ;gBAC/B,iBAAiB,EAAE,IAAI;gBACvB,gBAAgB,EAAE,IAAI;gBACtB,qBAAqB,EAAE,IAAI;gBAC3B,OAAO,EAAE,IAAI;gBACb,QAAQ,EAAE,EAAE;aACf,CAAC;QACN,CAAC;QAED,MAAM,IAAI,qBAAqB,CAAC,mBAAmB,QAAQ,EAAE,CAAC,CAAC;IACnE,CAAC;CACJ,CAAA;AAvBsB;IADlB,KAAK,CAAC,eAAe,CAAC;;gDACS;AAHvB,eAAe;IAD3B,SAAS,CAAC,WAAW,CAAC;GACV,eAAe,CA0B3B;;AAED;;;;GAIG;AAEI,IAAM,eAAe,GAArB,MAAM,eAAe;IAQxB,UAAU;QACN,IAAI,IAAI,CAAC,WAAW,YAAY,eAAe,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,iBAAiB,EAAE,CAAC;YACrF,IAAI,CAAC,MAAM,CAAC,IAAI,CACZ,mHAAmH;gBACnH,sFAAsF,CACzF,CAAC;QACN,CAAC;IACL,CAAC;CACJ,CAAA;AAbsB;IADlB,SAAS,CAAC,WAAW,CAAC;;oDACmC;AAGvC;IADlB,SAAS,CAAC,MAAM,CAAC;;+CACgB;AANzB,eAAe;IAD3B,SAAS,CAAC,oBAAoB,CAAC;GACnB,eAAe,CAgB3B"}
|
package/lib/browser/module.d.ts
CHANGED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface Subscription {
|
|
2
|
+
unsubscribe(): void;
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* A value that tells its subscribers when it changes, and tells a new subscriber the current value at once
|
|
6
|
+
* (the part of the rxjs `BehaviorSubject` that Cell uses).
|
|
7
|
+
*/
|
|
8
|
+
export declare class BehaviorSubject<T> {
|
|
9
|
+
protected current: T;
|
|
10
|
+
protected readonly listeners: Set<(value: T) => void>;
|
|
11
|
+
constructor(current: T);
|
|
12
|
+
get value(): T;
|
|
13
|
+
getValue(): T;
|
|
14
|
+
next(value: T): void;
|
|
15
|
+
subscribe(listener: (value: T) => void): Subscription;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=behavior-subject.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"behavior-subject.d.ts","sourceRoot":"","sources":["../../../src/browser/user/behavior-subject.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IACzB,WAAW,IAAI,IAAI,CAAC;CACvB;AAED;;;GAGG;AACH,qBAAa,eAAe,CAAC,CAAC;IAId,SAAS,CAAC,OAAO,EAAE,CAAC;IAFhC,SAAS,CAAC,QAAQ,CAAC,SAAS,cAAmB,CAAC,KAAK,IAAI,EAAI;IAE7D,YAAsB,OAAO,EAAE,CAAC,EAC/B;IAED,IAAI,KAAK,IAAI,CAAC,CAEb;IAED,QAAQ,IAAI,CAAC,CAEZ;IAED,IAAI,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,CAKnB;IAED,SAAS,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,GAAG,YAAY,CAIpD;CACJ"}
|