Skip to content

Commit 9e1eab0

Browse files
fix(providers): convert to TS, add picture (#2851)
1 parent f0551b0 commit 9e1eab0

File tree

2 files changed

+48
-21
lines changed

2 files changed

+48
-21
lines changed

src/providers/keycloak.js

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/providers/keycloak.ts

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import { OAuthConfig, OAuthUserConfig } from "."
2+
3+
export interface KeycloakProfile {
4+
exp: number
5+
iat: number
6+
auth_time: number
7+
jti: string
8+
iss: string
9+
aud: string
10+
sub: string
11+
typ: string
12+
azp: string
13+
session_state: string
14+
at_hash: string
15+
acr: string
16+
sid: string
17+
email_verified: boolean
18+
name: string
19+
preferred_username: string
20+
given_name: string
21+
family_name: string
22+
email: string
23+
picture: string
24+
user: any
25+
}
26+
27+
export default function Keycloak<
28+
P extends Record<string, any> = KeycloakProfile
29+
>(options: OAuthUserConfig<P>): OAuthConfig<P> {
30+
return {
31+
id: "keycloak",
32+
name: "Keycloak",
33+
wellKnown: `${options.issuer}/.well-known/openid-configuration`,
34+
type: "oauth",
35+
authorization: { params: { scope: "openid email profile" } },
36+
checks: ["pkce", "state"],
37+
idToken: true,
38+
profile(profile) {
39+
return {
40+
id: profile.sub,
41+
name: profile.name ?? profile.preferred_username,
42+
email: profile.email,
43+
image: profile.picture,
44+
}
45+
},
46+
options,
47+
}
48+
}

0 commit comments

Comments
 (0)