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

Added GCL Setting to suppress the X-Frame-Options SAMEORIGIN header #476

Merged
merged 1 commit into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,18 @@ public static IServiceCollection AddGclServices(this IServiceCollection services
{
options.HeaderName = "X-CSRF-TOKEN";
options.Cookie.Name = "CSRF-TOKEN";
options.SuppressXFrameOptionsHeader = gclSettings.SuppressXFrameOptionHeader;
});
}
else
{
services.AddControllersWithViews().AddNewtonsoftJson();
// the call to AddControllersWithViews() (or AddMvc() for that matter) will always call AddAntiforgery() no matter what, so DisableXsrfProtection might need another look
// setting the XFrameOptions setting here as well makes sure this setting will always work no matter what happens with DisableXsrfProtection
services.AddAntiforgery(options =>
{
options.SuppressXFrameOptionsHeader = gclSettings.SuppressXFrameOptionHeader;
});
}

// Let MVC know about the GCL controllers.
Expand Down
6 changes: 6 additions & 0 deletions GeeksCoreLibrary/Core/Models/GclSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,12 @@ public GclSettings()
/// By default the GCL adds XSRF protection in the form of anti forgery tokens. To disable this functionality, set this option to <see langword="true"/>.
/// </summary>
public bool DisableXsrfProtection { get; set; }

/// <summary>
/// Specifies whether to suppress the generation of X-Frame-Options header which is used to prevent ClickJacking.
/// By default, the X-Frame-Options header is generated with the value SAMEORIGIN. If this setting is 'true', the X-Frame-Options header will not be generated for the response.
/// </summary>
public bool SuppressXFrameOptionHeader { get; set; }

/// <summary>
/// In Wiser 3 we created a new templates module from scratch, which will be used by default.
Expand Down