mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-11-10 19:48:50 +00:00
Merge remote-tracking branch 'origin/6.5.x'
This commit is contained in:
commit
4daf089e46
@ -72,8 +72,10 @@ public final class JwtTypeValidator implements OAuth2TokenValidator<Jwt> {
|
||||
if (this.allowEmpty && !StringUtils.hasText(typ)) {
|
||||
return OAuth2TokenValidatorResult.success();
|
||||
}
|
||||
if (this.validTypes.contains(typ)) {
|
||||
return OAuth2TokenValidatorResult.success();
|
||||
for (String validType : this.validTypes) {
|
||||
if (validType.equalsIgnoreCase(typ)) {
|
||||
return OAuth2TokenValidatorResult.success();
|
||||
}
|
||||
}
|
||||
return OAuth2TokenValidatorResult.failure(new OAuth2Error(OAuth2ErrorCodes.INVALID_TOKEN,
|
||||
"the given typ value needs to be one of " + this.validTypes,
|
||||
|
||||
@ -44,4 +44,12 @@ class JwtTypeValidatorTests {
|
||||
assertThat(validator.validate(jwt.build()).hasErrors()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
void validateWhenTypHeaderHasDifferentCaseThenSuccess() {
|
||||
Jwt.Builder jwt = TestJwts.jwt();
|
||||
JwtTypeValidator validator = new JwtTypeValidator("at+jwt");
|
||||
jwt.header(JoseHeaderNames.TYP, "AT+JWT");
|
||||
assertThat(validator.validate(jwt.build()).hasErrors()).isFalse();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user