Force user to authenticate before bootstrapping Admin Console (#20251)
This commit is contained in:
parent
67cc6bfa7c
commit
64a65bd0aa
2 changed files with 14 additions and 2 deletions
|
@ -9,3 +9,15 @@ export const keycloak = new Keycloak({
|
|||
? "security-admin-console"
|
||||
: "security-admin-console-v2",
|
||||
});
|
||||
|
||||
export async function initKeycloak() {
|
||||
const authenticated = await keycloak.init({
|
||||
onLoad: "check-sso",
|
||||
pkceMethod: "S256",
|
||||
});
|
||||
|
||||
// Force the user to login if not authenticated.
|
||||
if (!authenticated) {
|
||||
await keycloak.login();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,13 +6,13 @@ import { render } from "react-dom";
|
|||
import { createHashRouter, RouterProvider } from "react-router-dom";
|
||||
|
||||
import { initI18n } from "./i18n";
|
||||
import { keycloak } from "./keycloak";
|
||||
import { initKeycloak } from "./keycloak";
|
||||
import { RootRoute } from "./routes";
|
||||
|
||||
import "./index.css";
|
||||
|
||||
// Initialize required components before rendering app.
|
||||
await keycloak.init({ onLoad: "check-sso", pkceMethod: "S256" });
|
||||
await initKeycloak();
|
||||
await initI18n();
|
||||
|
||||
const router = createHashRouter([RootRoute]);
|
||||
|
|
Loading…
Reference in a new issue