@feathersjs/authentication 5.0.0-pre.15 → 5.0.0-pre.18

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/CHANGELOG.md CHANGED
@@ -3,6 +3,37 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [5.0.0-pre.18](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.17...v5.0.0-pre.18) (2022-04-11)
7
+
8
+
9
+ ### Features
10
+
11
+ * **authentication:** Add setup method for auth strategies ([#1611](https://github.com/feathersjs/feathers/issues/1611)) ([a3c3581](https://github.com/feathersjs/feathers/commit/a3c35814dccdbbf6de96f04f60b226ce206c6dbe))
12
+ * **configuration:** Allow app configuration to be validated against a schema ([#2590](https://github.com/feathersjs/feathers/issues/2590)) ([a268f86](https://github.com/feathersjs/feathers/commit/a268f86da92a8ada14ed11ab456aac0a4bba5bb0))
13
+
14
+
15
+
16
+
17
+
18
+ # [5.0.0-pre.17](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.16...v5.0.0-pre.17) (2022-02-15)
19
+
20
+ **Note:** Version bump only for package @feathersjs/authentication
21
+
22
+
23
+
24
+
25
+
26
+ # [5.0.0-pre.16](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.15...v5.0.0-pre.16) (2022-01-12)
27
+
28
+
29
+ ### Features
30
+
31
+ * **express, koa:** make transports similar ([#2486](https://github.com/feathersjs/feathers/issues/2486)) ([26aa937](https://github.com/feathersjs/feathers/commit/26aa937c114fb8596dfefc599b1f53cead69c159))
32
+
33
+
34
+
35
+
36
+
6
37
  # [5.0.0-pre.15](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.14...v5.0.0-pre.15) (2021-11-27)
7
38
 
8
39
 
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2021 Feathers
3
+ Copyright (c) 2022 Feathers
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # @feathersjs/authentication
2
2
 
3
3
  [![CI](https://github.com/feathersjs/feathers/workflows/CI/badge.svg)](https://github.com/feathersjs/feathers/actions?query=workflow%3ACI)
4
- [![Dependency Status](https://img.shields.io/david/feathersjs/feathers.svg?style=flat-square&path=packages/authentication)](https://david-dm.org/feathersjs/feathers?path=packages/authentication)
5
4
  [![Download Status](https://img.shields.io/npm/dm/@feathersjs/authentication.svg?style=flat-square)](https://www.npmjs.com/package/@feathersjs/authentication)
5
+ [![Discord](https://badgen.net/badge/icon/discord?icon=discord&label)](https://discord.gg/qa8kez8QBx)
6
6
 
7
7
  > Add Authentication to your FeathersJS app.
8
8
 
@@ -18,6 +18,6 @@ Refer to the [Feathers authentication API documentation](https://docs.feathersjs
18
18
 
19
19
  ## License
20
20
 
21
- Copyright (c) 2021 [Feathers contributors](https://github.com/feathersjs/feathers/graphs/contributors)
21
+ Copyright (c) 2022 [Feathers contributors](https://github.com/feathersjs/feathers/graphs/contributors)
22
22
 
23
23
  Licensed under the [MIT license](LICENSE).
package/lib/core.d.ts CHANGED
@@ -34,6 +34,12 @@ export interface AuthenticationStrategy {
34
34
  * and throw an error if it is invalid.
35
35
  */
36
36
  verifyConfiguration?(): void;
37
+ /**
38
+ * Implement this method to setup this strategy
39
+ * @param auth The AuthenticationService
40
+ * @param name The name of the strategy
41
+ */
42
+ setup?(auth: AuthenticationBase, name: string): Promise<void>;
37
43
  /**
38
44
  * Authenticate an authentication request with this strategy.
39
45
  * Should throw an error if the strategy did not succeed.
@@ -65,10 +71,11 @@ export interface JwtVerifyOptions extends VerifyOptions {
65
71
  */
66
72
  export declare class AuthenticationBase {
67
73
  app: Application;
68
- configKey: string;
69
74
  strategies: {
70
75
  [key: string]: AuthenticationStrategy;
71
76
  };
77
+ configKey: string;
78
+ isReady: boolean;
72
79
  /**
73
80
  * Create a new authentication service.
74
81
  *
@@ -138,4 +145,5 @@ export declare class AuthenticationBase {
138
145
  * @param names A list of strategies to use
139
146
  */
140
147
  parse(req: IncomingMessage, res: ServerResponse, ...names: string[]): Promise<AuthenticationRequest>;
148
+ setup(): Promise<void>;
141
149
  }
package/lib/core.js CHANGED
@@ -9,7 +9,7 @@ const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
9
9
  const uuid_1 = require("uuid");
10
10
  const errors_1 = require("@feathersjs/errors");
11
11
  const commons_1 = require("@feathersjs/commons");
12
- const options_1 = __importDefault(require("./options"));
12
+ const options_1 = require("./options");
13
13
  const debug = (0, commons_1.createDebug)('@feathersjs/authentication/base');
14
14
  /**
15
15
  * A base class for managing authentication strategies and creating and verifying JWTs
@@ -29,6 +29,7 @@ class AuthenticationBase {
29
29
  this.app = app;
30
30
  this.strategies = {};
31
31
  this.configKey = configKey;
32
+ this.isReady = false;
32
33
  app.set('defaultAuthentication', app.get('defaultAuthentication') || configKey);
33
34
  app.set(configKey, (0, merge_1.default)({}, app.get(configKey), options));
34
35
  }
@@ -37,7 +38,7 @@ class AuthenticationBase {
37
38
  */
38
39
  get configuration() {
39
40
  // Always returns a copy of the authentication configuration
40
- return Object.assign({}, options_1.default, this.app.get(this.configKey));
41
+ return Object.assign({}, options_1.defaultOptions, this.app.get(this.configKey));
41
42
  }
42
43
  /**
43
44
  * A list of all registered strategy names
@@ -52,6 +53,7 @@ class AuthenticationBase {
52
53
  * @param strategy The authentication strategy instance
53
54
  */
54
55
  register(name, strategy) {
56
+ var _a;
55
57
  // Call the functions a strategy can implement
56
58
  if (typeof strategy.setName === 'function') {
57
59
  strategy.setName(name);
@@ -67,6 +69,9 @@ class AuthenticationBase {
67
69
  }
68
70
  // Register strategy as name
69
71
  this.strategies[name] = strategy;
72
+ if (this.isReady) {
73
+ (_a = strategy.setup) === null || _a === void 0 ? void 0 : _a.call(strategy, this, name);
74
+ }
70
75
  }
71
76
  /**
72
77
  * Get the registered authentication strategies for a list of names.
@@ -179,6 +184,14 @@ class AuthenticationBase {
179
184
  }
180
185
  return null;
181
186
  }
187
+ async setup() {
188
+ var _a;
189
+ this.isReady = true;
190
+ for (const name of Object.keys(this.strategies)) {
191
+ const strategy = this.strategies[name];
192
+ await ((_a = strategy.setup) === null || _a === void 0 ? void 0 : _a.call(strategy, this, name));
193
+ }
194
+ }
182
195
  }
183
196
  exports.AuthenticationBase = AuthenticationBase;
184
197
  //# sourceMappingURL=core.js.map
package/lib/core.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"core.js","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":";;;;;;AAAA,yDAAiC;AACjC,gEAAgF;AAChF,+BAAoC;AACpC,+CAAsD;AACtD,iDAAkD;AAGlD,wDAAuC;AAEvC,MAAM,KAAK,GAAG,IAAA,qBAAW,EAAC,iCAAiC,CAAC,CAAC;AAiE7D;;GAEG;AACH,MAAa,kBAAkB;IAO7B;;;;;;OAMG;IACH,YAAa,GAAgB,EAAE,SAAS,GAAG,gBAAgB,EAAE,OAAO,GAAG,EAAE;QACvE,IAAI,CAAC,GAAG,IAAI,OAAO,GAAG,CAAC,GAAG,KAAK,UAAU,EAAE;YACzC,MAAM,IAAI,KAAK,CAAC,wEAAwE,CAAC,CAAC;SAC3F;QAED,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;QACrB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAE3B,GAAG,CAAC,GAAG,CAAC,uBAAuB,EAAE,GAAG,CAAC,GAAG,CAAC,uBAAuB,CAAC,IAAI,SAAS,CAAC,CAAC;QAChF,GAAG,CAAC,GAAG,CAAC,SAAS,EAAE,IAAA,eAAK,EAAC,EAAE,EAAE,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;IAC7D,CAAC;IAED;;OAEG;IACH,IAAI,aAAa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AAK,yDAAG,IAAI,EAAE,IAAI,CAAC,CAAA,CAAC;SACpC;IACH,CAAC;CACF;AAtND,gDAsNC"}
@@ -1,7 +1,7 @@
1
1
  import { HookContext, NextFunction } from '@feathersjs/feathers';
2
2
  export interface AuthenticateHookSettings {
3
3
  service?: string;
4
- strategies: string[];
4
+ strategies?: string[];
5
5
  }
6
6
  declare const _default: (originalSettings: string | AuthenticateHookSettings, ...originalStrategies: string[]) => (context: HookContext, _next?: NextFunction) => Promise<any>;
7
7
  export default _default;
package/lib/index.d.ts CHANGED
@@ -4,3 +4,4 @@ export { AuthenticationBase, AuthenticationRequest, AuthenticationResult, Authen
4
4
  export { AuthenticationBaseStrategy } from './strategy';
5
5
  export { AuthenticationService } from './service';
6
6
  export { JWTStrategy } from './jwt';
7
+ export { authenticationSettingsSchema } from './options';
package/lib/index.js CHANGED
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -19,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
19
23
  return result;
20
24
  };
21
25
  Object.defineProperty(exports, "__esModule", { value: true });
22
- exports.JWTStrategy = exports.AuthenticationService = exports.AuthenticationBaseStrategy = exports.AuthenticationBase = exports.authenticate = exports.hooks = void 0;
26
+ exports.authenticationSettingsSchema = exports.JWTStrategy = exports.AuthenticationService = exports.AuthenticationBaseStrategy = exports.AuthenticationBase = exports.authenticate = exports.hooks = void 0;
23
27
  exports.hooks = __importStar(require("./hooks"));
24
28
  var hooks_1 = require("./hooks");
25
29
  Object.defineProperty(exports, "authenticate", { enumerable: true, get: function () { return hooks_1.authenticate; } });
@@ -31,4 +35,6 @@ var service_1 = require("./service");
31
35
  Object.defineProperty(exports, "AuthenticationService", { enumerable: true, get: function () { return service_1.AuthenticationService; } });
32
36
  var jwt_1 = require("./jwt");
33
37
  Object.defineProperty(exports, "JWTStrategy", { enumerable: true, get: function () { return jwt_1.JWTStrategy; } });
38
+ var options_1 = require("./options");
39
+ Object.defineProperty(exports, "authenticationSettingsSchema", { enumerable: true, get: function () { return options_1.authenticationSettingsSchema; } });
34
40
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAiC;AACjC,iCAAuC;AAA9B,qGAAA,YAAY,OAAA;AACrB,+BAMgB;AALd,0GAAA,kBAAkB,OAAA;AAMpB,uCAAwD;AAA/C,sHAAA,0BAA0B,OAAA;AACnC,qCAAkD;AAAzC,gHAAA,qBAAqB,OAAA;AAC9B,6BAAoC;AAA3B,kGAAA,WAAW,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAiC;AACjC,iCAAuC;AAA9B,qGAAA,YAAY,OAAA;AACrB,+BAMgB;AALd,0GAAA,kBAAkB,OAAA;AAMpB,uCAAwD;AAA/C,sHAAA,0BAA0B,OAAA;AACnC,qCAAkD;AAAzC,gHAAA,qBAAqB,OAAA;AAC9B,6BAAoC;AAA3B,kGAAA,WAAW,OAAA;AACpB,qCAAyD;AAAhD,uHAAA,4BAA4B,OAAA"}
package/lib/options.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- declare const _default: {
2
- authStrategies: any[];
1
+ export declare const defaultOptions: {
2
+ authStrategies: string[];
3
3
  jwtOptions: {
4
4
  header: {
5
5
  typ: string;
@@ -10,4 +10,119 @@ declare const _default: {
10
10
  expiresIn: string;
11
11
  };
12
12
  };
13
- export default _default;
13
+ export declare const authenticationSettingsSchema: {
14
+ readonly type: "object";
15
+ readonly required: readonly ["secret", "entity", "authStrategies"];
16
+ readonly properties: {
17
+ readonly secret: {
18
+ readonly type: "string";
19
+ readonly description: "The JWT signing secret";
20
+ };
21
+ readonly entity: {
22
+ readonly oneOf: readonly [{
23
+ readonly type: "null";
24
+ }, {
25
+ readonly type: "string";
26
+ }];
27
+ readonly description: "The name of the authentication entity (e.g. user)";
28
+ };
29
+ readonly entityId: {
30
+ readonly type: "string";
31
+ readonly description: "The name of the authentication entity id property";
32
+ };
33
+ readonly service: {
34
+ readonly type: "string";
35
+ readonly description: "The path of the entity service";
36
+ };
37
+ readonly authStrategies: {
38
+ readonly type: "array";
39
+ readonly items: {
40
+ readonly type: "string";
41
+ };
42
+ readonly description: "A list of authentication strategy names that are allowed to create JWT access tokens";
43
+ };
44
+ readonly parseStrategies: {
45
+ readonly type: "array";
46
+ readonly items: {
47
+ readonly type: "string";
48
+ };
49
+ readonly description: "A list of authentication strategy names that should parse HTTP headers for authentication information (defaults to `authStrategies`)";
50
+ };
51
+ readonly jwtOptions: {
52
+ readonly type: "object";
53
+ };
54
+ readonly jwt: {
55
+ readonly type: "object";
56
+ readonly properties: {
57
+ readonly header: {
58
+ readonly type: "string";
59
+ readonly default: "Authorization";
60
+ readonly description: "The HTTP header containing the JWT";
61
+ };
62
+ readonly schemes: {
63
+ readonly type: "array";
64
+ readonly items: {
65
+ readonly type: "string";
66
+ };
67
+ readonly description: "An array of schemes to support";
68
+ };
69
+ };
70
+ };
71
+ readonly local: {
72
+ readonly type: "object";
73
+ readonly required: readonly ["usernameField", "passwordField"];
74
+ readonly properties: {
75
+ readonly usernameField: {
76
+ readonly type: "string";
77
+ readonly description: "Name of the username field (e.g. `email`)";
78
+ };
79
+ readonly passwordField: {
80
+ readonly type: "string";
81
+ readonly description: "Name of the password field (e.g. `password`)";
82
+ };
83
+ readonly hashSize: {
84
+ readonly type: "number";
85
+ readonly description: "The BCrypt salt length";
86
+ };
87
+ readonly errorMessage: {
88
+ readonly type: "string";
89
+ readonly default: "Invalid login";
90
+ readonly description: "The error message to return on errors";
91
+ };
92
+ readonly entityUsernameField: {
93
+ readonly type: "string";
94
+ readonly description: "Name of the username field on the entity if authentication request data and entity field names are different";
95
+ };
96
+ readonly entityPasswordField: {
97
+ readonly type: "string";
98
+ readonly description: "Name of the password field on the entity if authentication request data and entity field names are different";
99
+ };
100
+ };
101
+ };
102
+ readonly oauth: {
103
+ readonly type: "object";
104
+ readonly properties: {
105
+ readonly redirect: {
106
+ readonly type: "string";
107
+ };
108
+ readonly origins: {
109
+ readonly type: "array";
110
+ readonly items: {
111
+ readonly type: "string";
112
+ };
113
+ };
114
+ readonly defaults: {
115
+ readonly type: "object";
116
+ readonly properties: {
117
+ readonly key: {
118
+ readonly type: "string";
119
+ };
120
+ readonly secret: {
121
+ readonly type: "string";
122
+ };
123
+ };
124
+ };
125
+ };
126
+ };
127
+ };
128
+ };
package/lib/options.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = {
3
+ exports.authenticationSettingsSchema = exports.defaultOptions = void 0;
4
+ exports.defaultOptions = {
4
5
  authStrategies: [],
5
6
  jwtOptions: {
6
7
  header: { typ: 'access' },
@@ -10,4 +11,108 @@ exports.default = {
10
11
  expiresIn: '1d'
11
12
  }
12
13
  };
14
+ exports.authenticationSettingsSchema = {
15
+ type: 'object',
16
+ required: ['secret', 'entity', 'authStrategies'],
17
+ properties: {
18
+ secret: {
19
+ type: 'string',
20
+ description: 'The JWT signing secret'
21
+ },
22
+ entity: {
23
+ oneOf: [{
24
+ type: 'null'
25
+ }, {
26
+ type: 'string'
27
+ }],
28
+ description: 'The name of the authentication entity (e.g. user)'
29
+ },
30
+ entityId: {
31
+ type: 'string',
32
+ description: 'The name of the authentication entity id property'
33
+ },
34
+ service: {
35
+ type: 'string',
36
+ description: 'The path of the entity service'
37
+ },
38
+ authStrategies: {
39
+ type: 'array',
40
+ items: { type: 'string' },
41
+ description: 'A list of authentication strategy names that are allowed to create JWT access tokens'
42
+ },
43
+ parseStrategies: {
44
+ type: 'array',
45
+ items: { type: 'string' },
46
+ description: 'A list of authentication strategy names that should parse HTTP headers for authentication information (defaults to `authStrategies`)'
47
+ },
48
+ jwtOptions: {
49
+ type: 'object'
50
+ },
51
+ jwt: {
52
+ type: 'object',
53
+ properties: {
54
+ header: {
55
+ type: 'string',
56
+ default: 'Authorization',
57
+ description: 'The HTTP header containing the JWT'
58
+ },
59
+ schemes: {
60
+ type: 'array',
61
+ items: { type: 'string' },
62
+ description: 'An array of schemes to support'
63
+ }
64
+ }
65
+ },
66
+ local: {
67
+ type: 'object',
68
+ required: ['usernameField', 'passwordField'],
69
+ properties: {
70
+ usernameField: {
71
+ type: 'string',
72
+ description: 'Name of the username field (e.g. `email`)'
73
+ },
74
+ passwordField: {
75
+ type: 'string',
76
+ description: 'Name of the password field (e.g. `password`)'
77
+ },
78
+ hashSize: {
79
+ type: 'number',
80
+ description: 'The BCrypt salt length'
81
+ },
82
+ errorMessage: {
83
+ type: 'string',
84
+ default: 'Invalid login',
85
+ description: 'The error message to return on errors'
86
+ },
87
+ entityUsernameField: {
88
+ type: 'string',
89
+ description: 'Name of the username field on the entity if authentication request data and entity field names are different'
90
+ },
91
+ entityPasswordField: {
92
+ type: 'string',
93
+ description: 'Name of the password field on the entity if authentication request data and entity field names are different'
94
+ }
95
+ }
96
+ },
97
+ oauth: {
98
+ type: 'object',
99
+ properties: {
100
+ redirect: {
101
+ type: 'string'
102
+ },
103
+ origins: {
104
+ type: 'array',
105
+ items: { type: 'string' }
106
+ },
107
+ defaults: {
108
+ type: 'object',
109
+ properties: {
110
+ key: { type: 'string' },
111
+ secret: { type: 'string' }
112
+ }
113
+ }
114
+ }
115
+ }
116
+ }
117
+ };
13
118
  //# sourceMappingURL=options.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"options.js","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":";;AAAA,kBAAe;IACb,cAAc,EAAE,EAAE;IAClB,UAAU,EAAE;QACV,MAAM,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE;QACzB,QAAQ,EAAE,wBAAwB;QAClC,MAAM,EAAE,UAAU;QAClB,SAAS,EAAE,OAAO;QAClB,SAAS,EAAE,IAAI;KAChB;CACF,CAAC"}
1
+ {"version":3,"file":"options.js","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":";;;AAAa,QAAA,cAAc,GAAG;IAC5B,cAAc,EAAE,EAAc;IAC9B,UAAU,EAAE;QACV,MAAM,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE;QACzB,QAAQ,EAAE,wBAAwB;QAClC,MAAM,EAAE,UAAU;QAClB,SAAS,EAAE,OAAO;QAClB,SAAS,EAAE,IAAI;KAChB;CACF,CAAC;AAEW,QAAA,4BAA4B,GAAG;IAC1C,IAAI,EAAE,QAAQ;IACd,QAAQ,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,gBAAgB,CAAC;IAChD,UAAU,EAAE;QACV,MAAM,EAAE;YACN,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,wBAAwB;SACtC;QACD,MAAM,EAAE;YACN,KAAK,EAAE,CAAC;oBACN,IAAI,EAAE,MAAM;iBACb,EAAE;oBACD,IAAI,EAAE,QAAQ;iBACf,CAAC;YACF,WAAW,EAAE,mDAAmD;SACjE;QACD,QAAQ,EAAE;YACR,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,mDAAmD;SACjE;QACD,OAAO,EAAE;YACP,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,gCAAgC;SAC9C;QACD,cAAc,EAAE;YACd,IAAI,EAAE,OAAO;YACb,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ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BACD,OAAO,EAAE;oBACP,IAAI,EAAE,OAAO;oBACb,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;iBAC1B;gBACD,QAAQ,EAAE;oBACR,IAAI,EAAE,QAAQ;oBACd,UAAU,EAAE;wBACV,GAAG,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;wBACvB,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;qBAC3B;iBACF;aACF;SACF;KACF;CACO,CAAC"}
package/lib/service.js CHANGED
@@ -108,6 +108,7 @@ class AuthenticationService extends core_1.AuthenticationBase {
108
108
  * Validates the service configuration.
109
109
  */
110
110
  async setup() {
111
+ await super.setup();
111
112
  // The setup method checks for valid settings and registers the
112
113
  // connection and event (login, logout) hooks
113
114
  const { secret, service, entity, entityId } = this.configuration;
@@ -1 +1 @@
1
- {"version":3,"file":"service.js","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":";;;;;;AAAA,yDAAiC;AACjC,+CAAsD;AACtD,iCAAyF;AACzF,mCAA4C;AAC5C,yCAAuC;AACvC,iDAAkD;AAElD,gEAAwC;AAExC,MAAM,KAAK,GAAG,IAAA,qBAAW,EAAC,oCAAoC,CAAC,CAAC;AAsBhE,MAAa,qBAAsB,SAAQ,yBAAkB;IAC3D,YAAa,GAAQ,EAAE,SAAS,GAAG,gBAAgB,EAAE,OAAO,GAAG,EAAE;QAC/D,KAAK,CAAC,GAAG,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;QAE/B,IAAI,OAAO,GAAG,CAAC,qBAAqB,KAAK,UAAU,EAAE;YACnD,GAAG,CAAC,qBAAqB,GAAG,UAAU,QAAiB;gBACrD,MAAM,SAAS,GAAG,GAAG,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;gBACnD,MAAM,IAAI,GAAG,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CACjE,IAAI,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AC,OAAO,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;SAC1B;IACH,CAAC;CACF;AA7JD,sDA6JC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@feathersjs/authentication",
3
3
  "description": "Add Authentication to your FeathersJS app.",
4
- "version": "5.0.0-pre.15",
4
+ "version": "5.0.0-pre.18",
5
5
  "homepage": "https://feathersjs.com",
6
6
  "main": "lib/",
7
7
  "types": "lib/",
@@ -16,7 +16,8 @@
16
16
  },
17
17
  "repository": {
18
18
  "type": "git",
19
- "url": "git://github.com/feathersjs/feathers.git"
19
+ "url": "git://github.com/feathersjs/feathers.git",
20
+ "directory": "packages/authentication"
20
21
  },
21
22
  "author": {
22
23
  "name": "Feathers contributors",
@@ -42,8 +43,7 @@
42
43
  "scripts": {
43
44
  "prepublish": "npm run compile",
44
45
  "compile": "shx rm -rf lib/ && tsc",
45
- "test": "npm run compile && npm run mocha",
46
- "mocha": "mocha --config ../../.mocharc.json --recursive test/**.test.ts test/**/*.test.ts"
46
+ "test": "mocha --config ../../.mocharc.json --recursive test/**.test.ts test/**/*.test.ts"
47
47
  },
48
48
  "directories": {
49
49
  "lib": "lib"
@@ -52,26 +52,27 @@
52
52
  "access": "public"
53
53
  },
54
54
  "dependencies": {
55
- "@feathersjs/commons": "^5.0.0-pre.15",
56
- "@feathersjs/errors": "^5.0.0-pre.15",
57
- "@feathersjs/feathers": "^5.0.0-pre.15",
58
- "@feathersjs/transport-commons": "^5.0.0-pre.15",
59
- "@types/jsonwebtoken": "^8.5.5",
55
+ "@feathersjs/commons": "^5.0.0-pre.18",
56
+ "@feathersjs/errors": "^5.0.0-pre.18",
57
+ "@feathersjs/feathers": "^5.0.0-pre.18",
58
+ "@feathersjs/transport-commons": "^5.0.0-pre.18",
59
+ "@types/jsonwebtoken": "^8.5.8",
60
60
  "jsonwebtoken": "^8.5.1",
61
61
  "lodash": "^4.17.21",
62
62
  "long-timeout": "^0.1.1",
63
63
  "uuid": "^8.3.2"
64
64
  },
65
65
  "devDependencies": {
66
- "@feathersjs/memory": "^5.0.0-pre.15",
67
- "@types/lodash": "^4.14.176",
68
- "@types/mocha": "^9.0.0",
69
- "@types/node": "^16.11.6",
70
- "@types/uuid": "^8.3.1",
71
- "mocha": "^9.1.3",
72
- "shx": "^0.3.3",
73
- "ts-node": "^10.4.0",
74
- "typescript": "^4.4.4"
66
+ "@feathersjs/memory": "^5.0.0-pre.18",
67
+ "@feathersjs/schema": "^5.0.0-pre.18",
68
+ "@types/lodash": "^4.14.181",
69
+ "@types/mocha": "^9.1.0",
70
+ "@types/node": "^17.0.23",
71
+ "@types/uuid": "^8.3.4",
72
+ "mocha": "^9.2.2",
73
+ "shx": "^0.3.4",
74
+ "ts-node": "^10.7.0",
75
+ "typescript": "^4.6.3"
75
76
  },
76
- "gitHead": "8008bf4f8529a2a40b6a2f976c1f43ae13675693"
77
+ "gitHead": "c0b7b67d872dcd6b6d94e4587f21332c8a519b50"
77
78
  }
package/src/core.ts CHANGED
@@ -5,7 +5,7 @@ import { NotAuthenticated } from '@feathersjs/errors';
5
5
  import { createDebug } from '@feathersjs/commons';
6
6
  import { Application, Params } from '@feathersjs/feathers';
7
7
  import { IncomingMessage, ServerResponse } from 'http';
8
- import defaultOptions from './options';
8
+ import { defaultOptions } from './options';
9
9
 
10
10
  const debug = createDebug('@feathersjs/authentication/base');
11
11
 
@@ -44,6 +44,12 @@ export interface AuthenticationStrategy {
44
44
  * and throw an error if it is invalid.
45
45
  */
46
46
  verifyConfiguration? (): void;
47
+ /**
48
+ * Implement this method to setup this strategy
49
+ * @param auth The AuthenticationService
50
+ * @param name The name of the strategy
51
+ */
52
+ setup? (auth: AuthenticationBase, name: string): Promise<void>;
47
53
  /**
48
54
  * Authenticate an authentication request with this strategy.
49
55
  * Should throw an error if the strategy did not succeed.
@@ -77,10 +83,9 @@ export interface JwtVerifyOptions extends VerifyOptions {
77
83
  */
78
84
  export class AuthenticationBase {
79
85
  app: Application;
86
+ strategies: { [key: string]: AuthenticationStrategy };
80
87
  configKey: string;
81
- strategies: {
82
- [key: string]: AuthenticationStrategy;
83
- };
88
+ isReady: boolean;
84
89
 
85
90
  /**
86
91
  * Create a new authentication service.
@@ -97,6 +102,7 @@ export class AuthenticationBase {
97
102
  this.app = app;
98
103
  this.strategies = {};
99
104
  this.configKey = configKey;
105
+ this.isReady = false;
100
106
 
101
107
  app.set('defaultAuthentication', app.get('defaultAuthentication') || configKey);
102
108
  app.set(configKey, merge({}, app.get(configKey), options));
@@ -143,6 +149,10 @@ export class AuthenticationBase {
143
149
 
144
150
  // Register strategy as name
145
151
  this.strategies[name] = strategy;
152
+
153
+ if (this.isReady) {
154
+ strategy.setup?.(this, name);
155
+ }
146
156
  }
147
157
 
148
158
  /**
@@ -157,7 +167,7 @@ export class AuthenticationBase {
157
167
 
158
168
  /**
159
169
  * Returns a single strategy by name
160
- *
170
+ *
161
171
  * @param name The strategy name
162
172
  * @returns The authentication strategy or undefined
163
173
  */
@@ -275,4 +285,14 @@ export class AuthenticationBase {
275
285
 
276
286
  return null;
277
287
  }
288
+
289
+ async setup () {
290
+ this.isReady = true;
291
+
292
+ for (const name of Object.keys(this.strategies)) {
293
+ const strategy = this.strategies[name];
294
+
295
+ await strategy.setup?.(this, name);
296
+ }
297
+ }
278
298
  }
@@ -8,7 +8,7 @@ const debug = createDebug('@feathersjs/authentication/hooks/authenticate');
8
8
 
9
9
  export interface AuthenticateHookSettings {
10
10
  service?: string;
11
- strategies: string[];
11
+ strategies?: string[];
12
12
  }
13
13
 
14
14
  export default (originalSettings: string | AuthenticateHookSettings, ...originalStrategies: string[]) => {
package/src/index.ts CHANGED
@@ -10,3 +10,4 @@ export {
10
10
  export { AuthenticationBaseStrategy } from './strategy';
11
11
  export { AuthenticationService } from './service';
12
12
  export { JWTStrategy } from './jwt';
13
+ export { authenticationSettingsSchema } from './options';
package/src/options.ts CHANGED
@@ -1,5 +1,5 @@
1
- export default {
2
- authStrategies: [],
1
+ export const defaultOptions = {
2
+ authStrategies: [] as string[],
3
3
  jwtOptions: {
4
4
  header: { typ: 'access' }, // by default is an access token but can be any type
5
5
  audience: 'https://yourdomain.com', // The resource server where the token is processed
@@ -8,3 +8,108 @@ export default {
8
8
  expiresIn: '1d'
9
9
  }
10
10
  };
11
+
12
+ export const authenticationSettingsSchema = {
13
+ type: 'object',
14
+ required: ['secret', 'entity', 'authStrategies'],
15
+ properties: {
16
+ secret: {
17
+ type: 'string',
18
+ description: 'The JWT signing secret'
19
+ },
20
+ entity: {
21
+ oneOf: [{
22
+ type: 'null'
23
+ }, {
24
+ type: 'string'
25
+ }],
26
+ description: 'The name of the authentication entity (e.g. user)'
27
+ },
28
+ entityId: {
29
+ type: 'string',
30
+ description: 'The name of the authentication entity id property'
31
+ },
32
+ service: {
33
+ type: 'string',
34
+ description: 'The path of the entity service'
35
+ },
36
+ authStrategies: {
37
+ type: 'array',
38
+ items: { type: 'string' },
39
+ description: 'A list of authentication strategy names that are allowed to create JWT access tokens'
40
+ },
41
+ parseStrategies: {
42
+ type: 'array',
43
+ items: { type: 'string' },
44
+ description: 'A list of authentication strategy names that should parse HTTP headers for authentication information (defaults to `authStrategies`)'
45
+ },
46
+ jwtOptions: {
47
+ type: 'object'
48
+ },
49
+ jwt: {
50
+ type: 'object',
51
+ properties: {
52
+ header: {
53
+ type: 'string',
54
+ default: 'Authorization',
55
+ description: 'The HTTP header containing the JWT'
56
+ },
57
+ schemes: {
58
+ type: 'array',
59
+ items: { type: 'string' },
60
+ description: 'An array of schemes to support'
61
+ }
62
+ }
63
+ },
64
+ local: {
65
+ type: 'object',
66
+ required: ['usernameField', 'passwordField'],
67
+ properties: {
68
+ usernameField: {
69
+ type: 'string',
70
+ description: 'Name of the username field (e.g. `email`)'
71
+ },
72
+ passwordField: {
73
+ type: 'string',
74
+ description: 'Name of the password field (e.g. `password`)'
75
+ },
76
+ hashSize: {
77
+ type: 'number',
78
+ description: 'The BCrypt salt length'
79
+ },
80
+ errorMessage: {
81
+ type: 'string',
82
+ default: 'Invalid login',
83
+ description: 'The error message to return on errors'
84
+ },
85
+ entityUsernameField: {
86
+ type: 'string',
87
+ description: 'Name of the username field on the entity if authentication request data and entity field names are different'
88
+ },
89
+ entityPasswordField: {
90
+ type: 'string',
91
+ description: 'Name of the password field on the entity if authentication request data and entity field names are different'
92
+ }
93
+ }
94
+ },
95
+ oauth: {
96
+ type: 'object',
97
+ properties: {
98
+ redirect: {
99
+ type: 'string'
100
+ },
101
+ origins: {
102
+ type: 'array',
103
+ items: { type: 'string' }
104
+ },
105
+ defaults: {
106
+ type: 'object',
107
+ properties: {
108
+ key: { type: 'string' },
109
+ secret: { type: 'string' }
110
+ }
111
+ }
112
+ }
113
+ }
114
+ }
115
+ } as const;
package/src/service.ts CHANGED
@@ -149,6 +149,8 @@ export class AuthenticationService extends AuthenticationBase implements Partial
149
149
  * Validates the service configuration.
150
150
  */
151
151
  async setup () {
152
+ await super.setup();
153
+
152
154
  // The setup method checks for valid settings and registers the
153
155
  // connection and event (login, logout) hooks
154
156
  const { secret, service, entity, entityId } = this.configuration;