Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Content] Check referrer policy & cotent security policy setting for duo mode toggle #2961

Merged
merged 3 commits into from
Sep 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion src/apps/content-editor/src/app/views/ItemEdit/ItemEdit.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,30 @@ export default function ItemEdit() {
const duoModeDisabled =
isFetching ||
instanceSettings?.find((setting) => {
// Makes sure that the CSP value is either empty or contains
// frame-ancestors 'self' zesty.io *.zesty.io anywhere in the value
const invalidCSPSettings =
setting.key === "content_security_policy" && !!setting.value
? !setting.value.includes("frame-ancestors") ||
!setting.value.includes("'self'") ||
!(
setting.value.includes("zesty.io") ||
setting.value.includes("*.zesty.io")
)
: false;

// if any of these settings are present then DuoMode is unavailable
return (
(setting.key === "basic_content_api_key" && setting.value) ||
(setting.key === "headless_authorization_key" && setting.value) ||
(setting.key === "authorization_key" && setting.value) ||
(setting.key === "x_frame_options" &&
!!setting.value &&
setting.value !== "sameorigin")
setting.value !== "sameorigin") ||
(setting.key === "referrer_policy" &&
!!setting.value &&
setting.value !== "strict-origin-when-cross-origin") ||
invalidCSPSettings
);
}) ||
model?.type === "dataset";
Expand Down
Loading