-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauth.config.js
More file actions
43 lines (39 loc) · 1.17 KB
/
auth.config.js
File metadata and controls
43 lines (39 loc) · 1.17 KB
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
import GitHub from '@auth/core/providers/github'
import { defineConfig } from 'auth-astro'
import { SERVER_ENV } from "@/lib/env/server";
export default defineConfig({
providers: [
GitHub({
clientId : SERVER_ENV.GITHUB_CLIENT_ID,
clientSecret : SERVER_ENV.GITHUB_CLIENT_SECRET,
}),
],
secret : SERVER_ENV.AUTH_SECRET,
trustHost : true,
cookies : {
sessionToken: {
name : `astro-auth.session-token`,
options : {
httpOnly : true,
sameSite : 'lax',
path : '/',
secure : true,
maxAge : 60 * 60 * 24 * 7,
}
}
},
callbacks: {
async jwt({ token, account }) {
if ( account ) {
token.accessToken = account.access_token;
token.githubId = account.providerAccountId;
}
return token;
},
async session({ session, token }) {
session.accessToken = token.accessToken;
session.user.githubId = token.githubId;
return session;
},
},
});