diff --git a/Cargo.lock b/Cargo.lock index ee743f9..222d8cb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -358,9 +358,9 @@ checksum = "1c66915cc5391097de7a2b0b972e8505aa33c0df401fd3a6811dbdb32881ba48" [[package]] name = "form_urlencoded" -version = "1.2.2" +version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf" +checksum = "afa489199eaffb1211795df1c6236ce1ad0d41a6fa45250add73e3b02420f06e" dependencies = [ "percent-encoding", ] @@ -1768,9 +1768,9 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" -version = "2.5.8" +version = "2.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff67a8a4397373c3ef660812acab3268222035010ab8680ec4215f38ba3d0eed" +checksum = "f00cd2407bb42c0ef17be88d4cf020f5cceffd121665bac9b8b9493a369b3b1a" dependencies = [ "form_urlencoded", "idna", diff --git a/crates/auth-rs/src/http/auth.rs b/crates/auth-rs/src/http/auth.rs index ced789f..0adb516 100644 --- a/crates/auth-rs/src/http/auth.rs +++ b/crates/auth-rs/src/http/auth.rs @@ -590,6 +590,22 @@ mod tests { .await .unwrap(); assert_eq!(resp.status(), StatusCode::UNAUTHORIZED); + + // Nor is a Cookie header that is not text (a byte outside visible + // ASCII): it is skipped, not an error. + let (app, _) = with_session(SessionKind::ApiKey); + let unreadable = axum::http::HeaderValue::from_bytes(b"test_session=\xff").unwrap(); + let resp = app + .oneshot( + HttpRequest::builder() + .uri("/protected") + .header("cookie", unreadable) + .body(Body::empty()) + .unwrap(), + ) + .await + .unwrap(); + assert_eq!(resp.status(), StatusCode::UNAUTHORIZED); } // A key in a header wins over a cookie the browser happens to hold. diff --git a/crates/auth-rs/src/ldap_directory.rs b/crates/auth-rs/src/ldap_directory.rs index b8f779d..205f706 100644 --- a/crates/auth-rs/src/ldap_directory.rs +++ b/crates/auth-rs/src/ldap_directory.rs @@ -82,10 +82,13 @@ async fn authenticate(request: DirectoryLogin<'_>) -> Result 1 { let matches = entries.len(); - tracing::warn!( - matches, - "LDAP user filter matched more than one entry; refusing the login" - ); + // The message is a const so the call fits one line: tracing's + // `log` fallback (on through axum) repeats it in a branch that + // never runs while a subscriber is set, and on a line of its own + // it is a line no test reaches. + const MESSAGE: &str = + "LDAP user filter matched more than one entry; refusing the login"; + tracing::warn!(matches, "{MESSAGE}"); } return Err(DirectoryError::InvalidCredentials); }; diff --git a/crates/auth-rs/src/login.rs b/crates/auth-rs/src/login.rs index 210ac88..ca00e03 100644 --- a/crates/auth-rs/src/login.rs +++ b/crates/auth-rs/src/login.rs @@ -184,11 +184,9 @@ pub async fn ldap_login( let grant = R::grant_for(&config.access, username, &user.member_of).ok_or_else(|| { let groups = user.member_of.len(); - tracing::warn!( - username, - groups, - "LDAP login refused: no access rule names this user or their groups" - ); + // A const so the call fits one line (see ldap_directory.rs). + const MESSAGE: &str = "LDAP login refused: no access rule names this user or their groups"; + tracing::warn!(username, groups, "{MESSAGE}"); LoginError::NotAuthorized })?;