Merge pull request #9001 from Chocobo1/csp

Improve WebUI security measures
This commit is contained in:
Mike Tzou 2018-05-31 00:34:21 +08:00 committed by GitHub
commit 6e96bbb2e9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -533,11 +533,14 @@ Http::Response WebApplication::processRequest(const Http::Request &request, cons
header(Http::HEADER_X_XSS_PROTECTION, "1; mode=block");
header(Http::HEADER_X_CONTENT_TYPE_OPTIONS, "nosniff");
QString csp = QLatin1String("default-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; script-src 'self' 'unsafe-inline'; object-src 'none';");
if (m_isClickjackingProtectionEnabled) {
header(Http::HEADER_X_FRAME_OPTIONS, "SAMEORIGIN");
header(Http::HEADER_CONTENT_SECURITY_POLICY, "default-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; script-src 'self' 'unsafe-inline'; object-src 'none';");
csp += QLatin1String(" frame-ancestors 'self';");
}
header(Http::HEADER_CONTENT_SECURITY_POLICY, csp);
return response();
}