feat(webui): bypass tokens for trusted proxy auth

This commit is contained in:
concertypin
2026-08-04 21:53:16 +08:00
committed by Xubin Ren
parent 5cd14a42df
commit 465a918cf8
9 changed files with 134 additions and 62 deletions
+11 -7
View File
@@ -70,7 +70,7 @@ type BootState =
status: "ready";
client: NanobotClient;
token: string;
tokenExpiresAt: number;
tokenExpiresAt: number | null;
modelName: string | null;
ingressLimits: BootstrapResponse["limits"] | null;
runtimeSurface: RuntimeSurface;
@@ -733,7 +733,9 @@ export default function App() {
? toRuntimeSurface(boot.runtime_surface)
: fallbackSurface;
const runtimeHost = createRuntimeHost(runtimeSurface, boot.runtime_capabilities);
const tokenExpiresAt = bootstrapTokenExpiresAt(boot.expires_in);
const tokenExpiresAt = boot.expires_in
? bootstrapTokenExpiresAt(boot.expires_in)
: null;
if (runtimeHost.socketFactory) {
client.updateUrl(url, runtimeHost.socketFactory);
} else {
@@ -744,7 +746,7 @@ export default function App() {
current.status === "ready" && current.client === client
? {
...current,
token: boot.api_token,
token: boot.api_token ?? "",
tokenExpiresAt,
modelName: boot.model_name ?? current.modelName,
ingressLimits: boot.limits ?? current.ingressLimits,
@@ -752,7 +754,7 @@ export default function App() {
}
: current,
);
return { token: boot.api_token, url };
return { token: boot.api_token ?? "", url };
},
[],
);
@@ -787,8 +789,10 @@ export default function App() {
setState({
status: "ready",
client,
token: boot.api_token,
tokenExpiresAt: bootstrapTokenExpiresAt(boot.expires_in),
token: boot.api_token ?? "",
tokenExpiresAt: boot.expires_in
? bootstrapTokenExpiresAt(boot.expires_in)
: null,
modelName: boot.model_name ?? null,
ingressLimits: boot.limits ?? null,
runtimeSurface,
@@ -813,7 +817,7 @@ export default function App() {
);
useEffect(() => {
if (state.status !== "ready") return;
if (state.status !== "ready" || state.tokenExpiresAt === null) return;
const client = state.client;
const timer = window.setTimeout(async () => {
try {