Skip to content

Commit 4daf089

Browse files
committed
Merge remote-tracking branch 'origin/6.5.x'
2 parents 3a84894 + 6501e97 commit 4daf089

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

oauth2/oauth2-jose/src/main/java/org/springframework/security/oauth2/jwt/JwtTypeValidator.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff 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,

oauth2/oauth2-jose/src/test/java/org/springframework/security/oauth2/jwt/JwtTypeValidatorTests.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)