From 4bf93b48724203f5f173b1a5bf4e0e231ffeba8a Mon Sep 17 00:00:00 2001 From: Baptiste Arnaud Date: Sat, 7 Jan 2023 17:13:08 +0100 Subject: [PATCH] :recycle: Add id token config param to custom OAuth Closes #224 --- .../src/pages/api/auth/[...nextauth].ts | 1 + .../self-hosting/configuration/builder.mdx | 25 ++++++++++--------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/apps/builder/src/pages/api/auth/[...nextauth].ts b/apps/builder/src/pages/api/auth/[...nextauth].ts index 4179eed6d..74f6eaf2b 100644 --- a/apps/builder/src/pages/api/auth/[...nextauth].ts +++ b/apps/builder/src/pages/api/auth/[...nextauth].ts @@ -107,6 +107,7 @@ if (isNotEmpty(process.env.CUSTOM_OAUTH_AUTHORIZATION_URL)) { authorization: process.env.CUSTOM_OAUTH_AUTHORIZATION_URL, token: process.env.CUSTOM_OAUTH_TOKEN_URL, userinfo: process.env.CUSTOM_OAUTH_USERINFO_URL, + idToken: process.env.CUSTOM_OAUTH_ENABLE_ID_TOKEN === 'true', profile(profile) { return { id: getAtPath(profile, process.env.CUSTOM_OAUTH_USER_ID_PATH ?? 'id'), diff --git a/apps/docs/docs/self-hosting/configuration/builder.mdx b/apps/docs/docs/self-hosting/configuration/builder.mdx index 4d358b250..398b9e47b 100644 --- a/apps/docs/docs/self-hosting/configuration/builder.mdx +++ b/apps/docs/docs/self-hosting/configuration/builder.mdx @@ -105,18 +105,19 @@ The Authorization callback URL should be `$NEXTAUTH_URL/api/auth/callback/azure- ## Custom OAuth Provider (Auth) -| Parameter | Default | Description | -| ------------------------------ | ------------ | ----------------------------------------------------------------------- | -| CUSTOM_OAUTH_NAME | Custom OAuth | Provider name. Is displayed in the sign in form. | -| CUSTOM_OAUTH_CLIENT_ID | -- | OAuth client ID. | -| CUSTOM_OAUTH_CLIENT_SECRET | -- | OAuth client secret. | -| CUSTOM_OAUTH_AUTHORIZATION_URL | -- | OAuth autorization URL (i.e. `https://kauth.kakao.com/oauth/authorize`) | -| CUSTOM_OAUTH_TOKEN_URL | -- | OAuth token URL (i.e. `https://kauth.kakao.com/oauth/token`) | -| CUSTOM_OAUTH_USERINFO_URL | -- | User info URL (i.e. `https://kapi.kakao.com/v2/user/me`) | -| CUSTOM_OAUTH_USER_ID_PATH | id | Used to map the id from the user info object | -| CUSTOM_OAUTH_USER_NAME_PATH | name | Used to map the name from the user info object | -| CUSTOM_OAUTH_USER_EMAIL_PATH | email | Used to map the email from the user info object | -| CUSTOM_OAUTH_USER_IMAGE_PATH | image | Used to map the image from the user info object | +| Parameter | Default | Description | +| ------------------------------ | ------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| CUSTOM_OAUTH_NAME | Custom OAuth | Provider name. Is displayed in the sign in form. | +| CUSTOM_OAUTH_CLIENT_ID | -- | OAuth client ID. | +| CUSTOM_OAUTH_CLIENT_SECRET | -- | OAuth client secret. | +| CUSTOM_OAUTH_AUTHORIZATION_URL | -- | OAuth autorization URL (i.e. `https://kauth.kakao.com/oauth/authorize`) | +| CUSTOM_OAUTH_TOKEN_URL | -- | OAuth token URL (i.e. `https://kauth.kakao.com/oauth/token`) | +| CUSTOM_OAUTH_USERINFO_URL | -- | User info URL (i.e. `https://kapi.kakao.com/v2/user/me`) | +| CUSTOM_OAUTH_ENABLE_ID_TOKEN | false | If set to true, the user information will be extracted from the id_token claims, instead of making a request to the userinfo endpoint. id_token is usually present in OpenID Connect (OIDC) compliant providers. | +| CUSTOM_OAUTH_USER_ID_PATH | id | Used to map the id from the user info object | +| CUSTOM_OAUTH_USER_NAME_PATH | name | Used to map the name from the user info object | +| CUSTOM_OAUTH_USER_EMAIL_PATH | email | Used to map the email from the user info object | +| CUSTOM_OAUTH_USER_IMAGE_PATH | image | Used to map the image from the user info object | For `*_PATH` parameters, you can use dot notation to access nested properties (i.e. `account.name`).