Skip to content

Commit a8dfc8e

Browse files
authored
feat(providers): Add Descope provider (#7874)
* Add Descope provider * Add Descope provider * Remove dark logo, remove wellKnown, and fix user profile syntax * Change to DESCOPE_SECRET * Fix env comment * Fix clientId extracting * Change to client id
1 parent 1b80a18 commit a8dfc8e

File tree

9 files changed

+176
-0
lines changed

9 files changed

+176
-0
lines changed

.github/ISSUE_TEMPLATE/2_bug_provider.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ body:
3737
- "Bungie"
3838
- "Cognito"
3939
- "Coinbase"
40+
- "Descope"
4041
- "Discord"
4142
- "Dropbox"
4243
- "EVE Online"

apps/dev/nextjs-v4/.env.local.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ AUTH0_ID=
1313
AUTH0_SECRET=
1414
AUTH0_ISSUER=
1515

16+
DESCOPE_ID=
17+
DESCOPE_SECRET=
18+
1619
KEYCLOAK_ID=
1720
KEYCLOAK_SECRET=
1821
KEYCLOAK_ISSUER=

apps/dev/nextjs/.env.local.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ BEYOND_IDENTITY_CLIENT_ID=
2222
BEYOND_IDENTITY_CLIENT_SECRET=
2323
BEYOND_IDENTITY_ISSUER=
2424

25+
DESCOPE_ID=
26+
DESCOPE_SECRET=
27+
2528
GITHUB_ID=
2629
GITHUB_SECRET=
2730

apps/dev/nextjs/pages/api/auth/[...nextauth].ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import BeyondIdentity from "@auth/core/providers/beyondidentity"
1010
import BoxyHQSAML from "@auth/core/providers/boxyhq-saml"
1111
// import Cognito from "@auth/core/providers/cognito"
1212
import Credentials from "@auth/core/providers/credentials"
13+
import Descope from "@auth/core/providers/descope"
1314
import Discord from "@auth/core/providers/discord"
1415
import DuendeIDS6 from "@auth/core/providers/duende-identity-server6"
1516
// import Email from "@auth/core/providers/email"
@@ -101,6 +102,7 @@ export const authConfig: AuthConfig = {
101102
}),
102103
BoxyHQSAML({ issuer: "https://jackson-demo.boxyhq.com", clientId: "tenant=boxyhq.com&product=saml-demo.boxyhq.com", clientSecret: "dummy" }),
103104
// Cognito({ clientId: process.env.COGNITO_ID, clientSecret: process.env.COGNITO_SECRET, issuer: process.env.COGNITO_ISSUER }),
105+
Descope({ clientId: process.env.DESCOPE_ID, clientSecret: process.env.DESCOPE_SECRET }),
104106
Discord({ clientId: process.env.DISCORD_ID, clientSecret: process.env.DISCORD_SECRET }),
105107
DuendeIDS6({ clientId: "interactive.confidential", clientSecret: "secret", issuer: "https://demo.duendesoftware.com" }),
106108
Facebook({ clientId: process.env.FACEBOOK_ID, clientSecret: process.env.FACEBOOK_SECRET }),

apps/examples/nextjs/.env.local.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ AUTH0_ID=
66
AUTH0_SECRET=
77
AUTH0_ISSUER=
88

9+
DESCOPE_ID=
10+
DESCOPE_SECRET=
11+
912
FACEBOOK_ID=
1013
FACEBOOK_SECRET=
1114

apps/examples/nextjs/process.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,7 @@ declare namespace NodeJS {
1212
GOOGLE_SECRET: string
1313
AUTH0_ID: string
1414
AUTH0_SECRET: string
15+
DESCOPE_ID: string
16+
DESCOPE_SECRET: string
1517
}
1618
}

docs/src/components/ProviderMarquee.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const icons = [
77
"/img/providers/apple.svg",
88
"/img/providers/auth0.svg",
99
"/img/providers/cognito.svg",
10+
"/img/providers/descope.svg",
1011
"/img/providers/battlenet.svg",
1112
"/img/providers/box.svg",
1213
"/img/providers/facebook.svg",

docs/static/img/providers/descope.svg

Lines changed: 50 additions & 0 deletions
Loading
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
/**
2+
* <div style={{display: "flex", justifyContent: "space-between", alignItems: "center"}}>
3+
* <span style={{fontSize: "1.35rem" }}>
4+
* Built-in sign in with <b>Descope</b> integration.
5+
* </span>
6+
* <a href="https://descope.com" style={{backgroundColor: "#000000", padding: "12px", borderRadius: "100%" }}>
7+
* <img style={{display: "block"}} src="https://authjs.dev/img/providers/descope.svg" width="24"/>
8+
* </a>
9+
* </div>
10+
*
11+
* @module providers/descope
12+
*/
13+
14+
import type { OIDCConfig, OIDCUserConfig } from "./index.js"
15+
16+
/** The returned user profile from Descope when using the profile callback. */
17+
export interface DescopeProfile {
18+
/** The user Descope ID */
19+
sub: string
20+
name: string
21+
email: string
22+
email_verified: boolean
23+
phone_number: string
24+
phone_number_verified: boolean
25+
picture: string
26+
/** Custom user's attributes */
27+
[claim: string]: unknown
28+
}
29+
30+
/**
31+
*
32+
* ### Setup
33+
*
34+
* #### Callback URL
35+
* ```
36+
* https://example.com/api/auth/callback/descope
37+
* ```
38+
*
39+
* #### Configuration
40+
*
41+
* Import the provider and configure it in your **Auth.js** initialization file:
42+
*
43+
* ```ts title="pages/api/auth/[...nextauth].ts"
44+
* import NextAuth from "next-auth"
45+
* import DescopeProvider from "next-auth/providers/descope";
46+
*
47+
* export default NextAuth({
48+
* providers: [
49+
* DescopeProvider({
50+
* clientId: process.env.DESCOPE_ID,
51+
* clientSecret: process.env.DESCOPE_SECRET,
52+
* }),
53+
* ],
54+
* })
55+
* ```
56+
*
57+
* ### Configuring Descope
58+
*
59+
* Follow these steps:
60+
*
61+
* 1. Log into the [Descope console](https://app.descope.com)
62+
* 2. Follow the [OIDC instructions](https://docs.descope.com/customize/auth/oidc)
63+
*
64+
* Then, create a `.env.local` file in the project root add the following entries:
65+
*
66+
* Get the following from the Descope's console:
67+
* ```
68+
* DESCOPE_ID="<Descope Issuer's last url segment>" # Descope's Issuer can be found in "Authentication Methods > SSO > Identity Provider" (Can also be taken from "Project > Project ID")
69+
* DESCOPE_SECRET="<Descope Access Key>" # Manage > Access Keys
70+
* ```
71+
*
72+
* ### Resources
73+
*
74+
* - [Descope OIDC](https://docs.descope.com/customize/auth/oidc)
75+
* - [Descope Flows](https://docs.descope.com/customize/flows)
76+
*
77+
* ### Notes
78+
*
79+
* The Descope provider comes with a [default configuration](https://github.com/nextauthjs/next-auth/blob/main/packages/core/src/providers/descope.ts). To override the defaults for your use case, check out [customizing a built-in OAuth provider](https://authjs.dev/guides/providers/custom-provider#override-default-options).
80+
*
81+
* :::info
82+
* By default, Auth.js assumes that the Descope provider is based on the [OIDC](https://openid.net/specs/openid-connect-core-1_0.html) spec
83+
* :::
84+
*
85+
* ## Help
86+
*
87+
* If you think you found a bug in the default configuration, you can [open an issue](https://authjs.dev/new/provider-issue).
88+
*
89+
* Auth.js strictly adheres to the specification and it cannot take responsibility for any deviation from
90+
* the spec by the provider. You can open an issue, but if the problem is non-compliance with the spec,
91+
* we might not pursue a resolution. You can ask for more help in [Discussions](https://authjs.dev/new/github-discussions).
92+
*/
93+
export default function Descope(
94+
config: OIDCUserConfig<DescopeProfile>
95+
): OIDCConfig<DescopeProfile> {
96+
return {
97+
id: "descope",
98+
name: "Descope",
99+
type: "oidc",
100+
clientId: `https://api.descope.com/${config.clientId}`,
101+
style: {
102+
logo: "/descope.svg",
103+
logoDark: "/descope.svg",
104+
bg: "#1C1C23",
105+
text: "#ffffff",
106+
bgDark: "#1C1C23",
107+
textDark: "#ffffff",
108+
},
109+
options: config,
110+
}
111+
}

0 commit comments

Comments
 (0)