-
fix(auth): match the Bearer scheme case-insensitively (RFC 6750) (#929)
发布于
2026-06-03 09:07:34 +00:00 require_bearerparsed the Authorization header with
strip_prefix("Bearer "), which is case-sensitive. Per RFC 6750 §2.1 /
RFC 7235 §2.1 the auth-scheme is case-insensitive, so a correct token sent
asAuthorization: bearer <token>(orBEARER, or with extra whitespace)
was rejected with a confusing "invalid bearer token" 401 — needless friction
when setting upRUVIEW_API_TOKEN(the active #864/#924 theme).Now the scheme is matched with
eq_ignore_ascii_caseand leading token
whitespace trimmed. The token comparison itself is unchanged — still exact
and constant-time (ct_eq) — so this does not weaken auth: a wrong token or
a non-Bearer scheme (Basic …) still returns 401.New test
accepts_case_insensitive_bearer_schemecoversbearer/BEARER/
extra-space (accept) and wrong-token/Basic(still reject). bearer_auth
suite: 9 passed.下载附件