mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-14 01:03:08 -07:00
Add option to control WebUI clickjacking protection
Some users actually want embedding WebUI into their custom build iframe. Closes #7370.
This commit is contained in:
parent
e8a69dd60c
commit
bad4d94f77
8 changed files with 52 additions and 3 deletions
|
@ -428,6 +428,8 @@ void WebApplication::configure()
|
|||
m_currentLocale = newLocale;
|
||||
m_translatedFiles.clear();
|
||||
}
|
||||
|
||||
m_isClickjackingProtectionEnabled = pref->isWebUiClickjackingProtectionEnabled();
|
||||
}
|
||||
|
||||
void WebApplication::registerAPIController(const QString &scope, APIController *controller)
|
||||
|
@ -525,11 +527,13 @@ Http::Response WebApplication::processRequest(const Http::Request &request, cons
|
|||
print(error.message(), Http::CONTENT_TYPE_TXT);
|
||||
}
|
||||
|
||||
// avoid clickjacking attacks
|
||||
header(Http::HEADER_X_FRAME_OPTIONS, "SAMEORIGIN");
|
||||
header(Http::HEADER_X_XSS_PROTECTION, "1; mode=block");
|
||||
header(Http::HEADER_X_CONTENT_TYPE_OPTIONS, "nosniff");
|
||||
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';");
|
||||
|
||||
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';");
|
||||
}
|
||||
|
||||
return response();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue