fix(webui): route missing API bootstrap tokens to auth
maintainer edit: handle review feedback by treating bootstrap responses without api_token as auth-required, and remove the obsolete issue_token(api_token=...) compatibility path now that API tokens are issued separately.
This commit is contained in:
+13
-5
@@ -23,6 +23,7 @@ import { useSkills } from "@/hooks/useSkills";
|
||||
import { ThemeProvider, useTheme } from "@/hooks/useTheme";
|
||||
import { cn } from "@/lib/utils";
|
||||
import {
|
||||
BootstrapAuthRequiredError,
|
||||
clearSavedSecret,
|
||||
consumeUrlBootstrapSecret,
|
||||
deriveWsUrl,
|
||||
@@ -296,6 +297,12 @@ function normalizeWorkspaceScope(scope: WorkspaceScopePayload): WorkspaceScopePa
|
||||
};
|
||||
}
|
||||
|
||||
function isBootstrapAuthRequired(error: unknown): boolean {
|
||||
if (error instanceof BootstrapAuthRequiredError) return true;
|
||||
const msg = error instanceof Error ? error.message : String(error);
|
||||
return msg.includes("HTTP 401") || msg.includes("HTTP 403");
|
||||
}
|
||||
|
||||
function HostChrome({
|
||||
onToggleSidebar,
|
||||
onSidebarPreviewEnter,
|
||||
@@ -410,11 +417,13 @@ export default function App() {
|
||||
});
|
||||
} catch (e) {
|
||||
if (cancelled) return;
|
||||
const msg = (e as Error).message;
|
||||
if (msg.includes("HTTP 401") || msg.includes("HTTP 403")) {
|
||||
if (isBootstrapAuthRequired(e)) {
|
||||
setState({ status: "auth", failed: !!secret });
|
||||
} else {
|
||||
setState({ status: "error", message: msg });
|
||||
setState({
|
||||
status: "error",
|
||||
message: e instanceof Error ? e.message : String(e),
|
||||
});
|
||||
}
|
||||
}
|
||||
})();
|
||||
@@ -432,8 +441,7 @@ export default function App() {
|
||||
try {
|
||||
await refreshReadyClient(client, state.runtimeSurface);
|
||||
} catch (e) {
|
||||
const msg = (e as Error).message;
|
||||
if (msg.includes("HTTP 401") || msg.includes("HTTP 403")) {
|
||||
if (isBootstrapAuthRequired(e)) {
|
||||
setState({ status: "auth", failed: !!bootstrapSecretRef.current });
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user