keycloak-scim/js/apps/admin-ui/src/keycloak.ts
Jon Koops 5bf2d4b6ec
Enable PKCE by default for Keycloak JS (#26412)
Closes #26411

Signed-off-by: Jon Koops <jonkoops@gmail.com>
2024-01-23 14:04:13 +01:00

20 lines
450 B
TypeScript

import Keycloak from "keycloak-js";
import environment from "./environment";
export const keycloak = new Keycloak({
url: environment.authServerUrl,
realm: environment.loginRealm,
clientId: environment.clientId,
});
export async function initKeycloak() {
const authenticated = await keycloak.init({
onLoad: "check-sso",
});
// Force the user to login if not authenticated.
if (!authenticated) {
await keycloak.login();
}
}