From 7a6814efba3b01795ffd00f6e2adca2726205dd3 Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Mon, 24 Jan 2022 13:18:44 +0100 Subject: [PATCH] Add forwarding methods to Authorization for provided C's --- src/common/authorization.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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 {