File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -36,23 +36,22 @@ pub(crate) struct Claims {
3636
3737const BEARER_PREFIX : & str = "Bearer " ;
3838
39- fn parse_public_key_pem ( pem : & str ) -> Result < PKey < Public > , String > {
39+ fn parse_public_key_pem ( pem : & str ) -> Result < PKey < Public > , ( ) > {
4040 let body = pem
4141 . trim ( )
4242 . strip_prefix ( "-----BEGIN PUBLIC KEY-----" )
43- . ok_or ( String :: from ( "Prefix not found" ) ) ?
43+ . ok_or ( ( ) ) ?
4444 . strip_suffix ( "-----END PUBLIC KEY-----" )
45- . ok_or ( String :: from ( "Suffix not found" ) ) ?;
45+ . ok_or ( ( ) ) ?;
4646 let body: String = body. lines ( ) . map ( |line| line. trim ( ) ) . collect ( ) ;
47- let body = STANDARD . decode ( body) . map_err ( |_| String :: from ( "Base64 decode failed" ) ) ?;
48- PKey :: public_key_from_der ( & body) . map_err ( |_| String :: from ( "DER decode failed" ) )
47+ let body = STANDARD . decode ( body) . map_err ( |_| ( ) ) ?;
48+ PKey :: public_key_from_der ( & body) . map_err ( |_| ( ) )
4949}
5050
5151impl JWTAuthorizer {
5252 /// Creates a new instance of [`JWTAuthorizer`], fails on failure to parse the PEM formatted RSA public key
53- pub async fn new ( rsa_pem : & str ) -> Result < Self , String > {
54- let jwt_issuer_key = parse_public_key_pem ( rsa_pem)
55- . map_err ( |e| format ! ( "Failed to parse the PEM formatted RSA public key: {}" , e) ) ?;
53+ pub async fn new ( rsa_pem : & str ) -> Result < Self , ( ) > {
54+ let jwt_issuer_key = parse_public_key_pem ( rsa_pem) ?;
5655 Ok ( Self { jwt_issuer_key } )
5756 }
5857}
Original file line number Diff line number Diff line change @@ -86,8 +86,8 @@ fn main() {
8686 info ! ( "Configured JWT authorizer with RSA public key" ) ;
8787 Some ( Arc :: new ( auth) )
8888 } ,
89- Err ( e ) => {
90- error ! ( "Failed to configure JWT authorizer: {}" , e ) ;
89+ Err ( ( ) ) => {
90+ error ! ( "Failed to configure JWT authorizer" ) ;
9191 std:: process:: exit ( -1 ) ;
9292 } ,
9393 } ;
You can’t perform that action at this time.
0 commit comments