Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,11 @@ TokenPolicy uaaTokenPolicy(
bean.setMaxSessionLimit(TokenPolicy.parseRefreshTokenUnique(refreshTokenUniqueStr));

bean.setRefreshTokenRotate(refreshTokenRotate);

if (refreshTokenRotate && "jwt".equalsIgnoreCase(refreshTokenFormat) && !jwtRevocable) {
throw new IllegalArgumentException("A token policy cannot have JWT-format refresh tokens with rotation enabled unless they are also revocable.");
}

return bean;
Comment on lines 699 to 705
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ public IdentityZoneConfiguration validate(IdentityZone zone, IdentityZoneValidat

TokenPolicy tokenPolicy = config.getTokenPolicy();
if (tokenPolicy != null) {
if (tokenPolicy.isRefreshTokenRotate() &&
"jwt".equalsIgnoreCase(tokenPolicy.getRefreshTokenFormat()) &&
!tokenPolicy.isJwtRevocable()) {
throw new InvalidIdentityZoneConfigurationException("A token policy cannot have JWT-format refresh tokens with rotation enabled unless they are also revocable.");
}
Comment on lines +52 to +56
String activeKeyId = tokenPolicy.getActiveKeyId();
if (StringUtils.hasText(activeKeyId)) {
Map<String, TokenPolicy.KeyInformation> jwtKeys = tokenPolicy.getKeys();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,36 @@ void validate_without_legacy_key_and_null_active_key(IdentityZoneValidator.Mode
.hasMessageContaining("Invalid SAML active key ID: 'null'. Couldn't find any matching keys.");
}

@ParameterizedTest
@MethodSource("parameters")
void validate_refreshTokenRotate_with_jwt_and_not_revocable(IdentityZoneValidator.Mode mode) {
IdentityZone testZone = new IdentityZone();
testZone.setId(IdentityZone.getUaaZoneId());
TokenPolicy tokenPolicy = new TokenPolicy();
tokenPolicy.setRefreshTokenRotate(true);
tokenPolicy.setRefreshTokenFormat("jwt");
tokenPolicy.setJwtRevocable(false);
testZone.getConfig().setTokenPolicy(tokenPolicy);

assertThatThrownBy(() -> validator.validate(testZone, mode))
.isInstanceOf(InvalidIdentityZoneConfigurationException.class)
.hasMessage("A token policy cannot have JWT-format refresh tokens with rotation enabled unless they are also revocable.");
}

@ParameterizedTest
@MethodSource("parameters")
void validate_refreshTokenRotate_with_jwt_and_revocable(IdentityZoneValidator.Mode mode) throws Exception {
IdentityZone testZone = new IdentityZone();
testZone.setId(IdentityZone.getUaaZoneId());
TokenPolicy tokenPolicy = new TokenPolicy();
tokenPolicy.setRefreshTokenRotate(true);
tokenPolicy.setRefreshTokenFormat("jwt");
tokenPolicy.setJwtRevocable(true);
testZone.getConfig().setTokenPolicy(tokenPolicy);

validator.validate(testZone, mode);
}

@MethodSource("parameters")
@ParameterizedTest
void validate_no_keys(IdentityZoneValidator.Mode mode) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ void ensureJKUHeaderIsSetWhenBuildingARefreshToken() {
@Nested
@DisplayName("when performing the refresh grant type")
@DefaultTestContext
@TestPropertySource(properties = {"uaa.url=https://uaa.some.test.domain.com:555/uaa", "jwt.token.refresh.rotate=true"})
@TestPropertySource(properties = {"uaa.url=https://uaa.some.test.domain.com:555/uaa", "jwt.token.refresh.rotate=true", "jwt.token.revocable=true"})
@DirtiesContext
class WhenRefreshGrant {
@Autowired
Expand Down
Loading