diff --git a/src/common/authorization.rs b/src/common/authorization.rs index 6442a5fd..dbef1530 100644 --- a/src/common/authorization.rs +++ b/src/common/authorization.rs @@ -45,6 +45,16 @@ impl Authorization { 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 { @@ -54,6 +64,11 @@ impl Authorization { .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 ::Header for Authorization {