Skip to content

Commit 5748ce4

Browse files
committed
case insensitive auth schema parsing
1 parent 5dada95 commit 5748ce4

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

src/auth/authentication_scheme.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,19 @@ impl FromStr for AuthenticationScheme {
5050
type Err = crate::Error;
5151

5252
fn from_str(s: &str) -> Result<Self, Self::Err> {
53-
match s {
54-
"Basic" => Ok(Self::Basic),
55-
"Bearer" => Ok(Self::Bearer),
56-
"Digest" => Ok(Self::Digest),
57-
"HOBA" => Ok(Self::Hoba),
58-
"Mutual" => Ok(Self::Mutual),
59-
"Negotiate" => Ok(Self::Negotiate),
60-
"OAuth" => Ok(Self::OAuth),
61-
"SCRAM-SHA-1" => Ok(Self::ScramSha1),
62-
"SCRAM-SHA-256" => Ok(Self::ScramSha256),
53+
// NOTE(yosh): matching here is lowercase as specified by RFC2617#section-1.2
54+
// > [...] case-insensitive token to identify the authentication scheme [...]
55+
// https://tools.ietf.org/html/rfc2617#section-1.2
56+
match s.to_lowercase().as_str() {
57+
"basic" => Ok(Self::Basic),
58+
"bearer" => Ok(Self::Bearer),
59+
"digest" => Ok(Self::Digest),
60+
"hoba" => Ok(Self::Hoba),
61+
"mutual" => Ok(Self::Mutual),
62+
"negotiate" => Ok(Self::Negotiate),
63+
"oauth" => Ok(Self::OAuth),
64+
"scram-sha-1" => Ok(Self::ScramSha1),
65+
"scram-sha-256" => Ok(Self::ScramSha256),
6366
"vapid" => Ok(Self::Vapid),
6467
s => bail!("`{}` is not a recognized authentication scheme", s),
6568
}

0 commit comments

Comments
 (0)