Browse Source
Fix icon redirect not working on desktop
We also need to exclude the header in case we do an external_icon call.
Fixes #5535
Signed-off-by: BlackDex <black.dex@gmail.com>
pull/5536/head
BlackDex
3 months ago
No known key found for this signature in database
GPG Key ID: 58C80A2AA6C765E1
1 changed files with
8 additions and
4 deletions
-
src/util.rs
|
|
@ -56,13 +56,17 @@ impl Fairing for AppHeaders { |
|
|
|
res.set_raw_header("X-Content-Type-Options", "nosniff"); |
|
|
|
res.set_raw_header("X-Robots-Tag", "noindex, nofollow"); |
|
|
|
|
|
|
|
if !res.headers().get_one("Content-Type").is_some_and(|v| v.starts_with("image/")) { |
|
|
|
res.set_raw_header("Cross-Origin-Resource-Policy", "same-origin"); |
|
|
|
} |
|
|
|
|
|
|
|
// Obsolete in modern browsers, unsafe (XS-Leak), and largely replaced by CSP
|
|
|
|
res.set_raw_header("X-XSS-Protection", "0"); |
|
|
|
|
|
|
|
// The `Cross-Origin-Resource-Policy` header should not be set on images or on the `icon_external` route.
|
|
|
|
// Else some clients, like the Bitwardem Desktop will fail to download the icons
|
|
|
|
if !(res.headers().get_one("Content-Type").is_some_and(|v| v.starts_with("image/")) |
|
|
|
|| req.route().is_some_and(|v| v.name.as_deref() == Some("icon_external"))) |
|
|
|
{ |
|
|
|
res.set_raw_header("Cross-Origin-Resource-Policy", "same-origin"); |
|
|
|
} |
|
|
|
|
|
|
|
// Do not send the Content-Security-Policy (CSP) Header and X-Frame-Options for the *-connector.html files.
|
|
|
|
// This can cause issues when some MFA requests needs to open a popup or page within the clients like WebAuthn, or Duo.
|
|
|
|
// This is the same behavior as upstream Bitwarden.
|
|
|
|