-
Notifications
You must be signed in to change notification settings - Fork 0
/
auth.ts
51 lines (49 loc) · 1.62 KB
/
auth.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import NextAuth from "next-auth";
export const { handlers, signIn, signOut, auth } = NextAuth({
secret: process.env.NEXTAUTH_SECRET,
callbacks: {
async jwt({ token, profile, account, user }) {
if (account && profile) {
token.id = profile.sub;
token.name = profile.name ?? profile.username;
token.email = profile.email;
token.picture = profile.picture;
}
return token;
},
async session({ session, token }) {
session.user.id = token.id as string;
session.user.name = token.name as string;
session.user.email = token.email as string;
session.user.image = token.picture as string;
return session;
},
},
providers: [
{
id: "logto",
name: "MikanDev Account",
type: "oidc",
issuer: "https://auth.mikandev.com/oidc",
authorization: {
params: {
scope: "openid offline_access profile email identities",
},
},
clientId: process.env.LOGTO_CLIENT_ID,
clientSecret: process.env.LOGTO_CLIENT_SECRET,
client: {
id_token_signed_response_alg: "ES384",
},
token: true,
profile(profile) {
return {
id: profile.sub,
name: profile.name ?? profile.username,
email: profile.email,
image: profile.picture,
};
},
},
],
});