@@ -125,7 +125,6 @@ where
125125 iss_required : bool ,
126126 issuer : IssuerUrl ,
127127 is_signature_check_enabled : bool ,
128- is_typ_check_enabled : bool ,
129128 other_aud_verifier_fn : Arc < dyn Fn ( & Audience ) -> bool + ' a + Send + Sync > ,
130129 signature_keys : JsonWebKeySet < K > ,
131130}
@@ -147,7 +146,6 @@ where
147146 iss_required : true ,
148147 issuer,
149148 is_signature_check_enabled : true ,
150- is_typ_check_enabled : true ,
151149 // Secure default: reject all other audiences as untrusted, since any other audience
152150 // can potentially impersonate the user when by sending its copy of these claims
153151 // to this relying party.
@@ -171,11 +169,6 @@ where
171169 self
172170 }
173171
174- pub fn require_typ_check ( mut self , typ_check_required : bool ) -> Self {
175- self . is_typ_check_enabled = typ_check_required;
176- self
177- }
178-
179172 pub fn set_allowed_algs < I > ( mut self , algs : I ) -> Self
180173 where
181174 I : IntoIterator < Item = K :: SigningAlgorithm > ,
@@ -202,23 +195,20 @@ where
202195 }
203196
204197 fn validate_jose_header < JE > (
205- & self ,
206198 jose_header : & JsonWebTokenHeader < JE , K :: SigningAlgorithm > ,
207199 ) -> Result < ( ) , ClaimsVerificationError >
208200 where
209201 JE : JweContentEncryptionAlgorithm <
210202 KeyType = <K :: SigningAlgorithm as JwsSigningAlgorithm >:: KeyType ,
211203 > ,
212204 {
213- if self . is_typ_check_enabled {
214- // The 'typ' header field must either be omitted or have the canonicalized value JWT.
215- if let Some ( ref jwt_type) = jose_header. typ {
216- if jwt_type. to_uppercase ( ) != "JWT" {
217- return Err ( ClaimsVerificationError :: Unsupported ( format ! (
218- "unexpected or unsupported JWT type `{}`" ,
219- * * jwt_type
220- ) ) ) ;
221- }
205+ // The 'typ' header field must either be omitted or have the canonicalized value JWT.
206+ if let Some ( ref jwt_type) = jose_header. typ {
207+ if jwt_type. to_uppercase ( ) != "JWT" {
208+ return Err ( ClaimsVerificationError :: Unsupported ( format ! (
209+ "unexpected or unsupported JWT type `{}`" ,
210+ * * jwt_type
211+ ) ) ) ;
222212 }
223213 }
224214 // The 'cty' header field must be omitted, since it's only used for JWTs that contain
@@ -260,7 +250,7 @@ where
260250 {
261251 {
262252 let jose_header = jwt. unverified_header ( ) ;
263- self . validate_jose_header ( jose_header) ?;
253+ Self :: validate_jose_header ( jose_header) ?;
264254
265255 // The code below roughly follows the validation steps described in
266256 // https://openid.net/specs/openid-connect-core-1_0.html#IDTokenValidation
@@ -624,14 +614,6 @@ where
624614 self
625615 }
626616
627- /// Specifies whether the `typ` field in the [JOSE header](
628- /// https://tools.ietf.org/html/rfc7519#section-5) should be validated against supported
629- /// values.
630- pub fn require_typ_check ( mut self , typ_check_required : bool ) -> Self {
631- self . jwt_verifier = self . jwt_verifier . require_typ_check ( typ_check_required) ;
632- self
633- }
634-
635617 /// Specifies whether the issuer claim must match the expected issuer URL for the provider.
636618 pub fn require_issuer_match ( mut self , iss_required : bool ) -> Self {
637619 self . jwt_verifier = self . jwt_verifier . require_issuer_match ( iss_required) ;
0 commit comments