[core] Device certificates: device_certs host field; edge config v3 and Caddy client_authentication with a CA bundle and an allow list, 403 without a certificate
This commit is contained in:
@@ -4,10 +4,10 @@
|
||||
|
||||
//! Model → [`EdgeConfig`] for the Pingora data plane.
|
||||
|
||||
use super::{CompileOptions, join, strip_headers};
|
||||
use super::{CompileOptions, DEVICE_ALLOW_FILE, DEVICE_CA_FILE, join, strip_headers};
|
||||
use crate::edge_config::{
|
||||
EDGE_CONFIG_VERSION, EdgeAcme, EdgeConfig, EdgeForwardAuth, EdgeHeaderOp, EdgeHealthCheck,
|
||||
EdgeHost, EdgeTls, EdgeUpstream, EdgeValue,
|
||||
EDGE_CONFIG_VERSION, EdgeAcme, EdgeConfig, EdgeDeviceCerts, EdgeForwardAuth, EdgeHeaderOp,
|
||||
EdgeHealthCheck, EdgeHost, EdgeTls, EdgeUpstream, EdgeValue,
|
||||
};
|
||||
use crate::{AccessLog, AuthMode, HeaderRule, HeaderValue, Model, Scheme, TlsMode, Upstream};
|
||||
|
||||
@@ -26,6 +26,14 @@ pub(super) fn compile(model: &Model, o: &CompileOptions) -> EdgeConfig {
|
||||
directory: site.acme.directory.clone(),
|
||||
email: site.acme.email.clone(),
|
||||
}),
|
||||
device_certs: model
|
||||
.hosts()
|
||||
.iter()
|
||||
.any(|h| h.device_certs)
|
||||
.then(|| EdgeDeviceCerts {
|
||||
ca: join(&o.cert_dir, DEVICE_CA_FILE),
|
||||
allow: join(&o.cert_dir, DEVICE_ALLOW_FILE),
|
||||
}),
|
||||
forward_auth: site.forward_auth.as_ref().map(|fa| EdgeForwardAuth {
|
||||
upstream: upstream(&fa.upstream),
|
||||
path_and_query: fa.path_and_query.clone(),
|
||||
@@ -55,6 +63,7 @@ pub(super) fn compile(model: &Model, o: &CompileOptions) -> EdgeConfig {
|
||||
}),
|
||||
access_log: h.access_log == AccessLog::Truncated,
|
||||
share_links: h.share_links,
|
||||
device_certs: h.device_certs,
|
||||
})
|
||||
.collect(),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user