feat(auth): add oidc-client-ts UserManager with sessionStorage store

This commit is contained in:
Urban Modig
2025-10-13 00:15:20 +02:00
parent 39c1958128
commit 47cef8e5a5

19
auth/oidc.ts Normal file
View File

@ -0,0 +1,19 @@
import { UserManager, WebStorageStateStore, Log, type UserManagerSettings } from 'oidc-client-ts'
const settings: UserManagerSettings = {
authority: import.meta.env.VITE_OIDC_AUTHORITY!,
client_id: import.meta.env.VITE_OIDC_CLIENT_ID!,
redirect_uri: import.meta.env.VITE_OIDC_REDIRECT_URI!,
post_logout_redirect_uri: import.meta.env.VITE_OIDC_POST_LOGOUT_REDIRECT_URI!,
response_type: 'code',
scope: 'openid profile email',
loadUserInfo: true,
automaticSilentRenew: true,
silent_redirect_uri: import.meta.env.VITE_OIDC_SILENT_REDIRECT_URI!,
userStore: new WebStorageStateStore({ store: window.sessionStorage }),
}
if (import.meta.env.DEV) Log.setLogger(console)
export const userManager = new UserManager(settings)