feat: add Keycloak authentication

This commit is contained in:
2026-08-19 12:11:18 +08:00
parent bdd5eff776
commit d08cf2abc1
27 changed files with 533 additions and 128 deletions
+24 -14
View File
@@ -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>
);