File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -63,8 +63,12 @@ impl BasicAuth {
6363 "Expected basic auth scheme found `{}`" ,
6464 scheme
6565 ) ;
66+ Self :: from_credentials ( auth. credentials ( ) ) . map ( Some )
67+ }
6668
67- let bytes = base64:: decode ( auth. credentials ( ) ) . status ( 400 ) ?;
69+ /// Create a new instance from the base64 encoded credentials.
70+ pub fn from_credentials ( credentials : impl AsRef < [ u8 ] > ) -> crate :: Result < Self > {
71+ let bytes = base64:: decode ( credentials) . status ( 400 ) ?;
6872 let credentials = String :: from_utf8 ( bytes) . status ( 400 ) ?;
6973
7074 let mut iter = credentials. splitn ( 2 , ':' ) ;
@@ -77,7 +81,7 @@ impl BasicAuth {
7781 ( None , _) => bail ! ( 400 , "Expected basic auth to contain a username" ) ,
7882 } ;
7983
80- Ok ( Some ( Self { username, password } ) )
84+ Ok ( Self { username, password } )
8185 }
8286
8387 /// Sets the header.
You can’t perform that action at this time.
0 commit comments