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 configuration option whether to add the "X-Frame-Options", "SAMEORIGIN" header #172

Open
wants to merge 4 commits into
base: 3.7-release
Choose a base branch
from
Open
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
12 changes: 11 additions & 1 deletion src/web/Configuration.C
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,8 @@ void Configuration::reset()
bootstrapConfig_.clear();
numSessionThreads_ = -1;
allowedOrigins_.clear();

xFrameSameOrigin_ = true;

if (!appRoot_.empty())
setAppRoot(appRoot_);
}
Expand Down Expand Up @@ -475,6 +476,13 @@ std::string Configuration::uaCompatible() const
READ_LOCK;
return uaCompatible_;
}

bool Configuration::xFrameSameOrigin() const
{
READ_LOCK;
return xFrameSameOrigin_;
}


bool Configuration::sessionIdCookie() const
{
Expand Down Expand Up @@ -1021,6 +1029,8 @@ void Configuration::readApplicationSettings(xml_node<> *app)
boost::split(allowedOrigins_, allowedOrigins, boost::is_any_of(","));
for (std::size_t i = 0; i < allowedOrigins_.size(); ++i)
boost::trim(allowedOrigins_[i]);

setBoolean(app, "x-frame-same-origin", xFrameSameOrigin_);
}

void Configuration::rereadConfiguration()
Expand Down
4 changes: 4 additions & 0 deletions src/web/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ class WT_API Configuration
bool agentIsBot(const std::string& agent) const;
bool agentSupportsAjax(const std::string& agent) const;
std::string uaCompatible() const;

bool xFrameSameOrigin() const;

// Things which are overridden by the connector
void setSessionTimeout(int sessionTimeout);
Expand Down Expand Up @@ -277,6 +279,8 @@ class WT_API Configuration
bool connectorWebSockets_;
std::string connectorSessionIdPrefix_;

bool xFrameSameOrigin_;

void reset();
void readApplicationSettings(Wt::rapidxml::xml_node<char> *app);
void readConfiguration(bool silent);
Expand Down
6 changes: 4 additions & 2 deletions src/web/WebRenderer.C
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,8 @@ void WebRenderer::serveBootstrap(WebResponse& response)
boot.setVar("BOOT_STYLE_URL", bootStyleUrl.str());

setCaching(response, false);
response.addHeader("X-Frame-Options", "SAMEORIGIN");
if (conf.xFrameSameOrigin())
response.addHeader("X-Frame-Options", "SAMEORIGIN");

std::string contentType = "text/html; charset=UTF-8";

Expand Down Expand Up @@ -1484,7 +1485,8 @@ void WebRenderer::serveMainpage(WebResponse& response)
std::string contentType = "text/html; charset=UTF-8";

setCaching(response, false);
response.addHeader("X-Frame-Options", "SAMEORIGIN");
if (conf.xFrameSameOrigin())
response.addHeader("X-Frame-Options", "SAMEORIGIN");
setHeaders(response, contentType);

currentFormObjectsList_ = createFormObjectsList(app);
Expand Down
2 changes: 2 additions & 0 deletions wt_config.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,8 @@
<!-- <property name="leafletCSSURL">https://unpkg.com/leaflet@1.5.1/dist/leaflet.css</property> -->
</properties>

<x-frame-same-origin>true</x-frame-same-origin>

</application-settings>


Expand Down