Skip to content

Commit 175ef28

Browse files
authored
fix(auth): UserInfo accepts more than one space after Bearer (#591)
UserInfo refused `Authorization: Bearer <token>` with two spaces, though RFC 9110 §11.4 (and RFC 6750 §2.1) let one or more spaces separate a scheme from its credentials. Both SDKs already accept it. `AuthScheme::credentials` now drops every space after the scheme, so both of its callers accept them: UserInfo's `Bearer`, and the token endpoint's `Basic` client authentication. The scheme name is still case-insensitive, and the credentials are otherwise untouched. Closes #558 > [!NOTE] > Written by Claude Opus 5.5 in Claude Code and reviewed by Claude Opus 5.5 (via T3 Code)
1 parent 348186e commit 175ef28

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

‎apps/auth-service/src/oidc/mod.rs‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,13 @@ sourceorigin_common::str_enum! {
105105

106106
impl AuthScheme {
107107
/// Returns the credentials of an `Authorization` value using this scheme.
108-
/// Scheme names are case-insensitive (RFC 9110); credentials are untouched.
108+
/// Scheme names are case-insensitive, and one or more spaces separate them
109+
/// from the credentials (RFC 9110 §11.4); credentials are otherwise untouched.
109110
fn credentials(self, value: &str) -> Option<&str> {
110111
let (scheme, credentials) = value.split_once(' ')?;
111112
scheme
112113
.eq_ignore_ascii_case(self.as_str())
113-
.then_some(credentials)
114+
.then(|| credentials.trim_start_matches(' '))
114115
}
115116
}
116117

‎apps/auth-service/src/oidc/tests/protocol.rs‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,13 @@ fn authentication_schemes_are_case_insensitive() {
162162
assert_eq!(AuthScheme::Bearer.credentials("Bearer"), None);
163163
}
164164

165+
/// Checks that credentials may follow the scheme after more than one space (RFC 9110 §11.4).
166+
#[test]
167+
fn authentication_schemes_allow_several_spaces() {
168+
assert_eq!(AuthScheme::Bearer.credentials("Bearer a.B"), Some("a.B"));
169+
assert_eq!(AuthScheme::Basic.credentials("Basic Zm9v"), Some("Zm9v"));
170+
}
171+
165172
/// Checks deduplication, lexical ordering and preservation of registered extension scopes.
166173
#[test]
167174
fn scope_sets_preserve_existing_wire_semantics() {

0 commit comments

Comments
 (0)