@whook/oauth2 9.0.0 → 10.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +90 -68
- package/dist/handlers/getOAuth2Authorize.d.ts +4 -4
- package/dist/handlers/getOAuth2Authorize.js +122 -165
- package/dist/handlers/getOAuth2Authorize.js.map +1 -1
- package/dist/handlers/getOAuth2Authorize.test.js +117 -103
- package/dist/handlers/getOAuth2Authorize.test.js.map +1 -1
- package/dist/handlers/postAuthLogin.d.ts +1 -1
- package/dist/handlers/postAuthLogin.js +83 -121
- package/dist/handlers/postAuthLogin.js.map +1 -1
- package/dist/handlers/postAuthLogin.test.js +42 -44
- package/dist/handlers/postAuthLogin.test.js.map +1 -1
- package/dist/handlers/postAuthLogout.d.ts +1 -1
- package/dist/handlers/postAuthLogout.js +26 -42
- package/dist/handlers/postAuthLogout.js.map +1 -1
- package/dist/handlers/postAuthLogout.test.js +19 -21
- package/dist/handlers/postAuthLogout.test.js.map +1 -1
- package/dist/handlers/postAuthRefresh.d.ts +1 -1
- package/dist/handlers/postAuthRefresh.js +93 -132
- package/dist/handlers/postAuthRefresh.js.map +1 -1
- package/dist/handlers/postAuthRefresh.test.js +47 -49
- package/dist/handlers/postAuthRefresh.test.js.map +1 -1
- package/dist/handlers/postOAuth2Acknowledge.d.ts +5 -5
- package/dist/handlers/postOAuth2Acknowledge.js +119 -151
- package/dist/handlers/postOAuth2Acknowledge.js.map +1 -1
- package/dist/handlers/postOAuth2Acknowledge.test.js +139 -125
- package/dist/handlers/postOAuth2Acknowledge.test.js.map +1 -1
- package/dist/handlers/postOAuth2Token.d.ts +1 -1
- package/dist/handlers/postOAuth2Token.js +200 -232
- package/dist/handlers/postOAuth2Token.js.map +1 -1
- package/dist/handlers/postOAuth2Token.test.js +156 -153
- package/dist/handlers/postOAuth2Token.test.js.map +1 -1
- package/dist/index.d.ts +16 -16
- package/dist/index.js +14 -229
- package/dist/index.js.map +1 -1
- package/dist/index.test.js +697 -619
- package/dist/index.test.js.map +1 -1
- package/dist/services/authCookies.d.ts +8 -4
- package/dist/services/authCookies.js +40 -71
- package/dist/services/authCookies.js.map +1 -1
- package/dist/services/authCookies.test.js +57 -62
- package/dist/services/authCookies.test.js.map +1 -1
- package/dist/services/oAuth2ClientCredentialsGranter.d.ts +2 -2
- package/dist/services/oAuth2ClientCredentialsGranter.js +34 -52
- package/dist/services/oAuth2ClientCredentialsGranter.js.map +1 -1
- package/dist/services/oAuth2CodeGranter.d.ts +1 -1
- package/dist/services/oAuth2CodeGranter.js +66 -109
- package/dist/services/oAuth2CodeGranter.js.map +1 -1
- package/dist/services/oAuth2CodeGranter.test.js +65 -66
- package/dist/services/oAuth2CodeGranter.test.js.map +1 -1
- package/dist/services/oAuth2Granters.js +131 -138
- package/dist/services/oAuth2Granters.js.map +1 -1
- package/dist/services/oAuth2PasswordGranter.d.ts +1 -1
- package/dist/services/oAuth2PasswordGranter.js +27 -52
- package/dist/services/oAuth2PasswordGranter.js.map +1 -1
- package/dist/services/oAuth2RefreshTokenGranter.d.ts +1 -1
- package/dist/services/oAuth2RefreshTokenGranter.js +34 -58
- package/dist/services/oAuth2RefreshTokenGranter.js.map +1 -1
- package/dist/services/oAuth2TokenGranter.d.ts +1 -1
- package/dist/services/oAuth2TokenGranter.js +50 -86
- package/dist/services/oAuth2TokenGranter.js.map +1 -1
- package/package.json +48 -89
- package/src/__snapshots__/index.test.ts.snap +23 -22
- package/src/handlers/__snapshots__/postOAuth2Acknowledge.test.ts.snap +1 -1
- package/src/handlers/getOAuth2Authorize.test.ts +49 -13
- package/src/handlers/getOAuth2Authorize.ts +2 -2
- package/src/handlers/postAuthLogin.test.ts +9 -5
- package/src/handlers/postAuthLogin.ts +4 -4
- package/src/handlers/postAuthLogout.test.ts +8 -4
- package/src/handlers/postAuthLogout.ts +2 -2
- package/src/handlers/postAuthRefresh.test.ts +10 -6
- package/src/handlers/postAuthRefresh.ts +4 -4
- package/src/handlers/postOAuth2Acknowledge.test.ts +83 -35
- package/src/handlers/postOAuth2Acknowledge.ts +18 -8
- package/src/handlers/postOAuth2Token.test.ts +77 -17
- package/src/handlers/postOAuth2Token.ts +3 -3
- package/src/index.test.ts +110 -65
- package/src/index.ts +21 -19
- package/src/services/authCookies.test.ts +2 -2
- package/src/services/authCookies.ts +10 -5
- package/src/services/oAuth2ClientCredentialsGranter.ts +3 -3
- package/src/services/oAuth2CodeGranter.test.ts +27 -4
- package/src/services/oAuth2CodeGranter.ts +2 -2
- package/src/services/oAuth2PasswordGranter.ts +2 -2
- package/src/services/oAuth2RefreshTokenGranter.ts +2 -2
- package/src/services/oAuth2TokenGranter.ts +1 -1
- package/dist/handlers/getOAuth2Authorize.mjs +0 -160
- package/dist/handlers/getOAuth2Authorize.mjs.map +0 -1
- package/dist/handlers/getOAuth2Authorize.test.mjs +0 -114
- package/dist/handlers/getOAuth2Authorize.test.mjs.map +0 -1
- package/dist/handlers/postAuthLogin.mjs +0 -109
- package/dist/handlers/postAuthLogin.mjs.map +0 -1
- package/dist/handlers/postAuthLogin.test.mjs +0 -85
- package/dist/handlers/postAuthLogin.test.mjs.map +0 -1
- package/dist/handlers/postAuthLogout.mjs +0 -33
- package/dist/handlers/postAuthLogout.mjs.map +0 -1
- package/dist/handlers/postAuthLogout.test.mjs +0 -30
- package/dist/handlers/postAuthLogout.test.mjs.map +0 -1
- package/dist/handlers/postAuthRefresh.mjs +0 -122
- package/dist/handlers/postAuthRefresh.mjs.map +0 -1
- package/dist/handlers/postAuthRefresh.test.mjs +0 -94
- package/dist/handlers/postAuthRefresh.test.mjs.map +0 -1
- package/dist/handlers/postOAuth2Acknowledge.mjs +0 -150
- package/dist/handlers/postOAuth2Acknowledge.mjs.map +0 -1
- package/dist/handlers/postOAuth2Acknowledge.test.mjs +0 -140
- package/dist/handlers/postOAuth2Acknowledge.test.mjs.map +0 -1
- package/dist/handlers/postOAuth2Token.mjs +0 -231
- package/dist/handlers/postOAuth2Token.mjs.map +0 -1
- package/dist/handlers/postOAuth2Token.test.mjs +0 -160
- package/dist/handlers/postOAuth2Token.test.mjs.map +0 -1
- package/dist/index.mjs +0 -15
- package/dist/index.mjs.map +0 -1
- package/dist/index.test.mjs +0 -747
- package/dist/index.test.mjs.map +0 -1
- package/dist/services/authCookies.mjs +0 -58
- package/dist/services/authCookies.mjs.map +0 -1
- package/dist/services/authCookies.test.mjs +0 -77
- package/dist/services/authCookies.test.mjs.map +0 -1
- package/dist/services/oAuth2ClientCredentialsGranter.mjs +0 -41
- package/dist/services/oAuth2ClientCredentialsGranter.mjs.map +0 -1
- package/dist/services/oAuth2CodeGranter.mjs +0 -98
- package/dist/services/oAuth2CodeGranter.mjs.map +0 -1
- package/dist/services/oAuth2CodeGranter.test.mjs +0 -83
- package/dist/services/oAuth2CodeGranter.test.mjs.map +0 -1
- package/dist/services/oAuth2Granters.mjs +0 -127
- package/dist/services/oAuth2Granters.mjs.map +0 -1
- package/dist/services/oAuth2PasswordGranter.mjs +0 -40
- package/dist/services/oAuth2PasswordGranter.mjs.map +0 -1
- package/dist/services/oAuth2RefreshTokenGranter.mjs +0 -47
- package/dist/services/oAuth2RefreshTokenGranter.mjs.map +0 -1
- package/dist/services/oAuth2TokenGranter.mjs +0 -78
- package/dist/services/oAuth2TokenGranter.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -19,18 +19,21 @@ authenticate and allow client applications to act on behalf of them.
|
|
|
19
19
|
|
|
20
20
|

|
|
21
21
|
|
|
22
|
-
The module provides
|
|
22
|
+
The module provides:
|
|
23
23
|
|
|
24
|
-
-
|
|
25
|
-
`postOAuth2Tokentoken`)
|
|
26
|
-
|
|
27
|
-
-
|
|
28
|
-
|
|
24
|
+
- 2 OAuth2 handlers implementing the 2 OAuth2 standard endpoints
|
|
25
|
+
(`getOAuth2authorize`, `postOAuth2Tokentoken`) to be used by OAuth2 client
|
|
26
|
+
applications,
|
|
27
|
+
- 4 authentication endpoints to be used by the authorization server directly to
|
|
28
|
+
authenticate users (`postAuthLogin`, `postAuthRefresh`, `postAuthLogout`) and
|
|
29
|
+
acknowledge the client requests (`postOAuth2Acknowledge`),
|
|
30
|
+
- 5 OAuth2 services implementing the standard grant types. You can create your
|
|
31
|
+
own granter services to create additional grant types.
|
|
29
32
|
|
|
30
33
|
This module requires you to implement some services it relies on:
|
|
31
34
|
|
|
32
35
|
- `oAuth2AccessToken` that generates and checks the `access_token` and the
|
|
33
|
-
`oAuth2RefreshToken` for the `refresh_token
|
|
36
|
+
`oAuth2RefreshToken` for the `refresh_token`, both have the same interface,
|
|
34
37
|
- `checkApplication` service that is supposed to check whether an application
|
|
35
38
|
can be used or not for a given grant type, a given scope and redirect URI,
|
|
36
39
|
- `oAuth2PasswordService` aimed to check the `password` grant type with your own
|
|
@@ -48,7 +51,7 @@ Install the module in your project:
|
|
|
48
51
|
npm i @whook/oauth2
|
|
49
52
|
```
|
|
50
53
|
|
|
51
|
-
Declare the plugin into your `index.ts` file:
|
|
54
|
+
Declare the plugin into your `src/index.ts` file:
|
|
52
55
|
|
|
53
56
|
```diff
|
|
54
57
|
// (...)
|
|
@@ -60,18 +63,29 @@ Declare the plugin into your `index.ts` file:
|
|
|
60
63
|
// (...)
|
|
61
64
|
```
|
|
62
65
|
|
|
63
|
-
Declare this module types in your `src/whook.d.ts` type
|
|
64
|
-
|
|
66
|
+
Declare this module types in your `src/whook.d.ts` type definitions:
|
|
67
|
+
|
|
65
68
|
```diff
|
|
66
|
-
+
|
|
69
|
+
+import type {
|
|
70
|
+
+ AuthCookiesEnv,
|
|
71
|
+
+ OAuth2Config,
|
|
72
|
+
+} from '@whook/oauth2';
|
|
67
73
|
|
|
68
74
|
declare module '@whook/whook' {
|
|
69
75
|
|
|
76
|
+
export interface WhookEnv
|
|
77
|
+
extends WhookBaseEnv,
|
|
78
|
+
// (...)
|
|
79
|
+
+ AuthCookiesEnv,
|
|
80
|
+
WhookSwaggerUIEnv {}
|
|
81
|
+
|
|
70
82
|
// ...
|
|
71
83
|
|
|
72
84
|
export interface WhookConfigs
|
|
73
85
|
- extends WhookBaseConfigs {}
|
|
74
|
-
+ extends WhookBaseConfigs,
|
|
86
|
+
+ extends WhookBaseConfigs,
|
|
87
|
+
+ AuthCookiesConfig,
|
|
88
|
+
+ OAuth2Config {}
|
|
75
89
|
|
|
76
90
|
// ...
|
|
77
91
|
|
|
@@ -112,15 +126,15 @@ The `oAuth2Granters` service gather the various granters services you can use in
|
|
|
112
126
|
your application but you can write your own that uses a subset or a superset of
|
|
113
127
|
these granters.
|
|
114
128
|
|
|
115
|
-
Here, for example
|
|
129
|
+
Here, for example a handler that implement a verify token mechanism in order to
|
|
116
130
|
validate a user subscription:
|
|
117
131
|
|
|
118
132
|
```ts
|
|
119
133
|
import { autoService } from 'knifecycle';
|
|
120
134
|
import { noop } from '@whook/whook';
|
|
121
|
-
import YError from 'yerror';
|
|
135
|
+
import { YError } from 'yerror';
|
|
122
136
|
import type { LogService } from 'common-services';
|
|
123
|
-
import type { AuthenticationData } from './authentication';
|
|
137
|
+
import type { AuthenticationData } from './authentication.js';
|
|
124
138
|
import type {
|
|
125
139
|
OAuth2GranterService,
|
|
126
140
|
CheckApplicationService,
|
|
@@ -157,43 +171,39 @@ async function initOAuth2VerifyTokenGranter({
|
|
|
157
171
|
jwtToken,
|
|
158
172
|
pg,
|
|
159
173
|
log = noop,
|
|
160
|
-
}: OAuth2VerifyTokenGranterDependencies): Promise<
|
|
161
|
-
OAuth2VerifyTokenGranterService
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
if (err.code === 'E_BAD_TOKEN') {
|
|
192
|
-
throw YError.wrap(err as Error, 'E_BAD_REFRESH_TOKEN');
|
|
174
|
+
}: OAuth2VerifyTokenGranterDependencies): Promise<OAuth2VerifyTokenGranterService> {
|
|
175
|
+
const authenticateWithVerifyToken: OAuth2VerifyTokenGranterService['authenticator']['authenticate'] =
|
|
176
|
+
async ({ verifyToken }, authenticationData) => {
|
|
177
|
+
try {
|
|
178
|
+
// The client must be authenticated
|
|
179
|
+
if (!authenticationData) {
|
|
180
|
+
throw new YError('E_UNAUTHORIZED');
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const newAuthenticationData = await jwtToken.verify(verifyToken);
|
|
184
|
+
|
|
185
|
+
await checkApplication({
|
|
186
|
+
applicationId: authenticationData.applicationId,
|
|
187
|
+
type: 'verify',
|
|
188
|
+
scope: newAuthenticationData.scope,
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
const result = await pg.query(USER_VERIFY_QUERY, {
|
|
192
|
+
userId: newAuthenticationData.userId,
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
if (result.rowCount === 0) {
|
|
196
|
+
throw new YError('E_ALREADY_VERIFIED', authenticationData.userId);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
return newAuthenticationData;
|
|
200
|
+
} catch (err) {
|
|
201
|
+
if (err.code === 'E_BAD_TOKEN') {
|
|
202
|
+
throw YError.wrap(err as Error, 'E_BAD_REFRESH_TOKEN');
|
|
203
|
+
}
|
|
204
|
+
throw err;
|
|
193
205
|
}
|
|
194
|
-
|
|
195
|
-
}
|
|
196
|
-
};
|
|
206
|
+
};
|
|
197
207
|
|
|
198
208
|
log('debug', '👫 - OAuth2VerifyTokenGranter Service Initialized!');
|
|
199
209
|
|
|
@@ -213,6 +223,7 @@ For internal use, you may prefer use cookies based auth handlers like
|
|
|
213
223
|
`postLogin`, `postLogout` and `postRefresh`.
|
|
214
224
|
|
|
215
225
|
To do so, configure the `ROOT_AUTHENTICATION_DATA` and `COOKIES` configurations:
|
|
226
|
+
|
|
216
227
|
```diff
|
|
217
228
|
// src/production/config.ts
|
|
218
229
|
+ COOKIES: {
|
|
@@ -225,8 +236,9 @@ To do so, configure the `ROOT_AUTHENTICATION_DATA` and `COOKIES` configurations:
|
|
|
225
236
|
```
|
|
226
237
|
|
|
227
238
|
Than import the `postLogin`, `postLogout` and `postRefresh` handlers like so:
|
|
239
|
+
|
|
228
240
|
```ts
|
|
229
|
-
// src/handlers/postRefresh.ts
|
|
241
|
+
// src/handlers/postRefresh.ts
|
|
230
242
|
import {
|
|
231
243
|
initPostAuthRefresh,
|
|
232
244
|
postAuthRefreshDefinition,
|
|
@@ -249,15 +261,17 @@ export const definition: WhookAPIHandlerDefinition = {
|
|
|
249
261
|
export default initPostAuthRefresh;
|
|
250
262
|
```
|
|
251
263
|
|
|
252
|
-
Additionnaly, you could create any handler in the `/auth` path in order to
|
|
264
|
+
Additionnaly, you could create any handler in the `/auth` path in order to
|
|
265
|
+
receive the auth cookies. For example, you may want to serve user profiles
|
|
266
|
+
there.
|
|
253
267
|
|
|
254
268
|
## Customizing handlers
|
|
255
269
|
|
|
256
270
|
The endpoints definitions are designed to support the standard OAuth2
|
|
257
271
|
definitions but can be easily overriden.
|
|
258
272
|
|
|
259
|
-
You will have to protect the `postOAuth2Acknowledge` with your own security
|
|
260
|
-
mechanism
|
|
273
|
+
You will also have to protect the `postOAuth2Acknowledge` with your own security
|
|
274
|
+
mechanism:
|
|
261
275
|
|
|
262
276
|
```ts
|
|
263
277
|
import {
|
|
@@ -273,6 +287,7 @@ export const definition: WhookAPIHandlerDefinition = {
|
|
|
273
287
|
...postOAuth2AcknowledgeDefinition,
|
|
274
288
|
operation: {
|
|
275
289
|
...postOAuth2AcknowledgeDefinition.operation,
|
|
290
|
+
// Complete the definition to protect the endpoint
|
|
276
291
|
security: [
|
|
277
292
|
{
|
|
278
293
|
bearerAuth: ['user'],
|
|
@@ -285,22 +300,29 @@ export const definition: WhookAPIHandlerDefinition = {
|
|
|
285
300
|
content: {
|
|
286
301
|
'application/json': {
|
|
287
302
|
schema: {
|
|
288
|
-
...((
|
|
289
|
-
.
|
|
290
|
-
|
|
291
|
-
]
|
|
303
|
+
...((
|
|
304
|
+
postOAuth2AcknowledgeDefinition.operation
|
|
305
|
+
.requestBody as OpenAPIV3.RequestBodyObject
|
|
306
|
+
).content['application/json']
|
|
307
|
+
.schema as OpenAPIV3.NonArraySchemaObject),
|
|
292
308
|
required: [
|
|
293
309
|
'userId',
|
|
294
|
-
...(
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
310
|
+
...(
|
|
311
|
+
(
|
|
312
|
+
postOAuth2AcknowledgeDefinition.operation
|
|
313
|
+
.requestBody as OpenAPIV3.RequestBodyObject
|
|
314
|
+
).content['application/json']
|
|
315
|
+
.schema as OpenAPIV3.NonArraySchemaObject
|
|
316
|
+
).required,
|
|
298
317
|
],
|
|
299
318
|
properties: {
|
|
300
|
-
...(
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
319
|
+
...(
|
|
320
|
+
(
|
|
321
|
+
postOAuth2AcknowledgeDefinition.operation
|
|
322
|
+
.requestBody as OpenAPIV3.RequestBodyObject
|
|
323
|
+
).content['application/json']
|
|
324
|
+
.schema as OpenAPIV3.NonArraySchemaObject
|
|
325
|
+
).properties,
|
|
304
326
|
userId: {
|
|
305
327
|
type: 'string',
|
|
306
328
|
},
|
|
@@ -314,7 +336,7 @@ export const definition: WhookAPIHandlerDefinition = {
|
|
|
314
336
|
```
|
|
315
337
|
|
|
316
338
|
You will probably need to also protect the `postOAuth2Token` endpoint with your
|
|
317
|
-
own security mecanism
|
|
339
|
+
own security mecanism:
|
|
318
340
|
|
|
319
341
|
```ts
|
|
320
342
|
// In a `src/handlers/postOAuth2Token.ts` fileimport {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import YError from 'yerror';
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
import { YError } from 'yerror';
|
|
3
3
|
import type { WhookAPIHandlerDefinition, WhookAPIParameterDefinition, WhookResponse, WhookErrorsDescriptors, WhookErrorDescriptor } from '@whook/whook';
|
|
4
|
-
import type { OAuth2Options, OAuth2GranterService } from '../services/oAuth2Granters';
|
|
4
|
+
import type { OAuth2Options, OAuth2GranterService } from '../services/oAuth2Granters.js';
|
|
5
5
|
import type { LogService } from 'common-services';
|
|
6
6
|
export declare const responseTypeParameter: WhookAPIParameterDefinition;
|
|
7
7
|
export declare const clientIdParameter: WhookAPIParameterDefinition;
|
|
@@ -22,7 +22,7 @@ declare const _default: import("knifecycle").ServiceInitializer<{
|
|
|
22
22
|
state: string;
|
|
23
23
|
} & Record<string, unknown>) => Promise<WhookResponse<302, {
|
|
24
24
|
location: string;
|
|
25
|
-
}, void | import("
|
|
25
|
+
}, void | import("stream").Readable | import("type-fest").JsonValue>>>;
|
|
26
26
|
export default _default;
|
|
27
27
|
export declare function camelCaseObjectProperties<T>(object: Record<string, T>): Record<string, T>;
|
|
28
28
|
export declare function setURLError(url: URL, err: YError | Error, oAuth2Error: WhookErrorDescriptor): void;
|
|
@@ -1,185 +1,142 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
exports.camelCaseObjectProperties = camelCaseObjectProperties;
|
|
7
|
-
exports.scopeParameter = exports.responseTypeParameter = exports.redirectURIParameter = exports.definition = exports.default = exports.clientIdParameter = void 0;
|
|
8
|
-
exports.setURLError = setURLError;
|
|
9
|
-
exports.stateParameter = void 0;
|
|
10
|
-
|
|
11
|
-
var _knifecycle = require("knifecycle");
|
|
12
|
-
|
|
13
|
-
var _camelcase = _interopRequireDefault(require("camelcase"));
|
|
14
|
-
|
|
15
|
-
var _yerror = _interopRequireDefault(require("yerror"));
|
|
16
|
-
|
|
17
|
-
var _whook = require("@whook/whook");
|
|
18
|
-
|
|
19
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
20
|
-
|
|
1
|
+
import { autoHandler } from 'knifecycle';
|
|
2
|
+
import camelCase from 'camelcase';
|
|
3
|
+
import { YError } from 'yerror';
|
|
4
|
+
import { refersTo } from '@whook/whook';
|
|
21
5
|
/* Architecture Note #1: OAuth2 authorize
|
|
22
6
|
This endpoint simply redirect the user to the authentication
|
|
23
7
|
server page by first checking the application details are
|
|
24
8
|
fine.
|
|
25
9
|
*/
|
|
26
|
-
const responseTypeParameter = {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
10
|
+
export const responseTypeParameter = {
|
|
11
|
+
name: 'responseType',
|
|
12
|
+
parameter: {
|
|
13
|
+
in: 'query',
|
|
14
|
+
name: 'response_type',
|
|
15
|
+
required: true,
|
|
16
|
+
schema: {
|
|
17
|
+
type: 'string',
|
|
18
|
+
enum: ['code', 'token'],
|
|
19
|
+
},
|
|
20
|
+
},
|
|
37
21
|
};
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
}
|
|
22
|
+
export const clientIdParameter = {
|
|
23
|
+
name: 'clientId',
|
|
24
|
+
parameter: {
|
|
25
|
+
in: 'query',
|
|
26
|
+
name: 'client_id',
|
|
27
|
+
required: true,
|
|
28
|
+
schema: {
|
|
29
|
+
type: 'string',
|
|
30
|
+
},
|
|
31
|
+
},
|
|
49
32
|
};
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
}
|
|
33
|
+
export const redirectURIParameter = {
|
|
34
|
+
name: 'redirectURI',
|
|
35
|
+
parameter: {
|
|
36
|
+
in: 'query',
|
|
37
|
+
name: 'redirect_uri',
|
|
38
|
+
required: false,
|
|
39
|
+
schema: {
|
|
40
|
+
type: 'string',
|
|
41
|
+
pattern: '^https?://',
|
|
42
|
+
format: 'uri',
|
|
43
|
+
},
|
|
44
|
+
},
|
|
63
45
|
};
|
|
64
|
-
|
|
65
|
-
const scopeParameter = {
|
|
66
|
-
name: 'scope',
|
|
67
|
-
parameter: {
|
|
68
|
-
in: 'query',
|
|
46
|
+
export const scopeParameter = {
|
|
69
47
|
name: 'scope',
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
48
|
+
parameter: {
|
|
49
|
+
in: 'query',
|
|
50
|
+
name: 'scope',
|
|
51
|
+
description: 'See https://tools.ietf.org/html/rfc6749#section-3.3',
|
|
52
|
+
required: false,
|
|
53
|
+
schema: {
|
|
54
|
+
type: 'string',
|
|
55
|
+
},
|
|
56
|
+
},
|
|
76
57
|
};
|
|
77
|
-
|
|
78
|
-
const stateParameter = {
|
|
79
|
-
name: 'state',
|
|
80
|
-
parameter: {
|
|
81
|
-
in: 'query',
|
|
58
|
+
export const stateParameter = {
|
|
82
59
|
name: 'state',
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
60
|
+
parameter: {
|
|
61
|
+
in: 'query',
|
|
62
|
+
name: 'state',
|
|
63
|
+
required: true,
|
|
64
|
+
schema: {
|
|
65
|
+
type: 'string',
|
|
66
|
+
},
|
|
67
|
+
},
|
|
88
68
|
};
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
summary: `Implements the [Authorization Endpoint](https://tools.ietf.org/html/rfc6749#section-3.1)
|
|
69
|
+
export const definition = {
|
|
70
|
+
method: 'get',
|
|
71
|
+
path: '/oauth2/authorize',
|
|
72
|
+
operation: {
|
|
73
|
+
operationId: 'getOAuth2Authorize',
|
|
74
|
+
summary: `Implements the [Authorization Endpoint](https://tools.ietf.org/html/rfc6749#section-3.1)
|
|
96
75
|
as defined per the OAuth2 RFC.`,
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
76
|
+
tags: ['oauth2'],
|
|
77
|
+
parameters: [
|
|
78
|
+
refersTo(responseTypeParameter),
|
|
79
|
+
refersTo(clientIdParameter),
|
|
80
|
+
refersTo(redirectURIParameter),
|
|
81
|
+
refersTo(scopeParameter),
|
|
82
|
+
refersTo(stateParameter),
|
|
83
|
+
],
|
|
84
|
+
responses: {
|
|
85
|
+
'302': {
|
|
86
|
+
description: 'Redirects the user to the authorization interface.',
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
},
|
|
105
90
|
};
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
if (!granter) {
|
|
131
|
-
throw new _yerror.default('E_UNKNOWN_AUTHORIZER_TYPE', responseType);
|
|
91
|
+
export default autoHandler(getOAuth2Authorize);
|
|
92
|
+
async function getOAuth2Authorize({ OAUTH2, ERRORS_DESCRIPTORS, oAuth2Granters, log, }, { response_type: responseType, client_id: clientId, redirect_uri: demandedRedirectURI = '', scope: demandedScope = '', state, ...authorizeParameters }) {
|
|
93
|
+
const url = new URL(OAUTH2.authenticateURL);
|
|
94
|
+
try {
|
|
95
|
+
const granter = oAuth2Granters.find((granter) => granter.authorizer && granter.authorizer.responseType === responseType);
|
|
96
|
+
if (!granter) {
|
|
97
|
+
throw new YError('E_UNKNOWN_AUTHORIZER_TYPE', responseType);
|
|
98
|
+
}
|
|
99
|
+
const { applicationId, redirectURI, scope } = await granter.authorizer.authorize({
|
|
100
|
+
clientId,
|
|
101
|
+
redirectURI: demandedRedirectURI,
|
|
102
|
+
scope: demandedScope,
|
|
103
|
+
}, camelCaseObjectProperties(authorizeParameters));
|
|
104
|
+
url.searchParams.set('type', responseType);
|
|
105
|
+
url.searchParams.set('redirect_uri', redirectURI);
|
|
106
|
+
url.searchParams.set('scope', scope);
|
|
107
|
+
url.searchParams.set('client_id', applicationId);
|
|
108
|
+
}
|
|
109
|
+
catch (err) {
|
|
110
|
+
log('debug', '👫 - OAuth2 initialization error', err.code);
|
|
111
|
+
log('debug-stack', err.stack || 'no_stack_trace');
|
|
112
|
+
url.searchParams.set('redirect_uri', demandedRedirectURI);
|
|
113
|
+
setURLError(url, err, ERRORS_DESCRIPTORS[err.code] || ERRORS_DESCRIPTORS.E_OAUTH2);
|
|
132
114
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
applicationId,
|
|
136
|
-
redirectURI,
|
|
137
|
-
scope
|
|
138
|
-
} = await granter.authorizer.authorize({
|
|
139
|
-
clientId,
|
|
140
|
-
redirectURI: demandedRedirectURI,
|
|
141
|
-
scope: demandedScope
|
|
142
|
-
}, camelCaseObjectProperties(authorizeParameters));
|
|
143
|
-
url.searchParams.set('type', responseType);
|
|
144
|
-
url.searchParams.set('redirect_uri', redirectURI);
|
|
145
|
-
url.searchParams.set('scope', scope);
|
|
146
|
-
url.searchParams.set('client_id', applicationId);
|
|
147
|
-
} catch (err) {
|
|
148
|
-
log('debug', '👫 - OAuth2 initialization error', err.code);
|
|
149
|
-
log('debug-stack', err.stack || 'no_stack_trace');
|
|
150
|
-
url.searchParams.set('redirect_uri', demandedRedirectURI);
|
|
151
|
-
setURLError(url, err, ERRORS_DESCRIPTORS[err.code] || ERRORS_DESCRIPTORS.E_OAUTH2);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
if (state) {
|
|
155
|
-
url.searchParams.set('state', state);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
return {
|
|
159
|
-
status: 302,
|
|
160
|
-
headers: {
|
|
161
|
-
location: url.href
|
|
115
|
+
if (state) {
|
|
116
|
+
url.searchParams.set('state', state);
|
|
162
117
|
}
|
|
163
|
-
|
|
164
|
-
|
|
118
|
+
return {
|
|
119
|
+
status: 302,
|
|
120
|
+
headers: {
|
|
121
|
+
location: url.href,
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
// The OAuth2 standard uses snake case names so we are
|
|
165
126
|
// converting them to the project standards asap
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
return camelCasedObject;
|
|
173
|
-
}, {});
|
|
127
|
+
export function camelCaseObjectProperties(object) {
|
|
128
|
+
return Object.keys(object).reduce((camelCasedObject, key) => {
|
|
129
|
+
const newKey = key === 'redirect_uri' ? 'redirectURI' : camelCase(key);
|
|
130
|
+
camelCasedObject[newKey] = object[key];
|
|
131
|
+
return camelCasedObject;
|
|
132
|
+
}, {});
|
|
174
133
|
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
}));
|
|
183
|
-
}
|
|
134
|
+
export function setURLError(url, err, oAuth2Error) {
|
|
135
|
+
url.searchParams.set('error', oAuth2Error.code);
|
|
136
|
+
if (oAuth2Error.description) {
|
|
137
|
+
url.searchParams.set('error_decription', oAuth2Error.description.replace(/\$([0-9]+)/g, (_, paramIndex) => {
|
|
138
|
+
return (err.params || [])[parseInt(paramIndex, 10)];
|
|
139
|
+
}));
|
|
140
|
+
}
|
|
184
141
|
}
|
|
185
142
|
//# sourceMappingURL=getOAuth2Authorize.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getOAuth2Authorize.js","names":["responseTypeParameter","name","parameter","in","required","schema","type","enum","clientIdParameter","redirectURIParameter","pattern","format","scopeParameter","description","stateParameter","definition","method","path","operation","operationId","summary","tags","parameters","refersTo","responses","autoHandler","getOAuth2Authorize","OAUTH2","ERRORS_DESCRIPTORS","oAuth2Granters","log","response_type","responseType","client_id","clientId","redirect_uri","demandedRedirectURI","scope","demandedScope","state","authorizeParameters","url","URL","authenticateURL","granter","find","authorizer","YError","applicationId","redirectURI","authorize","camelCaseObjectProperties","searchParams","set","err","code","stack","setURLError","E_OAUTH2","status","headers","location","href","object","Object","keys","reduce","camelCasedObject","key","newKey","camelCase","oAuth2Error","replace","_","paramIndex","params","parseInt"],"sources":["../../src/handlers/getOAuth2Authorize.ts"],"sourcesContent":["import { autoHandler } from 'knifecycle';\nimport camelCase from 'camelcase';\nimport YError from 'yerror';\nimport { refersTo } from '@whook/whook';\nimport type {\n WhookAPIHandlerDefinition,\n WhookAPIParameterDefinition,\n WhookResponse,\n WhookErrorsDescriptors,\n WhookErrorDescriptor,\n} from '@whook/whook';\nimport type {\n OAuth2Options,\n OAuth2GranterService,\n} from '../services/oAuth2Granters';\nimport type { LogService } from 'common-services';\n\n/* Architecture Note #1: OAuth2 authorize\nThis endpoint simply redirect the user to the authentication\n server page by first checking the application details are\n fine.\n*/\n\nexport const responseTypeParameter: WhookAPIParameterDefinition = {\n name: 'responseType',\n parameter: {\n in: 'query',\n name: 'response_type',\n required: true,\n schema: {\n type: 'string',\n enum: ['code', 'token'],\n },\n },\n};\nexport const clientIdParameter: WhookAPIParameterDefinition = {\n name: 'clientId',\n parameter: {\n in: 'query',\n name: 'client_id',\n required: true,\n schema: {\n type: 'string',\n },\n },\n};\nexport const redirectURIParameter: WhookAPIParameterDefinition = {\n name: 'redirectURI',\n parameter: {\n in: 'query',\n name: 'redirect_uri',\n required: false,\n schema: {\n type: 'string',\n pattern: '^https?://',\n format: 'uri',\n },\n },\n};\nexport const scopeParameter: WhookAPIParameterDefinition = {\n name: 'scope',\n parameter: {\n in: 'query',\n name: 'scope',\n description: 'See https://tools.ietf.org/html/rfc6749#section-3.3',\n required: false,\n schema: {\n type: 'string',\n },\n },\n};\nexport const stateParameter: WhookAPIParameterDefinition = {\n name: 'state',\n parameter: {\n in: 'query',\n name: 'state',\n required: true,\n schema: {\n type: 'string',\n },\n },\n};\n\nexport const definition: WhookAPIHandlerDefinition = {\n method: 'get',\n path: '/oauth2/authorize',\n operation: {\n operationId: 'getOAuth2Authorize',\n summary: `Implements the [Authorization Endpoint](https://tools.ietf.org/html/rfc6749#section-3.1)\n as defined per the OAuth2 RFC.`,\n tags: ['oauth2'],\n parameters: [\n refersTo(responseTypeParameter),\n refersTo(clientIdParameter),\n refersTo(redirectURIParameter),\n refersTo(scopeParameter),\n refersTo(stateParameter),\n ],\n responses: {\n '302': {\n description: 'Redirects the user to the authorization interface.',\n },\n },\n },\n};\n\nexport default autoHandler(getOAuth2Authorize);\n\nasync function getOAuth2Authorize(\n {\n OAUTH2,\n ERRORS_DESCRIPTORS,\n oAuth2Granters,\n log,\n }: {\n OAUTH2: OAuth2Options;\n ERRORS_DESCRIPTORS: WhookErrorsDescriptors;\n oAuth2Granters: OAuth2GranterService[];\n log: LogService;\n },\n {\n response_type: responseType,\n client_id: clientId,\n redirect_uri: demandedRedirectURI = '',\n scope: demandedScope = '',\n state,\n ...authorizeParameters\n }: {\n response_type: string;\n client_id: string;\n redirect_uri?: string;\n scope?: string;\n state: string;\n } & Record<string, unknown>,\n): Promise<WhookResponse<302, { location: string }>> {\n const url = new URL(OAUTH2.authenticateURL);\n\n try {\n const granter = oAuth2Granters.find(\n (granter) =>\n granter.authorizer && granter.authorizer.responseType === responseType,\n );\n\n if (!granter) {\n throw new YError('E_UNKNOWN_AUTHORIZER_TYPE', responseType);\n }\n\n const { applicationId, redirectURI, scope } = await (\n granter.authorizer as NonNullable<OAuth2GranterService['authorizer']>\n ).authorize(\n {\n clientId,\n redirectURI: demandedRedirectURI,\n scope: demandedScope,\n },\n camelCaseObjectProperties(authorizeParameters),\n );\n\n url.searchParams.set('type', responseType);\n url.searchParams.set('redirect_uri', redirectURI);\n url.searchParams.set('scope', scope);\n url.searchParams.set('client_id', applicationId);\n } catch (err) {\n log('debug', '👫 - OAuth2 initialization error', (err as YError).code);\n log('debug-stack', (err as Error).stack || 'no_stack_trace');\n\n url.searchParams.set('redirect_uri', demandedRedirectURI);\n setURLError(\n url,\n err as YError,\n ERRORS_DESCRIPTORS[(err as YError).code] || ERRORS_DESCRIPTORS.E_OAUTH2,\n );\n }\n\n if (state) {\n url.searchParams.set('state', state);\n }\n\n return {\n status: 302,\n headers: {\n location: url.href,\n },\n };\n}\n\n// The OAuth2 standard uses snake case names so we are\n// converting them to the project standards asap\nexport function camelCaseObjectProperties<T>(\n object: Record<string, T>,\n): Record<string, T> {\n return Object.keys(object).reduce((camelCasedObject, key) => {\n const newKey = key === 'redirect_uri' ? 'redirectURI' : camelCase(key);\n\n camelCasedObject[newKey] = object[key];\n return camelCasedObject;\n }, {});\n}\n\nexport function setURLError(\n url: URL,\n err: YError | Error,\n oAuth2Error: WhookErrorDescriptor,\n): void {\n url.searchParams.set('error', oAuth2Error.code);\n if (oAuth2Error.description) {\n url.searchParams.set(\n 'error_decription',\n oAuth2Error.description.replace(/\\$([0-9]+)/g, (_, paramIndex) => {\n return ((err as YError).params || [])[parseInt(paramIndex, 10)];\n }),\n );\n }\n}\n"],"mappings":";;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;;;AAcA;AACA;AACA;AACA;AACA;AAEO,MAAMA,qBAAkD,GAAG;EAChEC,IAAI,EAAE,cAD0D;EAEhEC,SAAS,EAAE;IACTC,EAAE,EAAE,OADK;IAETF,IAAI,EAAE,eAFG;IAGTG,QAAQ,EAAE,IAHD;IAITC,MAAM,EAAE;MACNC,IAAI,EAAE,QADA;MAENC,IAAI,EAAE,CAAC,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