-
Notifications
You must be signed in to change notification settings - Fork 0
/
auth.config.ts
42 lines (39 loc) · 1.29 KB
/
auth.config.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
import GitHub, { type GitHubProfile } from '@auth/core/providers/github';
import { defineConfig } from 'auth-astro';
import type { FullSession } from 'src/common/backend/session.type';
export default defineConfig({
session: { strategy: 'jwt' },
secret: import.meta.env.AUTH_SECRET,
trustHost:
import.meta.env.AUTH_TRUST_HOST === 'true' || import.meta.env.AUTH_TRUST_HOST === true,
providers: [
GitHub({
clientId: import.meta.env.GITHUB_CLIENT_ID,
clientSecret: import.meta.env.GITHUB_CLIENT_SECRET
})
],
callbacks: {
session: ({ session, token }) => {
const fullSession = {
github: {
accessToken: token.accessToken as string,
profile: token.profile as GitHubProfile
},
...session
} satisfies FullSession;
return fullSession;
},
jwt: ({ token, account, profile }) => {
if (account) {
token.accessToken = account.access_token;
}
if (profile) {
token.profile = {
html_url: profile.html_url,
login: profile.login
};
}
return token;
}
}
});