Spiegel von
https://github.com/dani-garcia/vaultwarden.git
synchronisiert 2024-11-06 02:38:00 +01:00
make cors work with multi-domains
Dieser Commit ist enthalten in:
Ursprung
0d7e678c2e
Commit
5462b97c26
1 geänderte Dateien mit 13 neuen und 3 gelöschten Zeilen
16
src/util.rs
16
src/util.rs
|
@ -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
|
||||
|
|
Laden …
In neuem Issue referenzieren