feat: allow HTTP operation on private LAN addresses
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
//! Zweck: Persistenter Dienstclient und ausschließlich lokale Tokenprüfung.
|
||||
//! Wichtig: Bestätigung erst nach fsync; Geheimnisse werden niemals protokolliert.
|
||||
//! Version: 1
|
||||
//! Version: 2
|
||||
use axum::{
|
||||
Json, Router,
|
||||
extract::State,
|
||||
@ -50,14 +50,14 @@ impl Konfiguration {
|
||||
}
|
||||
pub fn pruefen(&self) -> Ergebnis<()> {
|
||||
let url = reqwest::Url::parse(&self.server).map_err(|_| "Serveradresse ungültig")?;
|
||||
let lokal = matches!(url.host_str(), Some("127.0.0.1" | "localhost" | "[::1]"));
|
||||
let lokal = url.host_str().is_some_and(keyforge_protokoll::lan_host);
|
||||
if (url.scheme() != "https" && !(url.scheme() == "http" && lokal))
|
||||
|| !url.username().is_empty()
|
||||
|| url.password().is_some()
|
||||
|| url.query().is_some()
|
||||
|| url.fragment().is_some()
|
||||
{
|
||||
return Err("Server benötigt HTTPS; HTTP nur auf localhost erlaubt".into());
|
||||
return Err("Server benötigt HTTPS; HTTP nur zu privaten LAN-IP-Adressen oder localhost erlaubt".into());
|
||||
}
|
||||
if self.pruefen.adresse.ip() != Ipv4Addr::LOCALHOST
|
||||
|| !keyforge_protokoll::dienst_id_gueltig(&self.dienst_id)
|
||||
|
||||
Reference in New Issue
Block a user