mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 10:47:37 +00:00
Merge branch 'main' into cnsl-navigation-rehaul
This commit is contained in:
@@ -44,6 +44,8 @@ export async function setSAMLFormCookie(value: string): Promise<string> {
|
||||
name: uid,
|
||||
value: value,
|
||||
httpOnly: true,
|
||||
secure: process.env.NODE_ENV === "production", // Required for HTTPS in production
|
||||
sameSite: "lax", // Allows cookies with top-level navigation (needed for SAML redirects)
|
||||
path: "/",
|
||||
maxAge: 5 * 60, // 5 minutes
|
||||
});
|
||||
|
@@ -1016,44 +1016,10 @@ export async function startIdentityProviderFlow({
|
||||
|
||||
return `${redirectUrl}?${params.toString()}`;
|
||||
} catch (stringifyError) {
|
||||
console.error("Failed to stringify formData.fields:", {
|
||||
error: stringifyError,
|
||||
formDataFields: formData.fields,
|
||||
formDataUrl: formData.url,
|
||||
fieldsType: typeof formData.fields,
|
||||
fieldsConstructor: formData.fields?.constructor?.name,
|
||||
});
|
||||
|
||||
// Try to create a safe serialization by converting to plain object
|
||||
try {
|
||||
const safeFields: Record<string, string> = {};
|
||||
const fieldsObj = formData.fields || {};
|
||||
|
||||
// Convert each field to a string if it's not already
|
||||
for (const [key, value] of Object.entries(fieldsObj)) {
|
||||
safeFields[key] =
|
||||
typeof value === "string" ? value : String(value);
|
||||
}
|
||||
|
||||
console.log(
|
||||
"Using safe serialization for formData.fields:",
|
||||
safeFields,
|
||||
);
|
||||
|
||||
const safeStringified = JSON.stringify(safeFields);
|
||||
const dataId = await setSAMLFormCookie(safeStringified);
|
||||
const params = new URLSearchParams({
|
||||
url: formData.url,
|
||||
id: dataId,
|
||||
});
|
||||
|
||||
return `${redirectUrl}?${params.toString()}`;
|
||||
} catch (fallbackError) {
|
||||
console.error("Safe serialization also failed:", fallbackError);
|
||||
throw new Error(
|
||||
`Failed to serialize SAML form data: ${stringifyError instanceof Error ? stringifyError.message : String(stringifyError)}`,
|
||||
);
|
||||
}
|
||||
console.error("JSON serialization failed:", stringifyError);
|
||||
throw new Error(
|
||||
`Failed to serialize SAML form data: ${stringifyError instanceof Error ? stringifyError.message : String(stringifyError)}`,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
|
Reference in New Issue
Block a user