customer-portal/src/auth.server.ts
chris b509508ee6
All checks were successful
Test action / Print hello world (push) Successful in 6m22s
too lazy to think of a message, so enjoy this pointless text. Good luck future me...
2025-09-23 11:13:23 +00:00

51 lines
1.3 KiB
TypeScript
Executable file

import { betterAuth } from "better-auth";
import { genericOAuth } from "better-auth/plugins";
import { Database } from "bun:sqlite";
export const auth = betterAuth({
appName: "Streamarr",
basePath: "/api/auth",
database: new Database('auth.sqlite', { create: true }),
logger: {
level: "debug",
log(level, message, ...args) {
console.log(level, message, {args});
},
},
user: {
additionalFields: {
name: {
type: "string",
nullable: true,
},
username: {
type: "string",
nullable: true,
},
},
},
plugins: [
genericOAuth({
config: [
{
providerId: "zitadel",
clientId: "",
clientSecret: "",
discoveryUrl: "https://auth.amarth.cloud/.well-known/openid-configuration",
scopes: [
"offline_access",
"openid",
"email",
"picture",
"profile",
"groups",
],
accessType: "offline",
pkce: true,
mapProfileToUser: ({ id, name, email, image, preferred_username, emailVerified }) =>
({ id, name, email, emailVerified, image, username: preferred_username }),
},
],
}),
],
});