fix: validate state for manual Chutes OAuth

This commit is contained in:
Peter Steinberger
2026-02-14 23:01:28 +01:00
parent 937e1c21f2
commit a99ad11a41
6 changed files with 69 additions and 58 deletions

View File

@@ -1127,7 +1127,7 @@ describe("applyAuthChoice", () => {
expect(text).toHaveBeenCalledWith(
expect.objectContaining({
message: "Paste the redirect URL (or authorization code)",
message: "Paste the redirect URL",
}),
);
expect(result.config.auth?.profiles?.["chutes:remote-user"]).toMatchObject({

View File

@@ -156,7 +156,7 @@ export async function loginChutes(params: {
await params.onAuth({ url });
params.onProgress?.("Waiting for redirect URL…");
const input = await params.onPrompt({
message: "Paste the redirect URL (or authorization code)",
message: "Paste the redirect URL",
placeholder: `${params.app.redirectUri}?code=...&state=...`,
});
const parsed = parseOAuthCallbackInput(String(input), state);
@@ -176,7 +176,7 @@ export async function loginChutes(params: {
}).catch(async () => {
params.onProgress?.("OAuth callback not detected; paste redirect URL…");
const input = await params.onPrompt({
message: "Paste the redirect URL (or authorization code)",
message: "Paste the redirect URL",
placeholder: `${params.app.redirectUri}?code=...&state=...`,
});
const parsed = parseOAuthCallbackInput(String(input), state);

View File

@@ -17,8 +17,7 @@ export function createVpsAwareOAuthHandlers(params: {
onAuth: (event: { url: string }) => Promise<void>;
onPrompt: (prompt: OAuthPrompt) => Promise<string>;
} {
const manualPromptMessage =
params.manualPromptMessage ?? "Paste the redirect URL (or authorization code)";
const manualPromptMessage = params.manualPromptMessage ?? "Paste the redirect URL";
let manualCodePromise: Promise<string> | undefined;
return {