Phase 2: Docker and OIDC auth
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
let accessToken: string | null = null;
|
||||
|
||||
export function isOidcConfigured(): boolean {
|
||||
const enabled =
|
||||
(import.meta.env.VITE_OIDC_ENABLED ?? "true").toLowerCase() !== "false";
|
||||
return Boolean(
|
||||
enabled &&
|
||||
import.meta.env.VITE_OIDC_ISSUER &&
|
||||
import.meta.env.VITE_OIDC_CLIENT_ID,
|
||||
);
|
||||
}
|
||||
|
||||
export function getOidcConfig() {
|
||||
return {
|
||||
authority: import.meta.env.VITE_OIDC_ISSUER as string,
|
||||
client_id: import.meta.env.VITE_OIDC_CLIENT_ID as string,
|
||||
redirect_uri:
|
||||
import.meta.env.VITE_OIDC_REDIRECT_URI || window.location.origin,
|
||||
post_logout_redirect_uri:
|
||||
import.meta.env.VITE_OIDC_POST_LOGOUT_REDIRECT_URI ||
|
||||
window.location.origin,
|
||||
scope: import.meta.env.VITE_OIDC_SCOPE || "openid profile email",
|
||||
response_type: "code" as const,
|
||||
automaticSilentRenew: false,
|
||||
loadUserInfo: true,
|
||||
onSigninCallback: () => {
|
||||
window.history.replaceState(
|
||||
{},
|
||||
document.title,
|
||||
window.location.pathname + window.location.search,
|
||||
);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export function setAccessToken(token: string | null | undefined) {
|
||||
accessToken = token ?? null;
|
||||
}
|
||||
|
||||
export function getAccessToken(): string | null {
|
||||
return accessToken;
|
||||
}
|
||||
Reference in New Issue
Block a user