v0.34.15
This commit is contained in:
1 parent
62b7574553
commit
e364392659
47 files changed
+2164
-257
No files matched your search
+15
-6
@@ -54,7 +54,10 @@ pub struct MethodPolicy {
|
||||
}
|
||||
impl MethodPolicy {
|
||||
pub fn validate(&mut self) -> Result<()> {
|
||||
ensure!(self.methods.len() <= 32, "method policy allows at most 32 methods");
|
||||
ensure!(
|
||||
self.methods.len() <= 32,
|
||||
"method policy allows at most 32 methods"
|
||||
);
|
||||
let mut seen = std::collections::HashSet::new();
|
||||
for method in &mut self.methods {
|
||||
*method = method.trim().to_ascii_uppercase();
|
||||
@@ -62,7 +65,10 @@ impl MethodPolicy {
|
||||
!method.is_empty() && method.len() <= 32 && method.parse::<http::Method>().is_ok(),
|
||||
"invalid HTTP method in method policy"
|
||||
);
|
||||
ensure!(seen.insert(method.clone()), "duplicate HTTP method in method policy");
|
||||
ensure!(
|
||||
seen.insert(method.clone()),
|
||||
"duplicate HTTP method in method policy"
|
||||
);
|
||||
}
|
||||
ensure!(
|
||||
self.mode == MethodPolicyMode::Off || !self.methods.is_empty(),
|
||||
@@ -115,9 +121,7 @@ impl ContentTypePolicy {
|
||||
anyhow::bail!("invalid blocked Content-Type: expected type/subtype");
|
||||
};
|
||||
ensure!(
|
||||
mime_token(kind)
|
||||
&& (subtype == "*" || mime_token(subtype))
|
||||
&& value.len() <= 255,
|
||||
mime_token(kind) && (subtype == "*" || mime_token(subtype)) && value.len() <= 255,
|
||||
"invalid blocked Content-Type: use type/subtype or type/* without parameters"
|
||||
);
|
||||
ensure!(
|
||||
@@ -346,6 +350,10 @@ pub struct Vhost {
|
||||
#[serde(default)]
|
||||
pub tinyauth: crate::tinyauth::Settings,
|
||||
#[serde(default)]
|
||||
pub authelia: crate::authelia::Settings,
|
||||
#[serde(default)]
|
||||
pub authentik: crate::authentik::Settings,
|
||||
#[serde(default)]
|
||||
pub certificate_id: Option<String>,
|
||||
#[serde(default)]
|
||||
pub allow_certificate_mismatch: bool,
|
||||
@@ -379,7 +387,8 @@ pub struct Vhost {
|
||||
pub headers: HeaderRules,
|
||||
#[serde(default)]
|
||||
pub security_headers: SecurityHeaders,
|
||||
#[serde(default)] pub user_agent_blocking: crate::user_agent::Policy,
|
||||
#[serde(default)]
|
||||
pub user_agent_blocking: crate::user_agent::Policy,
|
||||
#[serde(default)]
|
||||
pub proxy_timeouts: ProxyTimeouts,
|
||||
#[serde(skip)]
|
||||
|
||||
@@ -242,12 +242,14 @@ impl Vhost {
|
||||
if let Some(server) = &self.server_header {
|
||||
server.validate()?;
|
||||
}
|
||||
self.tinyauth.validate()?;
|
||||
self.basic_auth.compile()?;
|
||||
ensure!(
|
||||
!(self.tinyauth.enabled && self.basic_auth.enabled),
|
||||
"choose either Tinyauth or Basic authentication"
|
||||
);
|
||||
crate::auth_provider::Selection {
|
||||
basic_enabled: self.basic_auth.enabled,
|
||||
tinyauth: &self.tinyauth,
|
||||
authelia: &self.authelia,
|
||||
authentik: &self.authentik,
|
||||
}
|
||||
.validate()?;
|
||||
self.pages.validate()?;
|
||||
self.transform
|
||||
.resolve(&crate::transform::Settings::default())?;
|
||||
|
||||
Reference in new issue
Block a user