From 47cef8e5a5e38e4a5c7d91f53eeb5e637d748bdc Mon Sep 17 00:00:00 2001 From: Urban Modig Date: Mon, 13 Oct 2025 00:15:20 +0200 Subject: [PATCH] feat(auth): add oidc-client-ts UserManager with sessionStorage store --- auth/oidc.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 auth/oidc.ts diff --git a/auth/oidc.ts b/auth/oidc.ts new file mode 100644 index 0000000..7270e31 --- /dev/null +++ b/auth/oidc.ts @@ -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) \ No newline at end of file