File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed
main/java/org/springframework/security/oauth2/jwt
test/java/org/springframework/security/oauth2/jwt Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -72,8 +72,10 @@ public OAuth2TokenValidatorResult validate(Jwt token) {
7272 if (this .allowEmpty && !StringUtils .hasText (typ )) {
7373 return OAuth2TokenValidatorResult .success ();
7474 }
75- if (this .validTypes .contains (typ )) {
76- return OAuth2TokenValidatorResult .success ();
75+ for (String validType : this .validTypes ) {
76+ if (validType .equalsIgnoreCase (typ )) {
77+ return OAuth2TokenValidatorResult .success ();
78+ }
7779 }
7880 return OAuth2TokenValidatorResult .failure (new OAuth2Error (OAuth2ErrorCodes .INVALID_TOKEN ,
7981 "the given typ value needs to be one of " + this .validTypes ,
Original file line number Diff line number Diff line change @@ -44,4 +44,12 @@ void constructorWhenCustomThenEnforces() {
4444 assertThat (validator .validate (jwt .build ()).hasErrors ()).isFalse ();
4545 }
4646
47+ @ Test
48+ void validateWhenTypHeaderHasDifferentCaseThenSuccess () {
49+ Jwt .Builder jwt = TestJwts .jwt ();
50+ JwtTypeValidator validator = new JwtTypeValidator ("at+jwt" );
51+ jwt .header (JoseHeaderNames .TYP , "AT+JWT" );
52+ assertThat (validator .validate (jwt .build ()).hasErrors ()).isFalse ();
53+ }
54+
4755}
You can’t perform that action at this time.
0 commit comments