Skip to content

Commit 3c210d9

Browse files
josh-the-devJoshgrant-devbalazsorban44
authoredJul 7, 2022
feat(providers): add Duende IdentityServer 6 (#4850)
* add duende identity server 6 provider * Update docs/versioned_docs/version-v3/providers/duende-identity-server6.md Co-authored-by: Balázs Orbán <info@balazsorban.com> * Update docs/versioned_docs/version-v3/providers/duende-identity-server6.md Co-authored-by: Balázs Orbán <info@balazsorban.com> * Update packages/next-auth/src/providers/duende-identity-server6.ts Co-authored-by: Balázs Orbán <info@balazsorban.com> * Update packages/next-auth/src/providers/duende-identity-server6.ts Co-authored-by: Balázs Orbán <info@balazsorban.com> * Update docs/versioned_docs/version-v3/providers/duende-identity-server6.md Co-authored-by: Balázs Orbán <info@balazsorban.com> * Update apps/dev/pages/api/auth/[...nextauth].ts Co-authored-by: Balázs Orbán <info@balazsorban.com> * Update docs/versioned_docs/version-v3/providers/duende-identity-server6.md Co-authored-by: Balázs Orbán <info@balazsorban.com> * Update docs/versioned_docs/version-v3/providers/duende-identity-server6.md Co-authored-by: Balázs Orbán <info@balazsorban.com> * Update packages/next-auth/src/providers/duende-identity-server6.ts Co-authored-by: Balázs Orbán <info@balazsorban.com> Co-authored-by: Joshua <joshua.grant@tempcover.com> Co-authored-by: Balázs Orbán <info@balazsorban.com>
1 parent 9457593 commit 3c210d9

File tree

4 files changed

+91
-1
lines changed

4 files changed

+91
-1
lines changed
 

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

+6
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import TwitterProvider, {
88
} from "next-auth/providers/twitter"
99
import CredentialsProvider from "next-auth/providers/credentials"
1010
import IDS4Provider from "next-auth/providers/identity-server4"
11+
import DuendeIDS6Provider from "next-auth/providers/duende-identity-server6"
1112
import Twitch from "next-auth/providers/twitch"
1213
import GoogleProvider from "next-auth/providers/google"
1314
import FacebookProvider from "next-auth/providers/facebook"
@@ -150,6 +151,11 @@ export const authOptions: NextAuthOptions = {
150151
clientSecret: process.env.IDS4_SECRET,
151152
issuer: process.env.IDS4_ISSUER,
152153
}),
154+
DuendeIDS6Provider({
155+
clientId: "interactive.confidential",
156+
clientSecret: "secret",
157+
issuer: "https://demo.duendesoftware.com",
158+
}),
153159
DiscordProvider({
154160
clientId: process.env.DISCORD_ID,
155161
clientSecret: process.env.DISCORD_SECRET,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
id: duende-identityserver6
3+
title: DuendeIdentityServer6
4+
---
5+
6+
## Documentation
7+
8+
https://docs.duendesoftware.com/identityserver/v6
9+
10+
## Options
11+
12+
The **DuendeIdentityServer6 Provider** comes with a set of default options:
13+
14+
- [DuendeIdentityServer6 Provider options](https://github.com/nextauthjs/next-auth/tree/main/packages/next-auth/src/providers/duende-identity-server6.ts)
15+
16+
You can override any of the options to suit your own use case.
17+
18+
## Example
19+
20+
```js
21+
import DuendeIDS6Provider from "next-auth/providers/duende-identity-server6"
22+
23+
...
24+
providers: [
25+
DuendeIDS6Provider({
26+
clientId: process.env.DUENDE_IDS6_ID,
27+
clientSecret: process.env.DUENDE_IDS6_SECRET,
28+
issuer: process.env.DUENDE_IDS6_ISSUER,
29+
})
30+
]
31+
...
32+
```
33+
34+
## Demo IdentityServer
35+
36+
The configuration below is for the demo server at https://demo.duendesoftware.com/
37+
38+
If you want to try it out, you can copy and paste the configuration below.
39+
40+
You can sign in to the demo service with either <b>bob/bob</b> or <b>alice/alice</b>.
41+
42+
```js
43+
import DuendeIDS6Provider from "next-auth/providers/duende-identity-server6"
44+
...
45+
providers: [
46+
DuendeIDS6Provider({
47+
clientId: "interactive.confidential",
48+
clientSecret: "secret",
49+
issuer: "https://demo.duendesoftware.com",
50+
})
51+
]
52+
...
53+
```

‎docs/versioned_docs/version-v3/providers/identity-server4.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,6 @@ providers: [
5454
clientSecret: "secret",
5555
protection: "pkce"
5656
})
57-
}
57+
]
5858
...
5959
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import type { OAuthConfig, OAuthUserConfig } from "./oauth"
2+
3+
export interface DuendeISUser extends Record<string, any> {
4+
email: string
5+
id: string
6+
name: string
7+
verified: boolean
8+
}
9+
10+
export default function DuendeIdentityServer6<P extends DuendeISUser>(
11+
options: OAuthUserConfig<P>
12+
): OAuthConfig<P> {
13+
return {
14+
id: "duende-identityserver6",
15+
name: "DuendeIdentityServer6",
16+
type: "oauth",
17+
wellKnown: `${options.issuer}/.well-known/openid-configuration`,
18+
authorization: { params: { scope: "openid profile email" } },
19+
checks: ["pkce", "state"],
20+
idToken: true,
21+
profile(profile) {
22+
return {
23+
id: profile.sub,
24+
name: profile.name,
25+
email: profile.email,
26+
image: null,
27+
}
28+
},
29+
options,
30+
}
31+
}

1 commit comments

Comments
 (1)
Please sign in to comment.