@feathersjs/authentication 5.0.0-pre.16 → 5.0.0-pre.19

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,38 @@
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.19](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.18...v5.0.0-pre.19) (2022-05-01)
7
+
8
+
9
+ ### Features
10
+
11
+ * **typescript:** Improve adapter typings ([#2605](https://github.com/feathersjs/feathers/issues/2605)) ([3b2ca0a](https://github.com/feathersjs/feathers/commit/3b2ca0a6a8e03e8390272c4d7e930b4bffdaacf5))
12
+ * **typescript:** Improve params and query typeability ([#2600](https://github.com/feathersjs/feathers/issues/2600)) ([df28b76](https://github.com/feathersjs/feathers/commit/df28b7619161f1df5e700326f52cca1a92dc5d28))
13
+
14
+
15
+
16
+
17
+
18
+ # [5.0.0-pre.18](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.17...v5.0.0-pre.18) (2022-04-11)
19
+
20
+
21
+ ### Features
22
+
23
+ * **authentication:** Add setup method for auth strategies ([#1611](https://github.com/feathersjs/feathers/issues/1611)) ([a3c3581](https://github.com/feathersjs/feathers/commit/a3c35814dccdbbf6de96f04f60b226ce206c6dbe))
24
+ * **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))
25
+
26
+
27
+
28
+
29
+
30
+ # [5.0.0-pre.17](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.16...v5.0.0-pre.17) (2022-02-15)
31
+
32
+ **Note:** Version bump only for package @feathersjs/authentication
33
+
34
+
35
+
36
+
37
+
6
38
  # [5.0.0-pre.16](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.15...v5.0.0-pre.16) (2022-01-12)
7
39
 
8
40
 
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
@@ -9,6 +9,15 @@ export interface AuthenticationRequest {
9
9
  strategy?: string;
10
10
  [key: string]: any;
11
11
  }
12
+ export interface AuthenticationParams extends Params {
13
+ payload?: {
14
+ [key: string]: any;
15
+ };
16
+ jwtOptions?: SignOptions;
17
+ authStrategies?: string[];
18
+ secret?: string;
19
+ [key: string]: any;
20
+ }
12
21
  export declare type ConnectionEvent = 'login' | 'logout' | 'disconnect';
13
22
  export interface AuthenticationStrategy {
14
23
  /**
@@ -34,6 +43,12 @@ export interface AuthenticationStrategy {
34
43
  * and throw an error if it is invalid.
35
44
  */
36
45
  verifyConfiguration?(): void;
46
+ /**
47
+ * Implement this method to setup this strategy
48
+ * @param auth The AuthenticationService
49
+ * @param name The name of the strategy
50
+ */
51
+ setup?(auth: AuthenticationBase, name: string): Promise<void>;
37
52
  /**
38
53
  * Authenticate an authentication request with this strategy.
39
54
  * Should throw an error if the strategy did not succeed.
@@ -41,7 +56,7 @@ export interface AuthenticationStrategy {
41
56
  * @param authentication The authentication request
42
57
  * @param params The service call parameters
43
58
  */
44
- authenticate?(authentication: AuthenticationRequest, params: Params): Promise<AuthenticationResult>;
59
+ authenticate?(authentication: AuthenticationRequest, params: AuthenticationParams): Promise<AuthenticationResult>;
45
60
  /**
46
61
  * Update a real-time connection according to this strategy.
47
62
  *
@@ -65,10 +80,11 @@ export interface JwtVerifyOptions extends VerifyOptions {
65
80
  */
66
81
  export declare class AuthenticationBase {
67
82
  app: Application;
68
- configKey: string;
69
83
  strategies: {
70
84
  [key: string]: AuthenticationStrategy;
71
85
  };
86
+ configKey: string;
87
+ isReady: boolean;
72
88
  /**
73
89
  * Create a new authentication service.
74
90
  *
@@ -128,7 +144,7 @@ export declare class AuthenticationBase {
128
144
  * @param params Service call parameters
129
145
  * @param allowed A list of allowed strategy names
130
146
  */
131
- authenticate(authentication: AuthenticationRequest, params: Params, ...allowed: string[]): Promise<AuthenticationResult>;
147
+ authenticate(authentication: AuthenticationRequest, params: AuthenticationParams, ...allowed: string[]): Promise<AuthenticationResult>;
132
148
  handleConnection(event: ConnectionEvent, connection: any, authResult?: AuthenticationResult): Promise<void>;
133
149
  /**
134
150
  * Parse an HTTP request and response for authentication request information.
@@ -138,4 +154,5 @@ export declare class AuthenticationBase {
138
154
  * @param names A list of strategies to use
139
155
  */
140
156
  parse(req: IncomingMessage, res: ServerResponse, ...names: string[]): Promise<AuthenticationRequest>;
157
+ setup(): Promise<void>;
141
158
  }
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;QACf,4DAA4D;QAC5D,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,iBAAc,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;IACzE,CAAC;IAED;;OAEG;IACH,IAAI,aAAa;QACf,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,U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AAC,EAAE,CAAC,OAAO,OAAO,CAAC,gBAAgB,KAAK,UAAU,CAAC,CAAC;QAErE,KAAK,MAAM,QAAQ,IAAI,UAAU,EAAE;YACjC,MAAM,QAAQ,CAAC,gBAAgB,CAAC,KAAK,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;SAChE;IACH,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,KAAK,CAAE,GAAoB,EAAE,GAAmB,EAAE,GAAG,KAAe;QACxE,MAAM,UAAU,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,KAAK,CAAC;aAC5C,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,OAAO,CAAC,KAAK,KAAK,UAAU,CAAC,CAAC;QAE1D,KAAK,CAAC,+DAA+D,EAAE,KAAK,CAAC,CAAC;QAE9E,KAAK,MAAM,YAAY,IAAI,UAAU,EAAE;YACrC,MAAM,KAAK,GAAG,MAAM,YAAY,CAAC,KAAK,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;YAEjD,IAAI,KAAK,KAAK,IAAI,EAAE;gBAClB,OAAO,KAAK,CAAC;aACd;SACF;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,KAAK;;QACT,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QAEpB,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE;YAC/C,MAAM,QAAQ,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;YAEvC,MAAM,CAAA,MAAA,QAAQ,CAAC,KAAK,yDAAG,IAAI,EAAE,IAAI,CAAC,CAAA,CAAC;SACpC;IACH,CAAC;CACF;AAtND,gDAsNC"}
package/lib/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export * as hooks from './hooks';
2
2
  export { authenticate } from './hooks';
3
- export { AuthenticationBase, AuthenticationRequest, AuthenticationResult, AuthenticationStrategy, ConnectionEvent } from './core';
3
+ export { AuthenticationBase, AuthenticationRequest, AuthenticationResult, AuthenticationStrategy, AuthenticationParams, ConnectionEvent } from './core';
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,+BAOgB;AANd,0GAAA,kBAAkB,OAAA;AAOpB,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/jwt.d.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  import { IncomingMessage } from 'http';
3
3
  import { Params } from '@feathersjs/feathers';
4
4
  import { AuthenticationBaseStrategy } from './strategy';
5
- import { AuthenticationRequest, AuthenticationResult, ConnectionEvent } from './core';
5
+ import { AuthenticationParams, AuthenticationRequest, AuthenticationResult, ConnectionEvent } from './core';
6
6
  export declare class JWTStrategy extends AuthenticationBaseStrategy {
7
7
  expirationTimers: WeakMap<object, any>;
8
8
  get configuration(): any;
@@ -17,7 +17,7 @@ export declare class JWTStrategy extends AuthenticationBaseStrategy {
17
17
  */
18
18
  getEntity(id: string, params: Params): Promise<any>;
19
19
  getEntityId(authResult: AuthenticationResult, _params: Params): Promise<any>;
20
- authenticate(authentication: AuthenticationRequest, params: Params): Promise<{
20
+ authenticate(authentication: AuthenticationRequest, params: AuthenticationParams): Promise<{
21
21
  accessToken: any;
22
22
  authentication: {
23
23
  strategy: string;
package/lib/jwt.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"jwt.js","sourceRoot":"","sources":["../src/jwt.ts"],"names":[],"mappings":";;;;;;AAAA,sDAAsD;AACtD,uDAA+B;AAE/B,+CAAsD;AAEtD,iDAAkD;AAClD,aAAa;AACb,gEAA8B;AAE9B,yCAAwD;AAGxD,MAAM,KAAK,GAAG,IAAA,qBAAW,EAAC,gCAAgC,CAAC,CAAC;AAC5D,MAAM,YAAY,GAAG,eAAe,CAAC;AAErC,MAAa,WAAY,SAAQ,qCAA0B;IAA3D;;QACE,qBAAgB,GAAG,IAAI,OAAO,EAAE,CAAC;IAgKnC,CAAC;IA9JC,IAAI,aAAa;QACf,MAAM,UAAU,GAAG,IAAI,CAAC,cAAc,CAAC,aAAa,CAAC;QACrD,MAAM,MAAM,GAAG,KAAK,CAAC,aAAa,CAAC;QAEnC,OAAO;YACL,OAAO,EAAE,UAAU,CAAC,OAAO;YAC3B,MAAM,EAAE,UAAU,CAAC,MAAM;YACzB,QAAQ,EAAE,UAAU,CAAC,QAAQ;YAC7B,MAAM,EAAE,eAAe;YACvB,OAAO,EAAE,CAAE,QAAQ,EAAE,KAAK,CAAE;YAC5B,GAAG,MAAM;SACV,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,gBAAgB,CAAE,KAAsB,EAAE,UAAe,EAAE,UAAiC;QAChG,MAAM,aAAa,GAAG,KAAK,KAAK,QAAQ,IAAI,UAAU,CAAC,cAAc,IAAI,UAAU;YACjF,UAAU,CAAC,cAAc,CAAC,WAAW,KAAK,UAAU,CAAC,WAAW,CAAC;QAEnE,MAAM,EAAE,WAAW,EAAE,GAAG,UAAU,IAAI,EAAE,CAAC;QAEzC,IAAI,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;AAjKD,kCAiKC"}
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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H;aACF;SACF;QACD,KAAK,EAAE;YACL,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,QAAQ,EAAE;oBACR,IAAI,EAAE,QAAQ;iBACf;gBACD,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.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { AuthenticationBase, AuthenticationResult, AuthenticationRequest } from './core';
1
+ import { AuthenticationBase, AuthenticationResult, AuthenticationRequest, AuthenticationParams } from './core';
2
2
  import '@feathersjs/transport-commons';
3
- import { Params, ServiceMethods, ServiceAddons } from '@feathersjs/feathers';
3
+ import { ServiceMethods, ServiceAddons } from '@feathersjs/feathers';
4
4
  declare module '@feathersjs/feathers/lib/declarations' {
5
5
  interface FeathersApplication<Services, Settings> {
6
6
  /**
@@ -18,7 +18,7 @@ declare module '@feathersjs/feathers/lib/declarations' {
18
18
  }
19
19
  export interface AuthenticationService extends ServiceAddons<AuthenticationResult, AuthenticationResult> {
20
20
  }
21
- export declare class AuthenticationService extends AuthenticationBase implements Partial<ServiceMethods<AuthenticationResult>> {
21
+ export declare class AuthenticationService extends AuthenticationBase implements Partial<ServiceMethods<AuthenticationResult, AuthenticationRequest, AuthenticationParams>> {
22
22
  constructor(app: any, configKey?: string, options?: {});
23
23
  /**
24
24
  * Return the payload for a JWT based on the authentication result.
@@ -27,7 +27,9 @@ export declare class AuthenticationService extends AuthenticationBase implements
27
27
  * @param _authResult The current authentication result
28
28
  * @param params The service call parameters
29
29
  */
30
- getPayload(_authResult: AuthenticationResult, params: Params): Promise<any>;
30
+ getPayload(_authResult: AuthenticationResult, params: AuthenticationParams): Promise<{
31
+ [key: string]: any;
32
+ }>;
31
33
  /**
32
34
  * Returns the JWT options based on an authentication result.
33
35
  * By default sets the JWT subject to the entity id.
@@ -35,7 +37,7 @@ export declare class AuthenticationService extends AuthenticationBase implements
35
37
  * @param authResult The authentication result
36
38
  * @param params Service call parameters
37
39
  */
38
- getTokenOptions(authResult: AuthenticationResult, params: Params): Promise<any>;
40
+ getTokenOptions(authResult: AuthenticationResult, params: AuthenticationParams): Promise<any>;
39
41
  /**
40
42
  * Create and return a new JWT for a given authentication request.
41
43
  * Will trigger the `login` event.
@@ -43,7 +45,7 @@ export declare class AuthenticationService extends AuthenticationBase implements
43
45
  * @param data The authentication request (should include `strategy` key)
44
46
  * @param params Service call parameters
45
47
  */
46
- create(data: AuthenticationRequest, params?: Params): Promise<AuthenticationResult>;
48
+ create(data: AuthenticationRequest, params?: AuthenticationParams): Promise<AuthenticationResult>;
47
49
  /**
48
50
  * Mark a JWT as removed. By default only verifies the JWT and returns the result.
49
51
  * Triggers the `logout` event.
@@ -51,7 +53,7 @@ export declare class AuthenticationService extends AuthenticationBase implements
51
53
  * @param id The JWT to remove or null
52
54
  * @param params Service call parameters
53
55
  */
54
- remove(id: string | null, params?: Params): Promise<AuthenticationResult>;
56
+ remove(id: string | null, params?: AuthenticationParams): Promise<AuthenticationResult>;
55
57
  /**
56
58
  * Validates the service configuration.
57
59
  */
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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,QAAQ,KAAK,SAAS,EAAE;gBACxE,MAAM,IAAI,KAAK,CAAC,QAAQ,OAAO,2EAA2E,CAAC,CAAC;aAC7G;SACF;QAEA,IAAY,CAAC,KAAK,CAAC;YAClB,MAAM,EAAE,CAAE,IAAA,kBAAU,EAAC,OAAO,CAAC,EAAE,IAAA,aAAK,EAAC,OAAO,CAAC,CAAE;YAC/C,MAAM,EAAE,CAAE,IAAA,kBAAU,EAAC,QAAQ,CAAC,EAAE,IAAA,aAAK,EAAC,QAAQ,CAAC,CAAE;SAClD,CAAC,CAAC;QAEH,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,YAAY,EAAE,KAAK,EAAE,UAAU,EAAE,EAAE;YAC7C,MAAM,IAAI,CAAC,gBAAgB,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;QACxD,CAAC,CAAC,CAAC;QAEH,IAAI,OAAO,IAAI,CAAC,OAAO,KAAK,UAAU,EAAE;YACtC,IAAI,CAAC,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.16",
4
+ "version": "5.0.0-pre.19",
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.16",
56
- "@feathersjs/errors": "^5.0.0-pre.16",
57
- "@feathersjs/feathers": "^5.0.0-pre.16",
58
- "@feathersjs/transport-commons": "^5.0.0-pre.16",
59
- "@types/jsonwebtoken": "^8.5.6",
55
+ "@feathersjs/commons": "^5.0.0-pre.19",
56
+ "@feathersjs/errors": "^5.0.0-pre.19",
57
+ "@feathersjs/feathers": "^5.0.0-pre.19",
58
+ "@feathersjs/transport-commons": "^5.0.0-pre.19",
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.16",
67
- "@types/lodash": "^4.14.178",
68
- "@types/mocha": "^9.0.0",
69
- "@types/node": "^17.0.5",
70
- "@types/uuid": "^8.3.3",
71
- "mocha": "^9.1.3",
72
- "shx": "^0.3.3",
73
- "ts-node": "^10.4.0",
74
- "typescript": "^4.5.4"
66
+ "@feathersjs/memory": "^5.0.0-pre.19",
67
+ "@feathersjs/schema": "^5.0.0-pre.19",
68
+ "@types/lodash": "^4.14.182",
69
+ "@types/mocha": "^9.1.1",
70
+ "@types/node": "^17.0.31",
71
+ "@types/uuid": "^8.3.4",
72
+ "mocha": "^10.0.0",
73
+ "shx": "^0.3.4",
74
+ "ts-node": "^10.7.0",
75
+ "typescript": "^4.6.4"
75
76
  },
76
- "gitHead": "f0cd227a82d159b528193bd33747c97684a48773"
77
+ "gitHead": "57f3e18bb62735e1869ffafee90286498738fdfa"
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
 
@@ -18,6 +18,14 @@ export interface AuthenticationRequest {
18
18
  [key: string]: any;
19
19
  }
20
20
 
21
+ export interface AuthenticationParams extends Params {
22
+ payload?: { [key: string]: any };
23
+ jwtOptions?: SignOptions;
24
+ authStrategies?: string[];
25
+ secret?: string;
26
+ [key: string]: any;
27
+ }
28
+
21
29
  export type ConnectionEvent = 'login' | 'logout' | 'disconnect';
22
30
 
23
31
  export interface AuthenticationStrategy {
@@ -44,6 +52,12 @@ export interface AuthenticationStrategy {
44
52
  * and throw an error if it is invalid.
45
53
  */
46
54
  verifyConfiguration? (): void;
55
+ /**
56
+ * Implement this method to setup this strategy
57
+ * @param auth The AuthenticationService
58
+ * @param name The name of the strategy
59
+ */
60
+ setup? (auth: AuthenticationBase, name: string): Promise<void>;
47
61
  /**
48
62
  * Authenticate an authentication request with this strategy.
49
63
  * Should throw an error if the strategy did not succeed.
@@ -51,7 +65,7 @@ export interface AuthenticationStrategy {
51
65
  * @param authentication The authentication request
52
66
  * @param params The service call parameters
53
67
  */
54
- authenticate? (authentication: AuthenticationRequest, params: Params): Promise<AuthenticationResult>;
68
+ authenticate? (authentication: AuthenticationRequest, params: AuthenticationParams): Promise<AuthenticationResult>;
55
69
  /**
56
70
  * Update a real-time connection according to this strategy.
57
71
  *
@@ -77,10 +91,9 @@ export interface JwtVerifyOptions extends VerifyOptions {
77
91
  */
78
92
  export class AuthenticationBase {
79
93
  app: Application;
94
+ strategies: { [key: string]: AuthenticationStrategy };
80
95
  configKey: string;
81
- strategies: {
82
- [key: string]: AuthenticationStrategy;
83
- };
96
+ isReady: boolean;
84
97
 
85
98
  /**
86
99
  * Create a new authentication service.
@@ -97,6 +110,7 @@ export class AuthenticationBase {
97
110
  this.app = app;
98
111
  this.strategies = {};
99
112
  this.configKey = configKey;
113
+ this.isReady = false;
100
114
 
101
115
  app.set('defaultAuthentication', app.get('defaultAuthentication') || configKey);
102
116
  app.set(configKey, merge({}, app.get(configKey), options));
@@ -143,6 +157,10 @@ export class AuthenticationBase {
143
157
 
144
158
  // Register strategy as name
145
159
  this.strategies[name] = strategy;
160
+
161
+ if (this.isReady) {
162
+ strategy.setup?.(this, name);
163
+ }
146
164
  }
147
165
 
148
166
  /**
@@ -157,7 +175,7 @@ export class AuthenticationBase {
157
175
 
158
176
  /**
159
177
  * Returns a single strategy by name
160
- *
178
+ *
161
179
  * @param name The strategy name
162
180
  * @returns The authentication strategy or undefined
163
181
  */
@@ -222,7 +240,7 @@ export class AuthenticationBase {
222
240
  * @param params Service call parameters
223
241
  * @param allowed A list of allowed strategy names
224
242
  */
225
- async authenticate (authentication: AuthenticationRequest, params: Params, ...allowed: string[]) {
243
+ async authenticate (authentication: AuthenticationRequest, params: AuthenticationParams, ...allowed: string[]) {
226
244
  const { strategy } = authentication || {};
227
245
  const [ authStrategy ] = this.getStrategies(strategy);
228
246
  const strategyAllowed = allowed.includes(strategy);
@@ -275,4 +293,14 @@ export class AuthenticationBase {
275
293
 
276
294
  return null;
277
295
  }
296
+
297
+ async setup () {
298
+ this.isReady = true;
299
+
300
+ for (const name of Object.keys(this.strategies)) {
301
+ const strategy = this.strategies[name];
302
+
303
+ await strategy.setup?.(this, name);
304
+ }
305
+ }
278
306
  }
package/src/index.ts CHANGED
@@ -5,8 +5,10 @@ export {
5
5
  AuthenticationRequest,
6
6
  AuthenticationResult,
7
7
  AuthenticationStrategy,
8
+ AuthenticationParams,
8
9
  ConnectionEvent
9
10
  } from './core';
10
11
  export { AuthenticationBaseStrategy } from './strategy';
11
12
  export { AuthenticationService } from './service';
12
13
  export { JWTStrategy } from './jwt';
14
+ export { authenticationSettingsSchema } from './options';
package/src/jwt.ts CHANGED
@@ -8,7 +8,7 @@ import { createDebug } from '@feathersjs/commons';
8
8
  import lt from 'long-timeout';
9
9
 
10
10
  import { AuthenticationBaseStrategy } from './strategy';
11
- import { AuthenticationRequest, AuthenticationResult, ConnectionEvent } from './core';
11
+ import { AuthenticationParams, AuthenticationRequest, AuthenticationResult, ConnectionEvent } from './core';
12
12
 
13
13
  const debug = createDebug('@feathersjs/authentication/jwt');
14
14
  const SPLIT_HEADER = /(\S+)\s+(\S+)/;
@@ -116,7 +116,7 @@ export class JWTStrategy extends AuthenticationBaseStrategy {
116
116
  return authResult.authentication.payload.sub;
117
117
  }
118
118
 
119
- async authenticate (authentication: AuthenticationRequest, params: Params) {
119
+ async authenticate (authentication: AuthenticationRequest, params: AuthenticationParams) {
120
120
  const { accessToken } = authentication;
121
121
  const { entity } = this.configuration;
122
122
 
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
@@ -1,10 +1,10 @@
1
1
  import merge from 'lodash/merge';
2
2
  import { NotAuthenticated } from '@feathersjs/errors';
3
- import { AuthenticationBase, AuthenticationResult, AuthenticationRequest } from './core';
3
+ import { AuthenticationBase, AuthenticationResult, AuthenticationRequest, AuthenticationParams } from './core';
4
4
  import { connection, event } from './hooks';
5
5
  import '@feathersjs/transport-commons';
6
6
  import { createDebug } from '@feathersjs/commons';
7
- import { Params, ServiceMethods, ServiceAddons } from '@feathersjs/feathers';
7
+ import { ServiceMethods, ServiceAddons } from '@feathersjs/feathers';
8
8
  import jsonwebtoken from 'jsonwebtoken';
9
9
 
10
10
  const debug = createDebug('@feathersjs/authentication/service');
@@ -29,7 +29,7 @@ declare module '@feathersjs/feathers/lib/declarations' {
29
29
  // eslint-disable-next-line
30
30
  export interface AuthenticationService extends ServiceAddons<AuthenticationResult, AuthenticationResult> {}
31
31
 
32
- export class AuthenticationService extends AuthenticationBase implements Partial<ServiceMethods<AuthenticationResult>> {
32
+ export class AuthenticationService extends AuthenticationBase implements Partial<ServiceMethods<AuthenticationResult, AuthenticationRequest, AuthenticationParams>> {
33
33
  constructor (app: any, configKey = 'authentication', options = {}) {
34
34
  super(app, configKey, options);
35
35
 
@@ -51,7 +51,7 @@ export class AuthenticationService extends AuthenticationBase implements Partial
51
51
  * @param _authResult The current authentication result
52
52
  * @param params The service call parameters
53
53
  */
54
- async getPayload (_authResult: AuthenticationResult, params: Params) {
54
+ async getPayload (_authResult: AuthenticationResult, params: AuthenticationParams) {
55
55
  // Uses `params.payload` or returns an empty payload
56
56
  const { payload = {} } = params;
57
57
 
@@ -65,7 +65,7 @@ export class AuthenticationService extends AuthenticationBase implements Partial
65
65
  * @param authResult The authentication result
66
66
  * @param params Service call parameters
67
67
  */
68
- async getTokenOptions (authResult: AuthenticationResult, params: Params) {
68
+ async getTokenOptions (authResult: AuthenticationResult, params: AuthenticationParams) {
69
69
  const { service, entity, entityId } = this.configuration;
70
70
  const jwtOptions = merge({}, params.jwtOptions, params.jwt);
71
71
  const value = service && entity && authResult[entity];
@@ -92,7 +92,7 @@ export class AuthenticationService extends AuthenticationBase implements Partial
92
92
  * @param data The authentication request (should include `strategy` key)
93
93
  * @param params Service call parameters
94
94
  */
95
- async create (data: AuthenticationRequest, params?: Params) {
95
+ async create (data: AuthenticationRequest, params?: AuthenticationParams) {
96
96
  const authStrategies = params.authStrategies || this.configuration.authStrategies;
97
97
 
98
98
  if (!authStrategies.length) {
@@ -131,7 +131,7 @@ export class AuthenticationService extends AuthenticationBase implements Partial
131
131
  * @param id The JWT to remove or null
132
132
  * @param params Service call parameters
133
133
  */
134
- async remove (id: string | null, params?: Params) {
134
+ async remove (id: string | null, params?: AuthenticationParams) {
135
135
  const { authentication } = params;
136
136
  const { authStrategies } = this.configuration;
137
137
 
@@ -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;