diff --git a/server/routes/api/teams/schema.ts b/server/routes/api/teams/schema.ts index 052a5ac095..bd028c5d93 100644 --- a/server/routes/api/teams/schema.ts +++ b/server/routes/api/teams/schema.ts @@ -58,6 +58,8 @@ export const TeamsUpdateSchema = BaseSchema.extend({ .optional(), /** Side to display the document's table of contents in relation to the main content. */ tocPosition: z.nativeEnum(TOCPosition).optional(), + /** Whether to prevent shared documents from being embedded in iframes on external websites. */ + preventDocumentEmbedding: z.boolean().optional(), }) .optional(), }), diff --git a/server/routes/app.ts b/server/routes/app.ts index ea2ea1472e..91592c54aa 100644 --- a/server/routes/app.ts +++ b/server/routes/app.ts @@ -194,8 +194,11 @@ export const renderShare = async (ctx: Context, next: Next) => { ctx.status = 404; } - // Allow shares to be embedded in iframes on other websites - ctx.remove("X-Frame-Options"); + // Allow shares to be embedded in iframes on other websites unless prevented by team preference + const preventEmbedding = team?.getPreference(TeamPreference.PreventDocumentEmbedding) ?? false; + if (!preventEmbedding) { + ctx.remove("X-Frame-Options"); + } const publicBranding = team?.getPreference(TeamPreference.PublicBranding) ?? false; diff --git a/shared/constants.ts b/shared/constants.ts index 6c63f9c8bc..236214c452 100644 --- a/shared/constants.ts +++ b/shared/constants.ts @@ -32,6 +32,7 @@ export const TeamPreferenceDefaults: TeamPreferences = { [TeamPreference.Commenting]: true, [TeamPreference.CustomTheme]: undefined, [TeamPreference.TocPosition]: TOCPosition.Left, + [TeamPreference.PreventDocumentEmbedding]: false, }; export const UserPreferenceDefaults: UserPreferences = { diff --git a/shared/types.ts b/shared/types.ts index b75ee861ea..0e0c6e3d98 100644 --- a/shared/types.ts +++ b/shared/types.ts @@ -297,6 +297,8 @@ export enum TeamPreference { CustomTheme = "customTheme", /** Side to display the document's table of contents in relation to the main content. */ TocPosition = "tocPosition", + /** Whether to prevent shared documents from being embedded in iframes on external websites. */ + PreventDocumentEmbedding = "preventDocumentEmbedding", } export type TeamPreferences = { @@ -310,6 +312,7 @@ export type TeamPreferences = { [TeamPreference.Commenting]?: boolean; [TeamPreference.CustomTheme]?: Partial; [TeamPreference.TocPosition]?: TOCPosition; + [TeamPreference.PreventDocumentEmbedding]?: boolean; }; export enum NavigationNodeType {