1+ use jsonwebtoken:: TokenData ;
12use jsonwebtoken:: errors:: Error ;
2- use jsonwebtoken:: { DecodingKey , TokenData , Validation } ;
33use serde:: Deserialize ;
4- use std:: collections:: HashSet ;
5- use std:: sync:: LazyLock ;
6-
7- /// [`Validation`] configuration for decoding JWTs without any
8- /// signature validation.
9- ///
10- /// **This must only be used to extract the `iss` claim from the JWT, which
11- /// is then used to look up the corresponding OIDC key set.**
12- static NO_VALIDATION : LazyLock < Validation > = LazyLock :: new ( || {
13- let mut no_validation = Validation :: default ( ) ;
14- no_validation. validate_aud = false ;
15- no_validation. validate_exp = false ;
16- no_validation. required_spec_claims = HashSet :: new ( ) ;
17- no_validation. insecure_disable_signature_validation ( ) ;
18- no_validation
19- } ) ;
20-
21- /// Empty [`DecodingKey`] used for decoding JWTs without any signature
22- /// validation.
23- ///
24- /// **This must only be used to extract the `iss` claim from the JWT, which
25- /// is then used to look up the corresponding OIDC key set.**
26- static EMPTY_KEY : LazyLock < DecodingKey > = LazyLock :: new ( || DecodingKey :: from_secret ( b"" ) ) ;
274
285/// Claims that are extracted from the JWT without any signature
296/// validation. Specifically, this only extracts the `iss` claim, which is
@@ -41,7 +18,7 @@ impl UnverifiedClaims {
4118 /// **This must only be used to extract the `iss` claim from the JWT, which
4219 /// is then used to look up the corresponding OIDC key set.**
4320 pub fn decode ( token : & str ) -> Result < TokenData < Self > , Error > {
44- jsonwebtoken:: decode ( token, & EMPTY_KEY , & NO_VALIDATION )
21+ jsonwebtoken:: dangerous :: insecure_decode ( token)
4522 }
4623}
4724
0 commit comments