@webda/google-auth 4.0.0-beta.2 → 4.0.0-beta.3
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 +119 -0
- package/lib/{google-auth.d.ts → google-auth.service.d.ts} +32 -21
- package/lib/google-auth.service.d.ts.map +1 -0
- package/lib/{google-auth.js → google-auth.service.js} +34 -20
- package/lib/google-auth.service.js.map +1 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/package.json +28 -36
- package/webda.module.json +155 -141
- package/lib/google-auth.d.ts.map +0 -1
- package/lib/google-auth.js.map +0 -1
- package/lib/google-auth.spec.d.ts +0 -2
- package/lib/google-auth.spec.d.ts.map +0 -1
- package/lib/google-auth.spec.js +0 -131
- package/lib/google-auth.spec.js.map +0 -1
package/README.md
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# @webda/google-auth module
|
|
2
|
+
|
|
3
|
+
This module is part of Webda Application Framework that allows you to quickly develop applications with all modern prerequisites: Security, Extensibility, GraphQL, REST, CloudNative [https://webda.io](https://webda.io)
|
|
4
|
+
|
|
5
|
+
<img src="https://webda.io/images/webda.svg" width="128" />
|
|
6
|
+
|
|
7
|
+

|
|
8
|
+
|
|
9
|
+
[](https://gitter.im/loopingz/webda?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
|
10
|
+
[](https://codecov.io/gh/loopingz/webda.io)
|
|
11
|
+
[](https://sonarcloud.io/summary/new_code?id=loopingz_webda.io)
|
|
12
|
+

|
|
13
|
+
|
|
14
|
+
<!-- README_HEADER -->
|
|
15
|
+
|
|
16
|
+
# @webda/google-auth
|
|
17
|
+
|
|
18
|
+
> Google OAuth 2.0 authentication provider for Webda — adds `GET /auth/google` and callback handling to your application so users can sign in with their Google account.
|
|
19
|
+
|
|
20
|
+
## When to use it
|
|
21
|
+
|
|
22
|
+
- You want to add "Sign in with Google" to a Webda application without hand-rolling OAuth flows.
|
|
23
|
+
- You need an offline access token (e.g. for server-side Google API calls on behalf of the user).
|
|
24
|
+
- You are building a multi-provider auth system alongside other `@webda/oauth` providers.
|
|
25
|
+
|
|
26
|
+
## Install
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
pnpm add @webda/google-auth
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Configuration
|
|
33
|
+
|
|
34
|
+
```json
|
|
35
|
+
{
|
|
36
|
+
"services": {
|
|
37
|
+
"Authentication": {
|
|
38
|
+
"type": "Authentication",
|
|
39
|
+
"providers": {
|
|
40
|
+
"google": {
|
|
41
|
+
"type": "GoogleAuthentication",
|
|
42
|
+
"client_id": "${GOOGLE_CLIENT_ID}",
|
|
43
|
+
"client_secret": "${GOOGLE_CLIENT_SECRET}",
|
|
44
|
+
"access_type": "online",
|
|
45
|
+
"redirect_uri": "https://myapp.example.com/auth/google/callback"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
| Parameter | Type | Default | Required | Description |
|
|
54
|
+
|---|---|---|---|---|
|
|
55
|
+
| `client_id` | string | — | Yes | Google OAuth 2.0 Client ID from Google Cloud Console |
|
|
56
|
+
| `client_secret` | string | — | Yes | Google OAuth 2.0 Client Secret |
|
|
57
|
+
| `access_type` | `"online"` \| `"offline"` | `"online"` | No | `"offline"` returns a refresh token for server-side API access |
|
|
58
|
+
| `project_id` | string | — | No | Google Cloud Project ID (informational) |
|
|
59
|
+
| `auth_options` | object | — | No | Additional parameters forwarded to the Google authorization URL |
|
|
60
|
+
| `redirects.use_referer` | boolean | — | No | Redirect to the HTTP Referer after successful login |
|
|
61
|
+
| `redirects.whitelist` | string[] | — | No | Allowed redirect URLs (regexp strings) |
|
|
62
|
+
|
|
63
|
+
## Usage
|
|
64
|
+
|
|
65
|
+
```typescript
|
|
66
|
+
// 1. Register your OAuth credentials in Google Cloud Console:
|
|
67
|
+
// APIs & Services > Credentials > Create OAuth 2.0 Client ID
|
|
68
|
+
// Authorized redirect URI: https://myapp.example.com/auth/google/callback
|
|
69
|
+
|
|
70
|
+
// 2. Configure (see above). The framework auto-registers these routes:
|
|
71
|
+
// GET /auth/google → redirects to Google consent screen
|
|
72
|
+
// GET /auth/google/callback → handles the OAuth callback, creates a session
|
|
73
|
+
|
|
74
|
+
// 3. Listen to the auth event to customize post-login behaviour:
|
|
75
|
+
import { GoogleAuthentication } from "@webda/google-auth";
|
|
76
|
+
import { Bean, Inject } from "@webda/core";
|
|
77
|
+
|
|
78
|
+
@Bean
|
|
79
|
+
export class ProfileSync extends Service {
|
|
80
|
+
@Inject("Authentication")
|
|
81
|
+
auth: any;
|
|
82
|
+
|
|
83
|
+
async resolve(): Promise<this> {
|
|
84
|
+
await super.resolve();
|
|
85
|
+
// Fired after a successful Google login
|
|
86
|
+
this.auth.on("GoogleAuth.Tokens", async ({ tokens, context }) => {
|
|
87
|
+
// tokens.access_token, tokens.refresh_token (if access_type=offline)
|
|
88
|
+
const user = context.getCurrentUser();
|
|
89
|
+
// ... sync Google profile data to your User model
|
|
90
|
+
});
|
|
91
|
+
return this;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Reference
|
|
97
|
+
|
|
98
|
+
- API reference: see the auto-generated typedoc at `docs/pages/Modules/google-auth/`.
|
|
99
|
+
- Source: [`packages/google-auth`](https://github.com/loopingz/webda.io/tree/main/packages/google-auth)
|
|
100
|
+
- Related: [`@webda/core`](../core) Authentication service; [`@webda/gcp`](../gcp) for Cloud-side GCP integrations.
|
|
101
|
+
|
|
102
|
+
<!-- README_FOOTER -->
|
|
103
|
+
## Sponsors
|
|
104
|
+
|
|
105
|
+
<!--
|
|
106
|
+
Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor](mailto:sponsor@webda.io)
|
|
107
|
+
-->
|
|
108
|
+
|
|
109
|
+
Arize AI is a machine learning observability and model monitoring platform. It helps you visualize, monitor, and explain your machine learning models. [Learn more](https://arize.com)
|
|
110
|
+
|
|
111
|
+
[<img src="https://arize.com/hubfs/arize/brand/arize-logomark-1.png" width="200">](https://arize.com)
|
|
112
|
+
|
|
113
|
+
Loopingz is a software development company that provides consulting and development services. [Learn more](https://loopingz.com)
|
|
114
|
+
|
|
115
|
+
[<img src="https://loopingz.com/images/logo.png" width="200">](https://loopingz.com)
|
|
116
|
+
|
|
117
|
+
Tellae is an innovative consulting firm specialized in cities transportation issues. We provide our clients, both public and private, with solutions to support your strategic and operational decisions. [Learn more](https://tellae.fr)
|
|
118
|
+
|
|
119
|
+
[<img src="https://tellae.fr/" width="200">](https://tellae.fr)
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
import { OAuthEvents, OAuthService, OAuthServiceParameters, RequestFilter, WebContext } from "@webda/core";
|
|
1
|
+
import { EventWithContext, OAuthEvents, OAuthService, OAuthServiceParameters, RequestFilter, WebContext } from "@webda/core";
|
|
2
2
|
import { Credentials, OAuth2Client } from "google-auth-library";
|
|
3
|
-
export interface EventGoogleOAuthToken {
|
|
3
|
+
export interface EventGoogleOAuthToken extends EventWithContext<WebContext> {
|
|
4
4
|
/**
|
|
5
5
|
* Tokens retrieved from Google
|
|
6
6
|
*/
|
|
7
7
|
tokens: Credentials;
|
|
8
|
-
/**
|
|
9
|
-
* Request context
|
|
10
|
-
*/
|
|
11
|
-
context: WebContext;
|
|
12
8
|
}
|
|
13
9
|
/**
|
|
14
10
|
* Credentials to manage Google Auth
|
|
@@ -34,14 +30,19 @@ export declare class GoogleParameters extends OAuthServiceParameters {
|
|
|
34
30
|
*/
|
|
35
31
|
access_type?: "online" | "offline";
|
|
36
32
|
auth_options?: any;
|
|
37
|
-
redirects
|
|
33
|
+
redirects?: {
|
|
38
34
|
use_referer: boolean;
|
|
39
35
|
whitelist: string[];
|
|
40
36
|
defaults: {
|
|
41
37
|
[key: string]: string;
|
|
42
38
|
};
|
|
43
39
|
};
|
|
44
|
-
|
|
40
|
+
/**
|
|
41
|
+
* Load parameters with Google defaults
|
|
42
|
+
* @param params - the service parameters
|
|
43
|
+
* @returns this
|
|
44
|
+
*/
|
|
45
|
+
load(params?: any): this;
|
|
45
46
|
}
|
|
46
47
|
type GoogleAuthEvents = OAuthEvents & {
|
|
47
48
|
"GoogleAuth.Tokens": EventGoogleOAuthToken;
|
|
@@ -55,16 +56,17 @@ export default class GoogleAuthentication<T extends GoogleParameters = GooglePar
|
|
|
55
56
|
protected _client: OAuth2Client;
|
|
56
57
|
/**
|
|
57
58
|
* Return provider name
|
|
58
|
-
* @returns
|
|
59
|
+
* @returns the provider name
|
|
59
60
|
*/
|
|
60
61
|
getName(): string;
|
|
61
62
|
/**
|
|
62
63
|
* Allow every accounts.google.
|
|
64
|
+
* @returns the referer patterns allowed to call back
|
|
63
65
|
*/
|
|
64
66
|
getCallbackReferer(): RegExp[];
|
|
65
67
|
/**
|
|
66
68
|
* Get OAuth callback query parameters
|
|
67
|
-
* @returns
|
|
69
|
+
* @returns the callback query parameters
|
|
68
70
|
*/
|
|
69
71
|
getCallbackQueryParams(): {
|
|
70
72
|
name: string;
|
|
@@ -72,29 +74,32 @@ export default class GoogleAuthentication<T extends GoogleParameters = GooglePar
|
|
|
72
74
|
}[];
|
|
73
75
|
/**
|
|
74
76
|
* Expose on /google by default
|
|
77
|
+
* @returns the default url
|
|
75
78
|
*/
|
|
76
79
|
getDefaultUrl(): string;
|
|
77
80
|
/**
|
|
78
81
|
* We manage Google Auth Token
|
|
82
|
+
* @returns true
|
|
79
83
|
*/
|
|
80
84
|
hasToken(): boolean;
|
|
81
85
|
/**
|
|
82
|
-
*
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
*
|
|
87
|
-
* @param redirect_uri
|
|
88
|
-
* @param state
|
|
86
|
+
* Generate the Google authorization url
|
|
87
|
+
* @param redirect_uri - the url Google will redirect to
|
|
88
|
+
* @param state - the random state to verify on callback
|
|
89
|
+
* @param _ctx - the request context
|
|
90
|
+
* @returns the authorization url
|
|
89
91
|
*/
|
|
90
92
|
generateAuthUrl(redirect_uri: string, state: string, _ctx: WebContext): string;
|
|
91
93
|
/**
|
|
92
94
|
* Return a google oauth client
|
|
93
|
-
* @param redirect_uri
|
|
95
|
+
* @param redirect_uri - the redirect url to use
|
|
96
|
+
* @returns a new OAuth2 client
|
|
94
97
|
*/
|
|
95
98
|
getOAuthClient(redirect_uri?: string): OAuth2Client;
|
|
96
99
|
/**
|
|
97
100
|
* @inheritdoc
|
|
101
|
+
* @param ctx - the request context
|
|
102
|
+
* @returns the identity and profile
|
|
98
103
|
*/
|
|
99
104
|
handleCallback(ctx: WebContext): Promise<{
|
|
100
105
|
identId: any;
|
|
@@ -102,12 +107,14 @@ export default class GoogleAuthentication<T extends GoogleParameters = GooglePar
|
|
|
102
107
|
}>;
|
|
103
108
|
/**
|
|
104
109
|
* Retrieve the user profile based on the token
|
|
105
|
-
* @param token
|
|
106
|
-
* @returns
|
|
110
|
+
* @param token - the Google id token
|
|
111
|
+
* @returns the token payload
|
|
107
112
|
*/
|
|
108
113
|
getUserInfo(token: string): Promise<import("google-auth-library").TokenPayload>;
|
|
109
114
|
/**
|
|
110
115
|
* Verify a Google Auth Token
|
|
116
|
+
* @param context - the request context
|
|
117
|
+
* @returns the identity and profile
|
|
111
118
|
*/
|
|
112
119
|
handleToken(context: WebContext): Promise<{
|
|
113
120
|
identId: string;
|
|
@@ -118,8 +125,12 @@ export default class GoogleAuthentication<T extends GoogleParameters = GooglePar
|
|
|
118
125
|
*
|
|
119
126
|
* Redirecting to the webbrowser for the OAuth validation
|
|
120
127
|
* Store the token in user store afterwards
|
|
128
|
+
* @param token - existing credentials to reuse, if any
|
|
129
|
+
* @param open - callback to open the authorization url in a browser
|
|
130
|
+
* @param storeToken - callback to persist the retrieved credentials
|
|
131
|
+
* @returns the authenticated OAuth2 client
|
|
121
132
|
*/
|
|
122
133
|
getLocalClient(token: Credentials, open: (url: string) => void, storeToken: (token: Credentials) => Promise<void>): Promise<OAuth2Client>;
|
|
123
134
|
}
|
|
124
135
|
export { GoogleAuthentication };
|
|
125
|
-
//# sourceMappingURL=google-auth.d.ts.map
|
|
136
|
+
//# sourceMappingURL=google-auth.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"google-auth.service.d.ts","sourceRoot":"","sources":["../src/google-auth.service.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,WAAW,EACX,YAAY,EACZ,sBAAsB,EAEtB,aAAa,EACb,UAAU,EAEX,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAGhE,MAAM,WAAW,qBAAsB,SAAQ,gBAAgB,CAAC,UAAU,CAAC;IACzE;;OAEG;IACH,MAAM,EAAE,WAAW,CAAC;CACrB;AAED;;;GAGG;AACH,qBAAa,gBAAiB,SAAQ,sBAAsB;IAC1D;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;IACtB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;;OAIG;IACH,WAAW,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;IAEnC,YAAY,CAAC,EAAE,GAAG,CAAC;IACnB,SAAS,CAAC,EAAE;QAEV,WAAW,EAAE,OAAO,CAAC;QAErB,SAAS,EAAE,MAAM,EAAE,CAAC;QAEpB,QAAQ,EAAE;YAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;SAAE,CAAC;KACrC,CAAC;IAEF;;;;OAIG;IACH,IAAI,CAAC,MAAM,GAAE,GAAQ,GAAG,IAAI,CAI3B;CACF;AAED,KAAK,gBAAgB,GAAG,WAAW,GAAG;IACpC,mBAAmB,EAAE,qBAAqB,CAAC;CAC5C,CAAC;AACF;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,oBAAoB,CAAC,CAAC,SAAS,gBAAgB,GAAG,gBAAgB,CACrF,SAAQ,YAAY,CAAC,CAAC,EAAE,gBAAgB,CACxC,YAAW,aAAa,CAAC,UAAU,CAAC;IAEpC,SAAS,CAAC,OAAO,EAAE,YAAY,CAAC;IAEhC;;;OAGG;IACH,OAAO,WAEN;IAED;;;OAGG;IACH,kBAAkB,IAAI,MAAM,EAAE,CAE7B;IAED;;;OAGG;IACH,sBAAsB,IAAI;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAA;KAAE,EAAE,CA2B9D;IAED;;;OAGG;IACH,aAAa,WAEZ;IAED;;;OAGG;IACH,QAAQ,YAEP;IAED;;;;;;OAMG;IACH,eAAe,CAAC,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,UAUpE;IAED;;;;OAIG;IACH,cAAc,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,YAAY,CAElD;IAED;;;;OAIG;IACG,cAAc,CAAC,GAAG,EAAE,UAAU;;;OAwBnC;IAED;;;;OAIG;IACG,WAAW,CAAC,KAAK,EAAE,MAAM,uDAO9B;IAED;;;;OAIG;IACG,WAAW,CAAC,OAAO,EAAE,UAAU;;;OAUpC;IAED;;;;;;;;;OASG;IACG,cAAc,CAClB,KAAK,EAAE,WAAW,EAClB,IAAI,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,EAC3B,UAAU,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,OAAO,CAAC,IAAI,CAAC,GAChD,OAAO,CAAC,YAAY,CAAC,CAyDvB;CACF;AAED,OAAO,EAAE,oBAAoB,EAAE,CAAC"}
|
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
import { OAuthService, OAuthServiceParameters, WebdaError } from "@webda/core";
|
|
2
2
|
import { OAuth2Client } from "google-auth-library";
|
|
3
|
-
import * as http from "http";
|
|
3
|
+
import * as http from "node:http";
|
|
4
4
|
/**
|
|
5
5
|
* Credentials to manage Google Auth
|
|
6
6
|
* https://developers.google.com/identity/protocols/oauth2
|
|
7
7
|
*/
|
|
8
8
|
export class GoogleParameters extends OAuthServiceParameters {
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Load parameters with Google defaults
|
|
11
|
+
* @param params - the service parameters
|
|
12
|
+
* @returns this
|
|
13
|
+
*/
|
|
14
|
+
load(params = {}) {
|
|
15
|
+
super.load(params);
|
|
11
16
|
this.access_type ?? (this.access_type = "online");
|
|
17
|
+
return this;
|
|
12
18
|
}
|
|
13
19
|
}
|
|
14
20
|
/**
|
|
@@ -19,20 +25,21 @@ export class GoogleParameters extends OAuthServiceParameters {
|
|
|
19
25
|
export default class GoogleAuthentication extends OAuthService {
|
|
20
26
|
/**
|
|
21
27
|
* Return provider name
|
|
22
|
-
* @returns
|
|
28
|
+
* @returns the provider name
|
|
23
29
|
*/
|
|
24
30
|
getName() {
|
|
25
31
|
return "google";
|
|
26
32
|
}
|
|
27
33
|
/**
|
|
28
34
|
* Allow every accounts.google.
|
|
35
|
+
* @returns the referer patterns allowed to call back
|
|
29
36
|
*/
|
|
30
37
|
getCallbackReferer() {
|
|
31
38
|
return [/accounts\.google\.[a-z]+$/];
|
|
32
39
|
}
|
|
33
40
|
/**
|
|
34
41
|
* Get OAuth callback query parameters
|
|
35
|
-
* @returns
|
|
42
|
+
* @returns the callback query parameters
|
|
36
43
|
*/
|
|
37
44
|
getCallbackQueryParams() {
|
|
38
45
|
return [
|
|
@@ -64,26 +71,24 @@ export default class GoogleAuthentication extends OAuthService {
|
|
|
64
71
|
}
|
|
65
72
|
/**
|
|
66
73
|
* Expose on /google by default
|
|
74
|
+
* @returns the default url
|
|
67
75
|
*/
|
|
68
76
|
getDefaultUrl() {
|
|
69
77
|
return "/google";
|
|
70
78
|
}
|
|
71
79
|
/**
|
|
72
80
|
* We manage Google Auth Token
|
|
81
|
+
* @returns true
|
|
73
82
|
*/
|
|
74
83
|
hasToken() {
|
|
75
84
|
return true;
|
|
76
85
|
}
|
|
77
86
|
/**
|
|
78
|
-
*
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
*
|
|
85
|
-
* @param redirect_uri
|
|
86
|
-
* @param state
|
|
87
|
+
* Generate the Google authorization url
|
|
88
|
+
* @param redirect_uri - the url Google will redirect to
|
|
89
|
+
* @param state - the random state to verify on callback
|
|
90
|
+
* @param _ctx - the request context
|
|
91
|
+
* @returns the authorization url
|
|
87
92
|
*/
|
|
88
93
|
generateAuthUrl(redirect_uri, state, _ctx) {
|
|
89
94
|
const oauthClient = this.getOAuthClient(redirect_uri);
|
|
@@ -98,13 +103,16 @@ export default class GoogleAuthentication extends OAuthService {
|
|
|
98
103
|
}
|
|
99
104
|
/**
|
|
100
105
|
* Return a google oauth client
|
|
101
|
-
* @param redirect_uri
|
|
106
|
+
* @param redirect_uri - the redirect url to use
|
|
107
|
+
* @returns a new OAuth2 client
|
|
102
108
|
*/
|
|
103
109
|
getOAuthClient(redirect_uri) {
|
|
104
110
|
return new OAuth2Client(this.parameters.client_id, this.parameters.client_secret, redirect_uri);
|
|
105
111
|
}
|
|
106
112
|
/**
|
|
107
113
|
* @inheritdoc
|
|
114
|
+
* @param ctx - the request context
|
|
115
|
+
* @returns the identity and profile
|
|
108
116
|
*/
|
|
109
117
|
async handleCallback(ctx) {
|
|
110
118
|
// Verify state are equal
|
|
@@ -119,7 +127,7 @@ export default class GoogleAuthentication extends OAuthService {
|
|
|
119
127
|
// Now that we have the code, use that to acquire tokens.
|
|
120
128
|
try {
|
|
121
129
|
const r = await oauthClient.getToken(code);
|
|
122
|
-
this.
|
|
130
|
+
await this.emit("GoogleAuth.Tokens", { tokens: r.tokens, context: ctx });
|
|
123
131
|
profile = await this.getUserInfo(r.tokens.id_token);
|
|
124
132
|
identId = profile.sub;
|
|
125
133
|
}
|
|
@@ -134,8 +142,8 @@ export default class GoogleAuthentication extends OAuthService {
|
|
|
134
142
|
}
|
|
135
143
|
/**
|
|
136
144
|
* Retrieve the user profile based on the token
|
|
137
|
-
* @param token
|
|
138
|
-
* @returns
|
|
145
|
+
* @param token - the Google id token
|
|
146
|
+
* @returns the token payload
|
|
139
147
|
*/
|
|
140
148
|
async getUserInfo(token) {
|
|
141
149
|
const oauthClient = this.getOAuthClient();
|
|
@@ -147,6 +155,8 @@ export default class GoogleAuthentication extends OAuthService {
|
|
|
147
155
|
}
|
|
148
156
|
/**
|
|
149
157
|
* Verify a Google Auth Token
|
|
158
|
+
* @param context - the request context
|
|
159
|
+
* @returns the identity and profile
|
|
150
160
|
*/
|
|
151
161
|
async handleToken(context) {
|
|
152
162
|
const tokens = (await context.getRequestBody()).tokens;
|
|
@@ -164,6 +174,10 @@ export default class GoogleAuthentication extends OAuthService {
|
|
|
164
174
|
*
|
|
165
175
|
* Redirecting to the webbrowser for the OAuth validation
|
|
166
176
|
* Store the token in user store afterwards
|
|
177
|
+
* @param token - existing credentials to reuse, if any
|
|
178
|
+
* @param open - callback to open the authorization url in a browser
|
|
179
|
+
* @param storeToken - callback to persist the retrieved credentials
|
|
180
|
+
* @returns the authenticated OAuth2 client
|
|
167
181
|
*/
|
|
168
182
|
async getLocalClient(token, open, storeToken) {
|
|
169
183
|
if (this._client) {
|
|
@@ -207,7 +221,7 @@ export default class GoogleAuthentication extends OAuthService {
|
|
|
207
221
|
return resolve(this._client);
|
|
208
222
|
}
|
|
209
223
|
catch (err) {
|
|
210
|
-
|
|
224
|
+
this.log("ERROR", err);
|
|
211
225
|
reject(err);
|
|
212
226
|
}
|
|
213
227
|
finally {
|
|
@@ -224,4 +238,4 @@ export default class GoogleAuthentication extends OAuthService {
|
|
|
224
238
|
}
|
|
225
239
|
}
|
|
226
240
|
export { GoogleAuthentication };
|
|
227
|
-
//# sourceMappingURL=google-auth.js.map
|
|
241
|
+
//# sourceMappingURL=google-auth.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"google-auth.service.js","sourceRoot":"","sources":["../src/google-auth.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,YAAY,EACZ,sBAAsB,EAItB,UAAU,EACX,MAAM,aAAa,CAAC;AACrB,OAAO,EAAe,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AASlC;;;GAGG;AACH,MAAM,OAAO,gBAAiB,SAAQ,sBAAsB;IA+B1D;;;;OAIG;IACH,IAAI,CAAC,MAAM,GAAQ,EAAE;QACnB,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACnB,IAAI,CAAC,WAAW,KAAhB,IAAI,CAAC,WAAW,GAAK,QAAQ,EAAC;QAC9B,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAKD;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,oBACnB,SAAQ,YAAiC;IAKzC;;;OAGG;IACH,OAAO;QACL,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;OAGG;IACH,kBAAkB;QAChB,OAAO,CAAC,2BAA2B,CAAC,CAAC;IACvC,CAAC;IAED;;;OAGG;IACH,sBAAsB;QACpB,OAAO;YACL;gBACE,IAAI,EAAE,MAAM;gBACZ,QAAQ,EAAE,IAAI;aACf;YACD;gBACE,IAAI,EAAE,OAAO;gBACb,QAAQ,EAAE,IAAI;aACf;YACD;gBACE,IAAI,EAAE,OAAO;gBACb,QAAQ,EAAE,IAAI;aACf;YACD;gBACE,IAAI,EAAE,UAAU;gBAChB,QAAQ,EAAE,KAAK;aAChB;YACD;gBACE,IAAI,EAAE,IAAI;gBACV,QAAQ,EAAE,KAAK;aAChB;YACD;gBACE,IAAI,EAAE,QAAQ;gBACd,QAAQ,EAAE,KAAK;aAChB;SACF,CAAC;IACJ,CAAC;IAED;;;OAGG;IACH,aAAa;QACX,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;;OAG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AA0D,CAAC,CAAC;wBACtE,CAAC;6BAAM,CAAC;4BACN,GAAG,CAAC,GAAG,CAAC,4DAA4D,CAAC,CAAC;4BACtE,OAAO,MAAM,CAAC,QAAQ,CAAC,CAAC;wBAC1B,CAAC;wBAED,yDAAyD;wBACzD,MAAM,CAAC,GAAG,MAAM,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;wBAC5C,yDAAyD;wBACzD,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;wBACrB,YAAY,CAAC,cAAc,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;wBACtC,IAAI,CAAC,OAAO,GAAG,YAAY,CAAC;wBAC5B,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,iCAAiC,CAAC,CAAC;wBACpD,OAAO,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;oBAC/B,CAAC;oBAAC,OAAO,GAAG,EAAE,CAAC;wBACb,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;wBACvB,MAAM,CAAC,GAAG,CAAC,CAAC;oBACd,CAAC;4BAAS,CAAC;wBACT,MAAM,CAAC,KAAK,EAAE,CAAC;oBACjB,CAAC;gBACH,CAAC;YACH,CAAC,CAAC;iBACD,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE;gBACjB,8DAA8D;gBAC9D,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,kDAAkD,CAAC,CAAC;gBACrE,IAAI,CAAC,YAAY,CAAC,CAAC;YACrB,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAED,OAAO,EAAE,oBAAoB,EAAE,CAAC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./google-auth.js";
|
|
1
|
+
export * from "./google-auth.service.js";
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./google-auth.js";
|
|
1
|
+
export * from "./google-auth.service.js";
|
|
2
2
|
//# 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,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,18 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webda/google-auth",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.3",
|
|
4
4
|
"description": "Webda Google Authentication",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"build": "webda build",
|
|
8
|
-
"build:watch": "webda build --watch",
|
|
9
|
-
"pretest": "npm run build",
|
|
10
|
-
"lint": "eslint",
|
|
11
|
-
"lint:fix": "eslint --fix",
|
|
12
|
-
"test": "c8 mocha",
|
|
13
|
-
"format": "prettier --check src/**/*",
|
|
14
|
-
"format:fix": "prettier --write src/**/*"
|
|
15
|
-
},
|
|
16
6
|
"repository": {
|
|
17
7
|
"type": "git",
|
|
18
8
|
"url": "git+https://github.com/loopingz/webda.io.git"
|
|
@@ -33,41 +23,43 @@
|
|
|
33
23
|
},
|
|
34
24
|
"homepage": "https://github.com/loopingz/webda.io#readme",
|
|
35
25
|
"dependencies": {
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
},
|
|
39
|
-
"c8": {
|
|
40
|
-
"report-dir": "./reports",
|
|
41
|
-
"reporter": [
|
|
42
|
-
"html",
|
|
43
|
-
"lcov",
|
|
44
|
-
"json",
|
|
45
|
-
"text"
|
|
46
|
-
],
|
|
47
|
-
"exclude": [
|
|
48
|
-
"**/*.spec.ts"
|
|
49
|
-
]
|
|
26
|
+
"google-auth-library": "^10.6.2",
|
|
27
|
+
"@webda/core": "4.0.0-beta.3"
|
|
50
28
|
},
|
|
51
29
|
"publishConfig": {
|
|
52
30
|
"access": "public"
|
|
53
31
|
},
|
|
54
32
|
"devDependencies": {
|
|
55
|
-
"@
|
|
56
|
-
"@
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
33
|
+
"@types/node": "25.5.0",
|
|
34
|
+
"@vitest/coverage-v8": "^4.1.2",
|
|
35
|
+
"jscodeshift": "^17.3.0",
|
|
36
|
+
"skott": "^0.35.8",
|
|
37
|
+
"tsx": "^4.21.0",
|
|
38
|
+
"typescript": "7.1.0-dev.20260929.1",
|
|
39
|
+
"vite": "^6.0.0",
|
|
40
|
+
"vitest": "^4.1.2",
|
|
41
|
+
"@webda/compiler": "^4.0.0-beta.3",
|
|
42
|
+
"@webda/test": "4.0.0-beta.3"
|
|
61
43
|
},
|
|
62
44
|
"type": "module",
|
|
63
45
|
"engines": {
|
|
64
|
-
"node": ">=
|
|
46
|
+
"node": ">=22.0.0"
|
|
65
47
|
},
|
|
66
48
|
"nx": {
|
|
67
49
|
"implicitDependencies": [
|
|
68
|
-
"@webda/core"
|
|
69
|
-
"@webda/shell"
|
|
50
|
+
"@webda/core"
|
|
70
51
|
]
|
|
71
52
|
},
|
|
72
|
-
"
|
|
73
|
-
|
|
53
|
+
"scripts": {
|
|
54
|
+
"build": "webdac build",
|
|
55
|
+
"build:watch": "webdac build --watch",
|
|
56
|
+
"pretest": "npm run build",
|
|
57
|
+
"lint": "eslint",
|
|
58
|
+
"lint:fix": "eslint --fix",
|
|
59
|
+
"test": "vitest run",
|
|
60
|
+
"format": "prettier --check src/**/*",
|
|
61
|
+
"format:fix": "prettier --write src/**/*",
|
|
62
|
+
"deps:graph": "skott --showCircularDependencies --no-trackTypeOnlyDependencies --displayMode=raw -e .ts",
|
|
63
|
+
"codemod": "jscodeshift --parser=ts --extensions=tsx,ts -t ../codemod/current.mjs src"
|
|
64
|
+
}
|
|
65
|
+
}
|
package/webda.module.json
CHANGED
|
@@ -1,46 +1,171 @@
|
|
|
1
1
|
{
|
|
2
|
+
"$schema": "https://webda.io/schemas/webda.module.v4.json",
|
|
2
3
|
"beans": {},
|
|
3
4
|
"deployers": {},
|
|
4
5
|
"moddas": {
|
|
5
|
-
"Webda/GoogleAuthentication":
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
"Webda/GoogleAuthentication": {
|
|
7
|
+
"Import": "lib/google-auth.service:default",
|
|
8
|
+
"Schema": {
|
|
9
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
10
|
+
"additionalProperties": false,
|
|
11
|
+
"definitions": {
|
|
12
|
+
"redirects": {
|
|
13
|
+
"additionalProperties": false,
|
|
14
|
+
"properties": {
|
|
15
|
+
"defaults": {
|
|
16
|
+
"$ref": "#/definitions/redirects%24defaults"
|
|
17
|
+
},
|
|
18
|
+
"use_referer": {
|
|
19
|
+
"default": false,
|
|
20
|
+
"type": "boolean"
|
|
21
|
+
},
|
|
22
|
+
"whitelist": {
|
|
23
|
+
"items": {
|
|
24
|
+
"type": "string"
|
|
25
|
+
},
|
|
26
|
+
"type": "array"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"required": [
|
|
30
|
+
"defaults",
|
|
31
|
+
"whitelist"
|
|
32
|
+
],
|
|
33
|
+
"type": "object"
|
|
34
|
+
},
|
|
35
|
+
"redirects$defaults": {
|
|
36
|
+
"additionalProperties": {
|
|
37
|
+
"type": "string"
|
|
38
|
+
},
|
|
39
|
+
"type": "object"
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"description": "Credentials to manage Google Auth\nhttps://developers.google.com/identity/protocols/oauth2",
|
|
43
|
+
"properties": {
|
|
44
|
+
"access_type": {
|
|
45
|
+
"description": "Type of access for Google token\n\nonline by default",
|
|
46
|
+
"enum": [
|
|
47
|
+
"online",
|
|
48
|
+
"offline"
|
|
49
|
+
],
|
|
50
|
+
"type": "string"
|
|
51
|
+
},
|
|
52
|
+
"auth_options": {},
|
|
53
|
+
"authenticationService": {
|
|
54
|
+
"default": "Authentication",
|
|
55
|
+
"description": "Name of the authentication service to use if exist",
|
|
56
|
+
"type": "string"
|
|
57
|
+
},
|
|
58
|
+
"authorized_uris": {
|
|
59
|
+
"default": [],
|
|
60
|
+
"description": "List of URIs authorized for redirect post authorization",
|
|
61
|
+
"items": {
|
|
62
|
+
"type": "string"
|
|
63
|
+
},
|
|
64
|
+
"type": "array"
|
|
65
|
+
},
|
|
66
|
+
"client_id": {
|
|
67
|
+
"description": "Google Auth Client id",
|
|
68
|
+
"type": "string"
|
|
69
|
+
},
|
|
70
|
+
"client_secret": {
|
|
71
|
+
"description": "Google Auth Client secret",
|
|
72
|
+
"type": "string"
|
|
73
|
+
},
|
|
74
|
+
"exposeScope": {
|
|
75
|
+
"default": false,
|
|
76
|
+
"description": "If set to true it will add a ${url}/scope\nSo client can anticipate the requested scope\n\nThis is useful when using the client api to generate\ntoken. This way the service can request the wanted scope",
|
|
77
|
+
"type": "boolean"
|
|
78
|
+
},
|
|
79
|
+
"no_referer": {
|
|
80
|
+
"default": false,
|
|
81
|
+
"description": "Allow direct connection without a referer",
|
|
82
|
+
"type": "boolean"
|
|
83
|
+
},
|
|
84
|
+
"project_id": {
|
|
85
|
+
"description": "Google Project ID",
|
|
86
|
+
"type": "string"
|
|
87
|
+
},
|
|
88
|
+
"redirect_uri": {
|
|
89
|
+
"default": "${url}/callback",
|
|
90
|
+
"description": "Default redirect_uri",
|
|
91
|
+
"type": "string"
|
|
92
|
+
},
|
|
93
|
+
"redirects": {
|
|
94
|
+
"$ref": "#/definitions/redirects"
|
|
95
|
+
},
|
|
96
|
+
"scope": {
|
|
97
|
+
"defaut": [
|
|
98
|
+
"email"
|
|
99
|
+
],
|
|
100
|
+
"description": "Scope to request on OAuth flow",
|
|
101
|
+
"items": {
|
|
102
|
+
"type": "string"
|
|
103
|
+
},
|
|
104
|
+
"type": "array"
|
|
105
|
+
},
|
|
106
|
+
"type": {
|
|
107
|
+
"description": "Type of the service",
|
|
108
|
+
"type": "string"
|
|
109
|
+
},
|
|
110
|
+
"url": {
|
|
111
|
+
"SchemaOptional": true,
|
|
112
|
+
"description": "URL to use for expose\n\nThe default value varying based on implementation\nIt should by default be the provider name in lowercase",
|
|
113
|
+
"type": "string"
|
|
114
|
+
},
|
|
115
|
+
"openapi": {
|
|
116
|
+
"type": "object",
|
|
117
|
+
"additionalProperties": true
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
"required": [
|
|
121
|
+
"client_id",
|
|
122
|
+
"client_secret",
|
|
123
|
+
"scope",
|
|
124
|
+
"type"
|
|
125
|
+
],
|
|
126
|
+
"type": "object",
|
|
127
|
+
"title": "GoogleAuthentication"
|
|
128
|
+
},
|
|
129
|
+
"Configuration": "lib/google-auth.service:GoogleParameters",
|
|
130
|
+
"capabilities": [
|
|
131
|
+
"request-filter"
|
|
132
|
+
]
|
|
133
|
+
}
|
|
13
134
|
},
|
|
135
|
+
"models": {},
|
|
14
136
|
"schemas": {
|
|
15
137
|
"Webda/BinaryFile": {
|
|
16
|
-
"
|
|
138
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
139
|
+
"WebdaSchema": true,
|
|
140
|
+
"additionalProperties": false,
|
|
141
|
+
"description": "Represent a file to store",
|
|
17
142
|
"properties": {
|
|
18
|
-
"hash": {
|
|
19
|
-
"type": "string",
|
|
20
|
-
"description": "Will be computed by the service\n\nhash of the content"
|
|
21
|
-
},
|
|
22
143
|
"challenge": {
|
|
23
|
-
"
|
|
24
|
-
"
|
|
144
|
+
"description": "Will be computed by the service\n\nhash of the content prefixed by 'WEBDA'",
|
|
145
|
+
"type": "string"
|
|
25
146
|
},
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
147
|
+
"hash": {
|
|
148
|
+
"description": "Will be computed by the service\n\nhash of the content",
|
|
149
|
+
"type": "string"
|
|
29
150
|
},
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"description": "Current name"
|
|
151
|
+
"metadata": {
|
|
152
|
+
"description": "Metadatas stored along with the binary"
|
|
33
153
|
},
|
|
34
154
|
"mimetype": {
|
|
35
|
-
"
|
|
36
|
-
"
|
|
155
|
+
"description": "Mimetype of the binary",
|
|
156
|
+
"type": "string"
|
|
37
157
|
},
|
|
38
|
-
"
|
|
39
|
-
"description": "
|
|
158
|
+
"name": {
|
|
159
|
+
"description": "Current name",
|
|
160
|
+
"type": "string"
|
|
40
161
|
},
|
|
41
162
|
"originalname": {
|
|
42
|
-
"
|
|
43
|
-
"
|
|
163
|
+
"description": "Original name",
|
|
164
|
+
"type": "string"
|
|
165
|
+
},
|
|
166
|
+
"size": {
|
|
167
|
+
"description": "Size of the binary",
|
|
168
|
+
"type": "number"
|
|
44
169
|
}
|
|
45
170
|
},
|
|
46
171
|
"required": [
|
|
@@ -48,120 +173,9 @@
|
|
|
48
173
|
"name",
|
|
49
174
|
"size"
|
|
50
175
|
],
|
|
51
|
-
"description": "Represent a file to store",
|
|
52
|
-
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
53
|
-
"title": "BinaryFile"
|
|
54
|
-
},
|
|
55
|
-
"Webda/GoogleAuthentication": {
|
|
56
176
|
"type": "object",
|
|
57
|
-
"
|
|
58
|
-
"type": {
|
|
59
|
-
"type": "string",
|
|
60
|
-
"description": "Type of the service"
|
|
61
|
-
},
|
|
62
|
-
"url": {
|
|
63
|
-
"type": "string",
|
|
64
|
-
"description": "URL to use for expose\n\nThe default value varying based on implementation It should by default be the provider name in lowercase"
|
|
65
|
-
},
|
|
66
|
-
"scope": {
|
|
67
|
-
"type": "array",
|
|
68
|
-
"items": {
|
|
69
|
-
"type": "string"
|
|
70
|
-
},
|
|
71
|
-
"description": "Scope to request on OAuth flow"
|
|
72
|
-
},
|
|
73
|
-
"exposeScope": {
|
|
74
|
-
"type": "boolean",
|
|
75
|
-
"description": "If set to true it will add a ${url}/scope So client can anticipate the requested scope\n\nThis is useful when using the client api to generate token. This way the service can request the wanted scope",
|
|
76
|
-
"default": false
|
|
77
|
-
},
|
|
78
|
-
"authorized_uris": {
|
|
79
|
-
"type": "array",
|
|
80
|
-
"items": {
|
|
81
|
-
"type": "string"
|
|
82
|
-
},
|
|
83
|
-
"description": "List of URIs authorized for redirect post authorization",
|
|
84
|
-
"default": []
|
|
85
|
-
},
|
|
86
|
-
"redirect_uri": {
|
|
87
|
-
"type": "string",
|
|
88
|
-
"description": "Default redirect_uri",
|
|
89
|
-
"default": "${url}/callback"
|
|
90
|
-
},
|
|
91
|
-
"no_referer": {
|
|
92
|
-
"type": "boolean",
|
|
93
|
-
"description": "Allow direct connection without a referer",
|
|
94
|
-
"default": false
|
|
95
|
-
},
|
|
96
|
-
"authenticationService": {
|
|
97
|
-
"type": "string",
|
|
98
|
-
"description": "Name of the authentication service to use if exist",
|
|
99
|
-
"default": "Authentication"
|
|
100
|
-
},
|
|
101
|
-
"client_id": {
|
|
102
|
-
"type": "string",
|
|
103
|
-
"description": "Google Auth Client id"
|
|
104
|
-
},
|
|
105
|
-
"client_secret": {
|
|
106
|
-
"type": "string",
|
|
107
|
-
"description": "Google Auth Client secret"
|
|
108
|
-
},
|
|
109
|
-
"project_id": {
|
|
110
|
-
"type": "string",
|
|
111
|
-
"description": "Google Project ID"
|
|
112
|
-
},
|
|
113
|
-
"access_type": {
|
|
114
|
-
"type": "string",
|
|
115
|
-
"enum": [
|
|
116
|
-
"online",
|
|
117
|
-
"offline"
|
|
118
|
-
],
|
|
119
|
-
"description": "Type of access for Google token\n\nonline by default"
|
|
120
|
-
},
|
|
121
|
-
"auth_options": {},
|
|
122
|
-
"redirects": {
|
|
123
|
-
"type": "object",
|
|
124
|
-
"properties": {
|
|
125
|
-
"use_referer": {
|
|
126
|
-
"type": "boolean"
|
|
127
|
-
},
|
|
128
|
-
"whitelist": {
|
|
129
|
-
"type": "array",
|
|
130
|
-
"items": {
|
|
131
|
-
"type": "string"
|
|
132
|
-
}
|
|
133
|
-
},
|
|
134
|
-
"defaults": {
|
|
135
|
-
"type": "object",
|
|
136
|
-
"additionalProperties": {
|
|
137
|
-
"type": "string"
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
},
|
|
141
|
-
"required": [
|
|
142
|
-
"use_referer",
|
|
143
|
-
"whitelist",
|
|
144
|
-
"defaults"
|
|
145
|
-
]
|
|
146
|
-
},
|
|
147
|
-
"openapi": {
|
|
148
|
-
"type": "object",
|
|
149
|
-
"additionalProperties": true
|
|
150
|
-
}
|
|
151
|
-
},
|
|
152
|
-
"required": [
|
|
153
|
-
"authenticationService",
|
|
154
|
-
"client_id",
|
|
155
|
-
"client_secret",
|
|
156
|
-
"exposeScope",
|
|
157
|
-
"no_referer",
|
|
158
|
-
"redirects",
|
|
159
|
-
"scope",
|
|
160
|
-
"type"
|
|
161
|
-
],
|
|
162
|
-
"description": "Credentials to manage Google Auth https://developers.google.com/identity/protocols/oauth2",
|
|
163
|
-
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
164
|
-
"title": "GoogleAuthentication"
|
|
177
|
+
"title": "BinaryFile"
|
|
165
178
|
}
|
|
166
|
-
}
|
|
179
|
+
},
|
|
180
|
+
"behaviors": {}
|
|
167
181
|
}
|
package/lib/google-auth.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"google-auth.d.ts","sourceRoot":"","sources":["../src/google-auth.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,YAAY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AAC,CAAC;oBAC/B,CAAC;oBAAC,OAAO,GAAG,EAAE,CAAC;wBACb,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;wBACjB,MAAM,CAAC,GAAG,CAAC,CAAC;oBACd,CAAC;4BAAS,CAAC;wBACT,MAAM,CAAC,KAAK,EAAE,CAAC;oBACjB,CAAC;gBACH,CAAC;YACH,CAAC,CAAC;iBACD,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE;gBACjB,8DAA8D;gBAC9D,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,kDAAkD,CAAC,CAAC;gBACrE,IAAI,CAAC,YAAY,CAAC,CAAC;YACrB,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAED,OAAO,EAAE,oBAAoB,EAAE,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"google-auth.spec.d.ts","sourceRoot":"","sources":["../src/google-auth.spec.ts"],"names":[],"mappings":""}
|
package/lib/google-auth.spec.js
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
import { suite, test } from "@testdeck/mocha";
|
|
8
|
-
import { WebdaError } from "@webda/core";
|
|
9
|
-
import { WebdaTest } from "@webda/core/lib/test.js";
|
|
10
|
-
import * as assert from "assert";
|
|
11
|
-
import fetch from "node-fetch";
|
|
12
|
-
import { GoogleAuthentication } from "./google-auth.js";
|
|
13
|
-
let GoogleAuthTest = class GoogleAuthTest extends WebdaTest {
|
|
14
|
-
async before() {
|
|
15
|
-
await super.before();
|
|
16
|
-
this.service = new GoogleAuthentication(this.webda, "google", {
|
|
17
|
-
client_id: "fake",
|
|
18
|
-
client_secret: "secret"
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
cov() {
|
|
22
|
-
assert.strictEqual(this.service.getName(), "google");
|
|
23
|
-
assert.strictEqual(this.service.getDefaultUrl(), "/google");
|
|
24
|
-
assert.deepStrictEqual(this.service.getCallbackReferer(), [/accounts\.google\.[a-z]+$/]);
|
|
25
|
-
assert.strictEqual(this.service.hasToken(), true);
|
|
26
|
-
assert.strictEqual(this.service.getCallbackQueryParams().length, 6);
|
|
27
|
-
}
|
|
28
|
-
generateAuthUrl() {
|
|
29
|
-
const url = this.service.generateAuthUrl("plopor", "myState", undefined);
|
|
30
|
-
assert.strictEqual(url, "https://accounts.google.com/o/oauth2/v2/auth?access_type=online&scope=email&redirect_uri=plopor&response_type=code&state=myState&client_id=fake");
|
|
31
|
-
}
|
|
32
|
-
mockClient() {
|
|
33
|
-
// Mock client
|
|
34
|
-
// @ts-ignore
|
|
35
|
-
this.service.getOAuthClient = () => {
|
|
36
|
-
return {
|
|
37
|
-
getToken: async (arg) => {
|
|
38
|
-
if (arg === "u1")
|
|
39
|
-
return { tokens: { id_token: arg } };
|
|
40
|
-
},
|
|
41
|
-
generateAuthUrl: () => {
|
|
42
|
-
return "/";
|
|
43
|
-
},
|
|
44
|
-
setCredentials: () => { },
|
|
45
|
-
verifyIdToken: async (args) => {
|
|
46
|
-
if (args.idToken === "u1") {
|
|
47
|
-
return {
|
|
48
|
-
getPayload: () => {
|
|
49
|
-
return {
|
|
50
|
-
sub: "u1",
|
|
51
|
-
email: "u1@webda.io"
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
async tokenAndCallback() {
|
|
61
|
-
var _a;
|
|
62
|
-
this.mockClient();
|
|
63
|
-
let ctx = await this.newContext();
|
|
64
|
-
// Verify normal callback
|
|
65
|
-
ctx.getParameters().state = "plop";
|
|
66
|
-
(_a = ctx.getSession()).oauth ?? (_a.oauth = {});
|
|
67
|
-
ctx.getSession().oauth.state = "bouzouf";
|
|
68
|
-
await assert.rejects(() => this.service.handleCallback(ctx), WebdaError.Forbidden);
|
|
69
|
-
ctx.getSession().oauth.state = "plop";
|
|
70
|
-
ctx.getParameters().code = "u1";
|
|
71
|
-
assert.deepStrictEqual(await this.service.handleCallback(ctx), {
|
|
72
|
-
identId: "u1",
|
|
73
|
-
profile: { sub: "u1", email: "u1@webda.io" }
|
|
74
|
-
});
|
|
75
|
-
ctx.getParameters().code = "u2";
|
|
76
|
-
await assert.rejects(() => this.service.handleCallback(ctx), WebdaError.Forbidden);
|
|
77
|
-
// Verify tokens verification
|
|
78
|
-
await assert.rejects(() => this.service.handleToken(ctx), WebdaError.BadRequest);
|
|
79
|
-
ctx = await this.newContext({ tokens: { id_token: "u1" } });
|
|
80
|
-
assert.deepStrictEqual(await this.service.handleToken(ctx), {
|
|
81
|
-
identId: "u1",
|
|
82
|
-
profile: { sub: "u1", email: "u1@webda.io" }
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
async localClient() {
|
|
86
|
-
const fakeClient = {};
|
|
87
|
-
// @ts-ignore
|
|
88
|
-
this.service._client = fakeClient;
|
|
89
|
-
assert.strictEqual(await this.service.getLocalClient(null, null, null), fakeClient);
|
|
90
|
-
// @ts-ignore
|
|
91
|
-
this.service._client = undefined;
|
|
92
|
-
const client = await this.service.getLocalClient({ id_token: "mytoken" }, null, null);
|
|
93
|
-
assert.deepStrictEqual(client.credentials, { id_token: "mytoken" });
|
|
94
|
-
// @ts-ignore
|
|
95
|
-
this.service._client = undefined;
|
|
96
|
-
let calledUrl;
|
|
97
|
-
await assert.rejects(async () => this.service.getLocalClient(null, url => {
|
|
98
|
-
calledUrl = url;
|
|
99
|
-
fetch("http://localhost:3000/oauth2callback", undefined);
|
|
100
|
-
}, null), /Failed/);
|
|
101
|
-
this.mockClient();
|
|
102
|
-
await assert.rejects(async () => this.service.getLocalClient(null, url => {
|
|
103
|
-
fetch("http://localhost:3000/oauth2callback?code=u2", undefined);
|
|
104
|
-
}, null), /Cannot read propert/);
|
|
105
|
-
let token;
|
|
106
|
-
await this.service.getLocalClient(null, url => {
|
|
107
|
-
// cov only
|
|
108
|
-
fetch("http://localhost:3000/cov", {});
|
|
109
|
-
fetch("http://localhost:3000/oauth2callback?code=u1", {});
|
|
110
|
-
}, async (t) => {
|
|
111
|
-
token = t;
|
|
112
|
-
});
|
|
113
|
-
assert.strictEqual(calledUrl, "https://accounts.google.com/o/oauth2/v2/auth?access_type=offline&scope=email&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Foauth2callback&response_type=code&client_id=fake");
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
__decorate([
|
|
117
|
-
test
|
|
118
|
-
], GoogleAuthTest.prototype, "cov", null);
|
|
119
|
-
__decorate([
|
|
120
|
-
test
|
|
121
|
-
], GoogleAuthTest.prototype, "generateAuthUrl", null);
|
|
122
|
-
__decorate([
|
|
123
|
-
test
|
|
124
|
-
], GoogleAuthTest.prototype, "tokenAndCallback", null);
|
|
125
|
-
__decorate([
|
|
126
|
-
test
|
|
127
|
-
], GoogleAuthTest.prototype, "localClient", null);
|
|
128
|
-
GoogleAuthTest = __decorate([
|
|
129
|
-
suite
|
|
130
|
-
], GoogleAuthTest);
|
|
131
|
-
//# sourceMappingURL=google-auth.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"google-auth.spec.js","sourceRoot":"","sources":["../src/google-auth.spec.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OA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