You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
1021 B
TypeScript
29 lines
1021 B
TypeScript
import { betterAuth } from 'better-auth'
|
|
import { genericOAuth } from 'better-auth/plugins'
|
|
import { drizzleAdapter } from 'better-auth/adapters/drizzle'
|
|
import * as authSchema from '@/db/auth-schema'
|
|
import db from '@/db'
|
|
|
|
export const auth = betterAuth({
|
|
database: drizzleAdapter(db, {
|
|
provider: 'sqlite',
|
|
schema: authSchema,
|
|
}),
|
|
plugins: [
|
|
genericOAuth({
|
|
config: [
|
|
{
|
|
providerId: 'unipi',
|
|
clientId: process.env.OAUTH_CLIENT_ID!,
|
|
clientSecret: process.env.OAUTH_CLIENT_SECRET!,
|
|
scopes: process.env.OAUTH_SCOPES!.split(' '),
|
|
userInfoUrl: process.env.OAUTH_USER_INFO_URL!,
|
|
authorizationUrl: process.env.OAUTH_AUTH_URL!,
|
|
tokenUrl: `${process.env.OAUTH_TOKEN_HOST}${process.env.OAUTH_TOKEN_PATH}`,
|
|
redirectURI: process.env.OAUTH_REDIRECT_URL!,
|
|
},
|
|
],
|
|
}),
|
|
],
|
|
})
|