[edge] Fixes: skip 1xx, enforce auth timeout, resolve upstreams per connect, all Upgrade tokens, strip Remote-*

This commit is contained in:
2026-11-07 15:48:18 +01:00
parent 60aee5d78a
commit a272e476b7
10 changed files with 509 additions and 115 deletions
+34 -8
View File
@@ -266,7 +266,10 @@ async fn misbehaving_auth_answers_fail_closed() {
site: &site,
hosts: vec![host_file(
"auth.test",
&format!("upstreams = [\"{}\"]\nauth = \"forward-auth\"\n", echo.url()),
&format!(
"upstreams = [\"{}\"]\nauth = \"forward-auth\"\n",
echo.url()
),
)],
..Default::default()
});
@@ -275,15 +278,26 @@ async fn misbehaving_auth_answers_fail_closed() {
let addr = edge.https;
async move {
let cookie = format!("authelia_session={session}");
client::https(addr, "auth.test", roots, &Req::get("auth.test", "/").header("cookie", &cookie)).await
client::https(
addr,
"auth.test",
roots,
&Req::get("auth.test", "/").header("cookie", &cookie),
)
.await
}
};
// 100 Continue before the real answer is skipped, like any HTTP client does.
let r = go("continue-ok").await.expect("edge answers after a 1xx from the auth server");
let r = go("continue-ok")
.await
.expect("edge answers after a 1xx from the auth server");
assert_eq!(r.status, 200);
assert_eq!(echo.proxied().len(), 1);
assert_eq!(echo.proxied()[0].header("remote-user"), Some(b"alice".as_slice()));
assert_eq!(
echo.proxied()[0].header("remote-user"),
Some(b"alice".as_slice())
);
echo.clear();
// 101 is a final answer but not an allow: denied with 502.
@@ -296,9 +310,15 @@ async fn misbehaving_auth_answers_fail_closed() {
// An auth server that never answers: 502 once the 10 s auth timeout passes.
let t = std::time::Instant::now();
let r = go("hang").await.expect("edge answers a hanging auth server");
let r = go("hang")
.await
.expect("edge answers a hanging auth server");
assert_eq!(r.status, 502);
assert!(t.elapsed() < std::time::Duration::from_secs(14), "took {:?}", t.elapsed());
assert!(
t.elapsed() < std::time::Duration::from_secs(14),
"took {:?}",
t.elapsed()
);
assert!(echo.proxied().is_empty());
// Still serving afterwards.
@@ -313,12 +333,18 @@ async fn remote_headers_are_stripped_even_with_a_custom_copy_list() {
let echo = Echo::start("app").await;
for copy in ["[]", "[\"Remote-User\"]"] {
echo.clear();
let site = format!("[forward_auth]\nurl = \"{}\"\ncopy_headers = {copy}\n", authelia.url());
let site = format!(
"[forward_auth]\nurl = \"{}\"\ncopy_headers = {copy}\n",
authelia.url()
);
let edge = start(EdgeSpec {
site: &site,
hosts: vec![host_file(
"auth.test",
&format!("upstreams = [\"{}\"]\nauth = \"forward-auth\"\n", echo.url()),
&format!(
"upstreams = [\"{}\"]\nauth = \"forward-auth\"\n",
echo.url()
),
)],
..Default::default()
});