Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/common/authorization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@ impl Authorization<Basic> {

Authorization(Basic { decoded, colon_pos })
}

/// View the decoded username.
pub fn username(&self) -> &str {
self.0.username()
}

/// View the decoded password.
pub fn password(&self) -> &str {
self.0.password()
}
}

impl Authorization<Bearer> {
Expand All @@ -54,6 +64,11 @@ impl Authorization<Bearer> {
.map(|val| Authorization(Bearer(val)))
.ok_or_else(|| InvalidBearerToken { _inner: () })
}

/// View the token part as a `&str`.
pub fn token(&self) -> &str {
self.0.token()
}
}

impl<C: Credentials> ::Header for Authorization<C> {
Expand Down