trips) adding initial commit

This commit is contained in:
2026-02-18 20:23:34 -05:00
commit 1068145261
67 changed files with 3602 additions and 0 deletions

44
src/auth.ts Normal file
View File

@@ -0,0 +1,44 @@
import { SvelteKitAuth } from '@auth/sveltekit';
import { env } from '$env/dynamic/private';
export const { handle, signIn, signOut } = SvelteKitAuth({
providers: [
{
id: 'synology',
name: 'Synology',
type: 'oidc',
issuer: env.SYNOLOGY_ISSUER,
clientId: env.SYNOLOGY_CLIENT_ID,
clientSecret: env.SYNOLOGY_CLIENT_SECRET,
redirectProxyUrl: env.AUTH_URL,
profile(profile) {
return {
id: profile.sub as string,
name: (profile.username ?? profile.name ?? profile.preferred_username) as string,
email: profile.email as string | undefined
};
}
}
],
trustHost: true,
callbacks: {
jwt({ token, profile }) {
if (profile?.sub) token.sub = profile.sub as string;
return token;
},
session({ session, token }) {
if (token.sub) session.user.id = token.sub;
return session;
},
redirect({ url, baseUrl }) {
const appRoot = env.AUTH_URL?.replace(/\/auth$/, '') ?? baseUrl;
if (url.startsWith(appRoot)) return url;
return appRoot;
}
},
cookies: {
sessionToken: { name: 'authjs.session-token' },
callbackUrl: { name: 'authjs.callback-url' },
csrfToken: { name: 'authjs.csrf-token' }
}
});