@feathersjs/authentication 5.0.0-pre.1 → 5.0.0-pre.15
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 +162 -0
- package/LICENSE +1 -1
- package/README.md +1 -1
- package/lib/core.d.ts +7 -0
- package/lib/core.js +70 -77
- package/lib/core.js.map +1 -1
- package/lib/hooks/authenticate.d.ts +2 -2
- package/lib/hooks/authenticate.js +11 -20
- package/lib/hooks/authenticate.js.map +1 -1
- package/lib/hooks/connection.d.ts +2 -2
- package/lib/hooks/connection.js +7 -17
- package/lib/hooks/connection.js.map +1 -1
- package/lib/hooks/event.d.ts +2 -2
- package/lib/hooks/event.js +5 -17
- package/lib/hooks/event.js.map +1 -1
- package/lib/index.d.ts +2 -4
- package/lib/index.js +3 -4
- package/lib/index.js.map +1 -1
- package/lib/jwt.d.ts +1 -1
- package/lib/jwt.js +95 -106
- package/lib/jwt.js.map +1 -1
- package/lib/service.d.ts +8 -8
- package/lib/service.js +54 -73
- package/lib/service.js.map +1 -1
- package/lib/strategy.d.ts +1 -1
- package/package.json +18 -19
- package/src/core.ts +13 -3
- package/src/hooks/authenticate.ts +7 -8
- package/src/hooks/connection.ts +9 -11
- package/src/hooks/event.ts +6 -6
- package/src/index.ts +2 -6
- package/src/jwt.ts +6 -3
- package/src/service.ts +13 -16
- package/src/strategy.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,168 @@
|
|
|
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.15](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.14...v5.0.0-pre.15) (2021-11-27)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **typescript:** Overall typing improvements ([#2478](https://github.com/feathersjs/feathers/issues/2478)) ([b8eb804](https://github.com/feathersjs/feathers/commit/b8eb804158556d9651a8607e3c3fda15e0bfd110))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
* **authentication-oauth:** Allow dynamic oAuth redirect ([#2469](https://github.com/feathersjs/feathers/issues/2469)) ([b7143d4](https://github.com/feathersjs/feathers/commit/b7143d4c0fbe961e714f79512be04449b9bbd7d9))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
# [5.0.0-pre.14](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.13...v5.0.0-pre.14) (2021-10-13)
|
|
23
|
+
|
|
24
|
+
**Note:** Version bump only for package @feathersjs/authentication
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
# [5.0.0-pre.13](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.12...v5.0.0-pre.13) (2021-10-13)
|
|
31
|
+
|
|
32
|
+
**Note:** Version bump only for package @feathersjs/authentication
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
# [5.0.0-pre.12](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.11...v5.0.0-pre.12) (2021-10-12)
|
|
39
|
+
|
|
40
|
+
**Note:** Version bump only for package @feathersjs/authentication
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
# [5.0.0-pre.11](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.10...v5.0.0-pre.11) (2021-10-06)
|
|
47
|
+
|
|
48
|
+
**Note:** Version bump only for package @feathersjs/authentication
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
# [5.0.0-pre.10](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.9...v5.0.0-pre.10) (2021-09-19)
|
|
55
|
+
|
|
56
|
+
**Note:** Version bump only for package @feathersjs/authentication
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
# [5.0.0-pre.9](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.8...v5.0.0-pre.9) (2021-08-09)
|
|
63
|
+
|
|
64
|
+
**Note:** Version bump only for package @feathersjs/authentication
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
# [5.0.0-pre.8](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.7...v5.0.0-pre.8) (2021-08-09)
|
|
71
|
+
|
|
72
|
+
**Note:** Version bump only for package @feathersjs/authentication
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
# [5.0.0-pre.7](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.6...v5.0.0-pre.7) (2021-08-09)
|
|
79
|
+
|
|
80
|
+
**Note:** Version bump only for package @feathersjs/authentication
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
# [5.0.0-pre.6](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.5...v5.0.0-pre.6) (2021-08-08)
|
|
87
|
+
|
|
88
|
+
**Note:** Version bump only for package @feathersjs/authentication
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
# [5.0.0-pre.5](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.4...v5.0.0-pre.5) (2021-06-23)
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
### Bug Fixes
|
|
98
|
+
|
|
99
|
+
* **hooks:** Migrate built-in hooks and allow backwards compatibility ([#2358](https://github.com/feathersjs/feathers/issues/2358)) ([759c5a1](https://github.com/feathersjs/feathers/commit/759c5a19327a731af965c3604119393b3d09a406))
|
|
100
|
+
* **koa:** Use extended query parser for compatibility ([#2397](https://github.com/feathersjs/feathers/issues/2397)) ([b2944ba](https://github.com/feathersjs/feathers/commit/b2944bac3ec6d5ecc80dc518cd4e58093692db74))
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
### Features
|
|
104
|
+
|
|
105
|
+
* **adapter-commons:** Add support for params.adapter option and move memory adapter to @feathersjs/memory ([#2367](https://github.com/feathersjs/feathers/issues/2367)) ([a43e7da](https://github.com/feathersjs/feathers/commit/a43e7da22b6b981a96d1321736ea9a0cb924fb4f))
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
# [5.0.0-pre.4](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.3...v5.0.0-pre.4) (2021-05-13)
|
|
112
|
+
|
|
113
|
+
**Note:** Version bump only for package @feathersjs/authentication
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
# [5.0.0-pre.3](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.2...v5.0.0-pre.3) (2021-04-21)
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
### Bug Fixes
|
|
123
|
+
|
|
124
|
+
* **typescript:** Improve TypeScript backwards compatibility ([#2310](https://github.com/feathersjs/feathers/issues/2310)) ([f33be73](https://github.com/feathersjs/feathers/commit/f33be73fc46a533efb15df9aab0658e3240d3897))
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
### Features
|
|
128
|
+
|
|
129
|
+
* **dependencies:** Remove direct debug dependency ([#2296](https://github.com/feathersjs/feathers/issues/2296)) ([501d416](https://github.com/feathersjs/feathers/commit/501d4164d30c6a126906dc640cdfdc82207ba34a))
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
# [5.0.0-pre.2](https://github.com/feathersjs/feathers/compare/v5.0.0-beta.1...v5.0.0-pre.2) (2021-04-06)
|
|
136
|
+
|
|
137
|
+
**Note:** Version bump only for package @feathersjs/authentication
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
# [5.0.0-beta.1](https://github.com/feathersjs/feathers/compare/v5.0.0-beta.0...v5.0.0-beta.1) (2021-04-03)
|
|
144
|
+
|
|
145
|
+
**Note:** Version bump only for package @feathersjs/authentication
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
# [5.0.0-beta.0](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.1...v5.0.0-beta.0) (2021-03-28)
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
### Bug Fixes
|
|
155
|
+
|
|
156
|
+
* Update Grant usage and other dependencies ([#2264](https://github.com/feathersjs/feathers/issues/2264)) ([7b0f8fa](https://github.com/feathersjs/feathers/commit/7b0f8fad252419ed0ad0bf259cdf3104d322ab60))
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
### Features
|
|
160
|
+
|
|
161
|
+
* Application service types default to any ([#1566](https://github.com/feathersjs/feathers/issues/1566)) ([d93ba9a](https://github.com/feathersjs/feathers/commit/d93ba9a17edd20d3397bb00f4f6e82e804e42ed6))
|
|
162
|
+
* Feathers v5 core refactoring and features ([#2255](https://github.com/feathersjs/feathers/issues/2255)) ([2dafb7c](https://github.com/feathersjs/feathers/commit/2dafb7ce14ba57406aeec13d10ca45b1e709bee9))
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
|
|
6
168
|
# [5.0.0-pre.1](https://github.com/feathersjs/feathers/compare/v4.5.11...v5.0.0-pre.1) (2020-12-17)
|
|
7
169
|
|
|
8
170
|
|
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -18,6 +18,6 @@ Refer to the [Feathers authentication API documentation](https://docs.feathersjs
|
|
|
18
18
|
|
|
19
19
|
## License
|
|
20
20
|
|
|
21
|
-
Copyright (c)
|
|
21
|
+
Copyright (c) 2021 [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
|
@@ -98,6 +98,13 @@ export declare class AuthenticationBase {
|
|
|
98
98
|
* @param names The list or strategy names
|
|
99
99
|
*/
|
|
100
100
|
getStrategies(...names: string[]): AuthenticationStrategy[];
|
|
101
|
+
/**
|
|
102
|
+
* Returns a single strategy by name
|
|
103
|
+
*
|
|
104
|
+
* @param name The strategy name
|
|
105
|
+
* @returns The authentication strategy or undefined
|
|
106
|
+
*/
|
|
107
|
+
getStrategy(name: string): AuthenticationStrategy;
|
|
101
108
|
/**
|
|
102
109
|
* Create a new access token with payload and options.
|
|
103
110
|
*
|
package/lib/core.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
@@ -17,9 +8,9 @@ const merge_1 = __importDefault(require("lodash/merge"));
|
|
|
17
8
|
const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
|
|
18
9
|
const uuid_1 = require("uuid");
|
|
19
10
|
const errors_1 = require("@feathersjs/errors");
|
|
20
|
-
const
|
|
11
|
+
const commons_1 = require("@feathersjs/commons");
|
|
21
12
|
const options_1 = __importDefault(require("./options"));
|
|
22
|
-
const debug =
|
|
13
|
+
const debug = (0, commons_1.createDebug)('@feathersjs/authentication/base');
|
|
23
14
|
/**
|
|
24
15
|
* A base class for managing authentication strategies and creating and verifying JWTs
|
|
25
16
|
*/
|
|
@@ -39,7 +30,7 @@ class AuthenticationBase {
|
|
|
39
30
|
this.strategies = {};
|
|
40
31
|
this.configKey = configKey;
|
|
41
32
|
app.set('defaultAuthentication', app.get('defaultAuthentication') || configKey);
|
|
42
|
-
app.set(configKey, merge_1.default({}, app.get(configKey), options));
|
|
33
|
+
app.set(configKey, (0, merge_1.default)({}, app.get(configKey), options));
|
|
43
34
|
}
|
|
44
35
|
/**
|
|
45
36
|
* Return the current configuration from the application
|
|
@@ -86,6 +77,15 @@ class AuthenticationBase {
|
|
|
86
77
|
return names.map(name => this.strategies[name])
|
|
87
78
|
.filter(current => !!current);
|
|
88
79
|
}
|
|
80
|
+
/**
|
|
81
|
+
* Returns a single strategy by name
|
|
82
|
+
*
|
|
83
|
+
* @param name The strategy name
|
|
84
|
+
* @returns The authentication strategy or undefined
|
|
85
|
+
*/
|
|
86
|
+
getStrategy(name) {
|
|
87
|
+
return this.strategies[name];
|
|
88
|
+
}
|
|
89
89
|
/**
|
|
90
90
|
* Create a new access token with payload and options.
|
|
91
91
|
*
|
|
@@ -93,19 +93,17 @@ class AuthenticationBase {
|
|
|
93
93
|
* @param optsOverride The options to extend the defaults (`configuration.jwtOptions`) with
|
|
94
94
|
* @param secretOverride Use a different secret instead
|
|
95
95
|
*/
|
|
96
|
-
createAccessToken(payload, optsOverride, secretOverride) {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
return jsonwebtoken_1.default.sign(payload, jwtSecret, options);
|
|
108
|
-
});
|
|
96
|
+
async createAccessToken(payload, optsOverride, secretOverride) {
|
|
97
|
+
const { secret, jwtOptions } = this.configuration;
|
|
98
|
+
// Use configuration by default but allow overriding the secret
|
|
99
|
+
const jwtSecret = secretOverride || secret;
|
|
100
|
+
// Default jwt options merged with additional options
|
|
101
|
+
const options = (0, merge_1.default)({}, jwtOptions, optsOverride);
|
|
102
|
+
if (!options.jwtid) {
|
|
103
|
+
// Generate a UUID as JWT ID by default
|
|
104
|
+
options.jwtid = (0, uuid_1.v4)();
|
|
105
|
+
}
|
|
106
|
+
return jsonwebtoken_1.default.sign(payload, jwtSecret, options);
|
|
109
107
|
}
|
|
110
108
|
/**
|
|
111
109
|
* Verifies an access token.
|
|
@@ -114,25 +112,23 @@ class AuthenticationBase {
|
|
|
114
112
|
* @param optsOverride The options to extend the defaults (`configuration.jwtOptions`) with
|
|
115
113
|
* @param secretOverride Use a different secret instead
|
|
116
114
|
*/
|
|
117
|
-
verifyAccessToken(accessToken, optsOverride, secretOverride) {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}
|
|
135
|
-
});
|
|
115
|
+
async verifyAccessToken(accessToken, optsOverride, secretOverride) {
|
|
116
|
+
const { secret, jwtOptions } = this.configuration;
|
|
117
|
+
const jwtSecret = secretOverride || secret;
|
|
118
|
+
const options = (0, merge_1.default)({}, jwtOptions, optsOverride);
|
|
119
|
+
const { algorithm } = options;
|
|
120
|
+
// Normalize the `algorithm` setting into the algorithms array
|
|
121
|
+
if (algorithm && !options.algorithms) {
|
|
122
|
+
options.algorithms = Array.isArray(algorithm) ? algorithm : [algorithm];
|
|
123
|
+
delete options.algorithm;
|
|
124
|
+
}
|
|
125
|
+
try {
|
|
126
|
+
const verified = jsonwebtoken_1.default.verify(accessToken, jwtSecret, options);
|
|
127
|
+
return verified;
|
|
128
|
+
}
|
|
129
|
+
catch (error) {
|
|
130
|
+
throw new errors_1.NotAuthenticated(error.message, error);
|
|
131
|
+
}
|
|
136
132
|
}
|
|
137
133
|
/**
|
|
138
134
|
* Authenticate a given authentication request against a list of strategies.
|
|
@@ -141,29 +137,28 @@ class AuthenticationBase {
|
|
|
141
137
|
* @param params Service call parameters
|
|
142
138
|
* @param allowed A list of allowed strategy names
|
|
143
139
|
*/
|
|
144
|
-
authenticate(authentication, params, ...allowed) {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
140
|
+
async authenticate(authentication, params, ...allowed) {
|
|
141
|
+
const { strategy } = authentication || {};
|
|
142
|
+
const [authStrategy] = this.getStrategies(strategy);
|
|
143
|
+
const strategyAllowed = allowed.includes(strategy);
|
|
144
|
+
debug('Running authenticate for strategy', strategy, allowed);
|
|
145
|
+
if (!authentication || !authStrategy || !strategyAllowed) {
|
|
146
|
+
const additionalInfo = (!strategy && ' (no `strategy` set)') ||
|
|
147
|
+
(!strategyAllowed && ' (strategy not allowed in authStrategies)') || '';
|
|
148
|
+
// If there are no valid strategies or `authentication` is not an object
|
|
149
|
+
throw new errors_1.NotAuthenticated('Invalid authentication information' + additionalInfo);
|
|
150
|
+
}
|
|
151
|
+
return authStrategy.authenticate(authentication, {
|
|
152
|
+
...params,
|
|
153
|
+
authenticated: true
|
|
157
154
|
});
|
|
158
155
|
}
|
|
159
|
-
handleConnection(event, connection, authResult) {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
}
|
|
166
|
-
});
|
|
156
|
+
async handleConnection(event, connection, authResult) {
|
|
157
|
+
const strategies = this.getStrategies(...Object.keys(this.strategies))
|
|
158
|
+
.filter(current => typeof current.handleConnection === 'function');
|
|
159
|
+
for (const strategy of strategies) {
|
|
160
|
+
await strategy.handleConnection(event, connection, authResult);
|
|
161
|
+
}
|
|
167
162
|
}
|
|
168
163
|
/**
|
|
169
164
|
* Parse an HTTP request and response for authentication request information.
|
|
@@ -172,19 +167,17 @@ class AuthenticationBase {
|
|
|
172
167
|
* @param res The HTTP response
|
|
173
168
|
* @param names A list of strategies to use
|
|
174
169
|
*/
|
|
175
|
-
parse(req, res, ...names) {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
return value;
|
|
184
|
-
}
|
|
170
|
+
async parse(req, res, ...names) {
|
|
171
|
+
const strategies = this.getStrategies(...names)
|
|
172
|
+
.filter(current => typeof current.parse === 'function');
|
|
173
|
+
debug('Strategies parsing HTTP header for authentication information', names);
|
|
174
|
+
for (const authStrategy of strategies) {
|
|
175
|
+
const value = await authStrategy.parse(req, res);
|
|
176
|
+
if (value !== null) {
|
|
177
|
+
return value;
|
|
185
178
|
}
|
|
186
|
-
|
|
187
|
-
|
|
179
|
+
}
|
|
180
|
+
return null;
|
|
188
181
|
}
|
|
189
182
|
}
|
|
190
183
|
exports.AuthenticationBase = AuthenticationBase;
|
package/lib/core.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.js","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"
|
|
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,GAA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unction } from '@feathersjs/feathers';
|
|
2
2
|
export interface AuthenticateHookSettings {
|
|
3
3
|
service?: string;
|
|
4
4
|
strategies: string[];
|
|
5
5
|
}
|
|
6
|
-
declare const _default: (originalSettings: string | AuthenticateHookSettings, ...originalStrategies: string[]) => (context: HookContext) => Promise<
|
|
6
|
+
declare const _default: (originalSettings: string | AuthenticateHookSettings, ...originalStrategies: string[]) => (context: HookContext, _next?: NextFunction) => Promise<any>;
|
|
7
7
|
export default _default;
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
@@ -15,16 +6,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
6
|
const flatten_1 = __importDefault(require("lodash/flatten"));
|
|
16
7
|
const omit_1 = __importDefault(require("lodash/omit"));
|
|
17
8
|
const errors_1 = require("@feathersjs/errors");
|
|
18
|
-
const
|
|
19
|
-
const debug =
|
|
9
|
+
const commons_1 = require("@feathersjs/commons");
|
|
10
|
+
const debug = (0, commons_1.createDebug)('@feathersjs/authentication/hooks/authenticate');
|
|
20
11
|
exports.default = (originalSettings, ...originalStrategies) => {
|
|
21
12
|
const settings = typeof originalSettings === 'string'
|
|
22
|
-
? { strategies: flatten_1.default([originalSettings, ...originalStrategies]) }
|
|
13
|
+
? { strategies: (0, flatten_1.default)([originalSettings, ...originalStrategies]) }
|
|
23
14
|
: originalSettings;
|
|
24
15
|
if (!originalSettings || settings.strategies.length === 0) {
|
|
25
16
|
throw new Error('The authenticate hook needs at least one allowed strategy');
|
|
26
17
|
}
|
|
27
|
-
return (context) =>
|
|
18
|
+
return async (context, _next) => {
|
|
19
|
+
const next = typeof _next === 'function' ? _next : async () => context;
|
|
28
20
|
const { app, params, type, path, service } = context;
|
|
29
21
|
const { strategies } = settings;
|
|
30
22
|
const { provider, authentication } = params;
|
|
@@ -41,19 +33,18 @@ exports.default = (originalSettings, ...originalStrategies) => {
|
|
|
41
33
|
throw new errors_1.NotAuthenticated('The authenticate hook does not need to be used on the authentication service');
|
|
42
34
|
}
|
|
43
35
|
if (params.authenticated === true) {
|
|
44
|
-
return
|
|
36
|
+
return next();
|
|
45
37
|
}
|
|
46
38
|
if (authentication) {
|
|
47
|
-
const authParams = omit_1.default(params, 'provider', 'authentication');
|
|
39
|
+
const authParams = (0, omit_1.default)(params, 'provider', 'authentication');
|
|
48
40
|
debug('Authenticating with', authentication, strategies);
|
|
49
|
-
const authResult =
|
|
50
|
-
context.params = Object.assign({}, params, omit_1.default(authResult, 'accessToken'), { authenticated: true });
|
|
51
|
-
return context;
|
|
41
|
+
const authResult = await authService.authenticate(authentication, authParams, ...strategies);
|
|
42
|
+
context.params = Object.assign({}, params, (0, omit_1.default)(authResult, 'accessToken'), { authenticated: true });
|
|
52
43
|
}
|
|
53
44
|
else if (provider) {
|
|
54
45
|
throw new errors_1.NotAuthenticated('Not authenticated');
|
|
55
46
|
}
|
|
56
|
-
return
|
|
57
|
-
}
|
|
47
|
+
return next();
|
|
48
|
+
};
|
|
58
49
|
};
|
|
59
50
|
//# sourceMappingURL=authenticate.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authenticate.js","sourceRoot":"","sources":["../../src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AAgB,CAAC,qDAAqD,CAAC,CAAC;SACnF;QAED,IAAI,CAAC,WAAW,IAAI,OAAO,WAAW,CAAC,YAAY,KAAK,UAAU,EAAE;YAClE,MAAM,IAAI,yBAAgB,CAAC,+CAA+C,CAAC,CAAC;SAC7E;QAED,aAAa;QACb,IAAI,OAAO,KAAK,WAAW,EAAE;YAC3B,MAAM,IAAI,yBAAgB,CAAC,8EAA8E,CAAC,CAAC;SAC5G;QAED,IAAI,MAAM,CAAC,aAAa,KAAK,IAAI,EAAE;YACjC,OAAO,IAAI,EAAE,CAAC;SACf;QAED,IAAI,cAAc,EAAE;YAClB,MAAM,UAAU,GAAG,IAAA,cAAI,EAAC,MAAM,EAAE,UAAU,EAAE,gBAAgB,CAAC,CAAC;YAE9D,KAAK,CAAC,qBAAqB,EAAE,cAAc,EAAE,UAAU,CAAC,CAAC;YAEzD,MAAM,UAAU,GAAG,MAAM,WAAW,CAAC,YAAY,CAAC,cAAc,EAAE,UAAU,EAAE,GAAG,UAAU,CAAC,CAAC;YAE7F,OAAO,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,IAAA,cAAI,EAAC,UAAU,EAAE,aAAa,CAAC,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;SACtG;aAAM,IAAI,QAAQ,EAAE;YACnB,MAAM,IAAI,yBAAgB,CAAC,mBAAmB,CAAC,CAAC;SACjD;QAED,OAAO,IAAI,EAAE,CAAC;IAChB,CAAC,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HookContext } from '@feathersjs/feathers';
|
|
1
|
+
import { HookContext, NextFunction } from '@feathersjs/feathers';
|
|
2
2
|
import { ConnectionEvent } from '../core';
|
|
3
|
-
declare const _default: (event: ConnectionEvent) => (context: HookContext) => Promise<
|
|
3
|
+
declare const _default: (event: ConnectionEvent) => (context: HookContext, next: NextFunction) => Promise<void>;
|
|
4
4
|
export default _default;
|
package/lib/hooks/connection.js
CHANGED
|
@@ -1,26 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
14
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
6
|
const omit_1 = __importDefault(require("lodash/omit"));
|
|
16
|
-
exports.default = (event) => (context) =>
|
|
7
|
+
exports.default = (event) => async (context, next) => {
|
|
8
|
+
await next();
|
|
17
9
|
const { result, params: { connection } } = context;
|
|
18
|
-
if (
|
|
19
|
-
|
|
10
|
+
if (connection) {
|
|
11
|
+
const service = context.service;
|
|
12
|
+
Object.assign(connection, (0, omit_1.default)(result, 'accessToken', 'authentication'));
|
|
13
|
+
await service.handleConnection(event, connection, result);
|
|
20
14
|
}
|
|
21
|
-
|
|
22
|
-
Object.assign(connection, omit_1.default(result, 'accessToken', 'authentication'));
|
|
23
|
-
yield service.handleConnection(event, connection, result);
|
|
24
|
-
return context;
|
|
25
|
-
});
|
|
15
|
+
};
|
|
26
16
|
//# sourceMappingURL=connection.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection.js","sourceRoot":"","sources":["../../src/hooks/connection.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"connection.js","sourceRoot":"","sources":["../../src/hooks/connection.ts"],"names":[],"mappings":";;;;;AACA,uDAA+B;AAG/B,kBAAe,CAAC,KAAsB,EAAE,EAAE,CAAC,KAAK,EAAE,OAAoB,EAAE,IAAkB,EAAE,EAAE;IAC5F,MAAM,IAAI,EAAE,CAAC;IAEb,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,UAAU,EAAE,EAAE,GAAG,OAAO,CAAC;IAEnD,IAAI,UAAU,EAAE;QACd,MAAM,OAAO,GAAG,OAAO,CAAC,OAAwC,CAAC;QAEjE,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,IAAA,cAAI,EAAC,MAAM,EAAE,aAAa,EAAE,gBAAgB,CAAC,CAAC,CAAC;QAEzE,MAAM,OAAO,CAAC,gBAAgB,CAAC,KAAK,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC;KAC3D;AACH,CAAC,CAAC"}
|
package/lib/hooks/event.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HookContext } from '@feathersjs/feathers';
|
|
1
|
+
import { HookContext, NextFunction } from '@feathersjs/feathers';
|
|
2
2
|
import { ConnectionEvent } from '../core';
|
|
3
|
-
declare const _default: (event: ConnectionEvent) => (context: HookContext) => Promise<
|
|
3
|
+
declare const _default: (event: ConnectionEvent) => (context: HookContext, next: NextFunction) => Promise<void>;
|
|
4
4
|
export default _default;
|
package/lib/hooks/event.js
CHANGED
|
@@ -1,25 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const
|
|
16
|
-
const debug =
|
|
17
|
-
exports.default = (event) => (context) =>
|
|
3
|
+
const commons_1 = require("@feathersjs/commons");
|
|
4
|
+
const debug = (0, commons_1.createDebug)('@feathersjs/authentication/hooks/connection');
|
|
5
|
+
exports.default = (event) => async (context, next) => {
|
|
6
|
+
await next();
|
|
18
7
|
const { app, result, params } = context;
|
|
19
8
|
if (params.provider && result) {
|
|
20
9
|
debug(`Sending authentication event '${event}'`);
|
|
21
10
|
app.emit(event, result, params, context);
|
|
22
11
|
}
|
|
23
|
-
|
|
24
|
-
});
|
|
12
|
+
};
|
|
25
13
|
//# sourceMappingURL=event.js.map
|
package/lib/hooks/event.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event.js","sourceRoot":"","sources":["../../src/hooks/event.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"event.js","sourceRoot":"","sources":["../../src/hooks/event.ts"],"names":[],"mappings":";;AACA,iDAAkD;AAGlD,MAAM,KAAK,GAAG,IAAA,qBAAW,EAAC,6CAA6C,CAAC,CAAC;AAEzE,kBAAe,CAAC,KAAsB,EAAE,EAAE,CAAC,KAAK,EAAE,OAAoB,EAAE,IAAkB,EAAE,EAAE;IAC5F,MAAM,IAAI,EAAE,CAAC;IAEb,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAExC,IAAI,MAAM,CAAC,QAAQ,IAAI,MAAM,EAAE;QAC7B,KAAK,CAAC,iCAAiC,KAAK,GAAG,CAAC,CAAC;QACjD,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;KAC1C;AACH,CAAC,CAAC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export { hooks };
|
|
4
|
-
export { authenticate };
|
|
1
|
+
export * as hooks from './hooks';
|
|
2
|
+
export { authenticate } from './hooks';
|
|
5
3
|
export { AuthenticationBase, AuthenticationRequest, AuthenticationResult, AuthenticationStrategy, ConnectionEvent } from './core';
|
|
6
4
|
export { AuthenticationBaseStrategy } from './strategy';
|
|
7
5
|
export { AuthenticationService } from './service';
|