refactor(web): switch dashboard auth from tokens to passwords (#2608)

- replace token-based launcher auth with password-based login and sessions
- migrate legacy launcher_token values into bcrypt-backed password storage
- add one-shot local auto-login bootstrap
- update config UI, i18n strings, docs, and auth-related tests
This commit is contained in:
wenjie authored and GitHub committed 2026-04-21 18:04:15 +08:00
1 parent a5379d5fff
commit 71c877a67f
34 files changed
+1188 -585

No files matched your search

+18 -4
View File
@@ -2,16 +2,26 @@
* Dashboard launcher auth API.
* Uses plain fetch (not launcherFetch) to avoid redirect loops on auth pages.
*/
export type LoginResult =
| { ok: true }
| { ok: false; status: number; error: string }
export async function postLauncherDashboardLogin(
password: string,
): Promise<boolean> {
): Promise<LoginResult> {
const res = await fetch("/api/auth/login", {
method: "POST",
headers: { "Content-Type": "application/json" },
credentials: "same-origin",
body: JSON.stringify({ password: password.trim() }),
})
return res.ok
if (res.ok) return { ok: true }
return {
ok: false,
status: res.status,
error: await readLauncherAuthError(res),
}
}
export type LauncherAuthStatus = {
@@ -57,12 +67,16 @@ export async function postLauncherDashboardSetup(
}),
})
if (res.ok) return { ok: true }
let msg = "Unknown error"
return { ok: false, error: await readLauncherAuthError(res) }
}
async function readLauncherAuthError(res: Response): Promise<string> {
let msg = `Request failed with status ${res.status}`
try {
const j = (await res.json()) as { error?: string }
if (j.error) msg = j.error
} catch {
/* ignore */
}
return { ok: false, error: msg }
return msg
}
-1
View File
@@ -11,7 +11,6 @@ export interface LauncherConfig {
port: number
public: boolean
allowed_cidrs: string[]
launcher_token: string
}
export interface SystemVersionInfo {