Skip to content
Merged
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 @@ -336,7 +336,7 @@ private boolean validClaims(ClientAssertionClaims claims, AssertionOperation ope
try {
Instant issued = Instant.ofEpochSecond(claims.issuedAt());
Instant expires = Instant.ofEpochSecond(claims.expiresAt());
return !issued.isAfter(now.plus(clockSkew)) && !expires.isBefore(now.minus(clockSkew));
return !issued.isAfter(now.plus(clockSkew)) && expires.isAfter(now.minus(clockSkew));
} catch (RuntimeException exception) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,31 @@ void rejectsReplayedAssertionWithoutDisclosingTheCause() {
assertEquals("not_recognized", second.problem().code());
}

@Test
void rejectsExpirationBoundaryFromCustomVerifier() {
AepService service = AepService.builder(
document(false),
(assertion, context) -> completed(new ClientAssertionClaims(
AGENT_DID,
AGENT_DID,
context.serviceDid(),
context.operation(),
NOW.minusSeconds(60).getEpochSecond(),
NOW.minusSeconds(30).getEpochSecond(),
"expiration-boundary",
null)))
.clock(Clock.fixed(NOW, ZoneOffset.UTC))
.clockSkew(java.time.Duration.ofSeconds(30))
.build();

ServiceResponse<?> response = service.status(CommandOptions.authenticated("assertion"))
.toCompletableFuture()
.join();

assertEquals(401, response.status());
assertEquals("not_recognized", response.problem().code());
}

@Test
void grantsAndRevokesThroughTheAdvertisedHandler() {
RecordingGrantHandler handler = new RecordingGrantHandler();
Expand Down