feat: add Keycloak authentication
This commit is contained in:
+24
-14
@@ -1,23 +1,33 @@
|
||||
import React from "react";
|
||||
import ReactDOM from "react-dom/client";
|
||||
|
||||
import { App } from "@/app/app";
|
||||
import { env } from "@/shared/config/env";
|
||||
import { AuthStartupScreen } from "@/app/auth-startup-screen";
|
||||
import { initializeAuthentication } from "@/shared/auth/keycloak-auth";
|
||||
import "@/styles.css";
|
||||
import "maplibre-gl/dist/maplibre-gl.css";
|
||||
import "katex/dist/katex.min.css";
|
||||
import "streamdown/styles.css";
|
||||
|
||||
async function prepareMocks() {
|
||||
if (!env.TJWATER_ENABLE_MSW) return;
|
||||
const { worker } = await import("@/mocks/browser");
|
||||
await worker.start({ onUnhandledRequest: "bypass" });
|
||||
const root = ReactDOM.createRoot(document.getElementById("root")!);
|
||||
|
||||
root.render(<AuthStartupScreen />);
|
||||
|
||||
try {
|
||||
const [{ App }, { env }] = await Promise.all([
|
||||
import("@/app/app"),
|
||||
import("@/shared/config/env")
|
||||
]);
|
||||
if (env.TJWATER_ENABLE_MSW) {
|
||||
const { worker } = await import("@/mocks/browser");
|
||||
await worker.start({ onUnhandledRequest: "bypass" });
|
||||
}
|
||||
const authentication = await initializeAuthentication(env);
|
||||
root.render(
|
||||
<React.StrictMode>
|
||||
<App authentication={authentication} />
|
||||
</React.StrictMode>
|
||||
);
|
||||
} catch (error) {
|
||||
console.error("Failed to initialize authentication", error);
|
||||
root.render(<AuthStartupScreen error />);
|
||||
}
|
||||
|
||||
await prepareMocks();
|
||||
|
||||
ReactDOM.createRoot(document.getElementById("root")!).render(
|
||||
<React.StrictMode>
|
||||
<App />
|
||||
</React.StrictMode>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user