1
0
Fork 1
Spiegel von https://github.com/dani-garcia/vaultwarden.git synchronisiert 2024-11-05 02:28:00 +01:00

make cors work with multi-domains

Dieser Commit ist enthalten in:
BlockListed 2023-09-09 11:16:24 +02:00
Ursprung 0d7e678c2e
Commit 5462b97c26
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 2D204777C477B588

Datei anzeigen

@ -17,7 +17,7 @@ use tokio::{
time::{sleep, Duration},
};
use crate::CONFIG;
use crate::{CONFIG, config::extract_url_host};
pub struct AppHeaders();
@ -129,9 +129,19 @@ impl Cors {
// If a match exists, return it. Otherwise, return None.
fn get_allowed_origin(headers: &HeaderMap<'_>) -> Option<String> {
let origin = Cors::get_header(headers, "Origin");
let domain_origin = CONFIG.domain_origin();
let domain_origin_opt = CONFIG.domain_origin(&extract_url_host(&origin));
let safari_extension_origin = "file://";
if origin == domain_origin || origin == safari_extension_origin {
let found_origin = {
if let Some(domain_origin) = domain_origin_opt {
origin == domain_origin
} else {
false
}
};
if found_origin || origin == safari_extension_origin {
Some(origin)
} else {
None