File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change 1+ use std:: fmt:: { Debug , Formatter } ;
2+
13use base64:: { engine:: general_purpose:: STANDARD , Engine } ;
24use serde:: de:: DeserializeOwned ;
35
@@ -69,9 +71,22 @@ pub(crate) enum DecodingKeyKind {
6971 RsaModulusExponent { n : Vec < u8 > , e : Vec < u8 > } ,
7072}
7173
74+ impl Debug for DecodingKeyKind {
75+ fn fmt ( & self , f : & mut Formatter < ' _ > ) -> std:: fmt:: Result {
76+ match self {
77+ Self :: SecretOrDer ( _) => f. debug_tuple ( "SecretOrDer" ) . field ( & "[redacted]" ) . finish ( ) ,
78+ Self :: RsaModulusExponent { .. } => f
79+ . debug_struct ( "RsaModulusExponent" )
80+ . field ( "n" , & "[redacted]" )
81+ . field ( "e" , & "[redacted]" )
82+ . finish ( ) ,
83+ }
84+ }
85+ }
86+
7287/// All the different kind of keys we can use to decode a JWT.
7388/// This key can be re-used so make sure you only initialize it once if you can for better performance.
74- #[ derive( Clone ) ]
89+ #[ derive( Clone , Debug ) ]
7590pub struct DecodingKey {
7691 pub ( crate ) family : AlgorithmFamily ,
7792 pub ( crate ) kind : DecodingKeyKind ,
Original file line number Diff line number Diff line change 1+ use std:: fmt:: { Debug , Formatter } ;
2+
13use base64:: { engine:: general_purpose:: STANDARD , Engine } ;
24use serde:: ser:: Serialize ;
35
@@ -124,6 +126,15 @@ impl EncodingKey {
124126 }
125127}
126128
129+ impl Debug for EncodingKey {
130+ fn fmt ( & self , f : & mut Formatter < ' _ > ) -> std:: fmt:: Result {
131+ f. debug_struct ( "EncodingKey" )
132+ . field ( "family" , & self . family )
133+ . field ( "content" , & "[redacted]" )
134+ . finish ( )
135+ }
136+ }
137+
127138/// Encode the header and claims given and sign the payload using the algorithm from the header and the key.
128139/// If the algorithm given is RSA or EC, the key needs to be in the PEM format.
129140///
You can’t perform that action at this time.
0 commit comments