Skip to content

Commit

Permalink
TokenVerifier: execute blocking calls in parallel (knative-extensions…
Browse files Browse the repository at this point in the history
…#3728)

* TokenVerifier: execute blocking calls in parallel

* Revert "TokenVerifier: execute blocking calls in parallel"

This reverts commit f3dbde9.

* Revert: removed changes in contract.pb.go
  • Loading branch information
parth721 authored and creydr committed Apr 2, 2024
1 parent 2162121 commit 59a4503
Showing 1 changed file with 16 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,25 @@ public TokenVerifierImpl(Vertx vertx, OIDCDiscoveryConfig oidcDiscoveryConfig) {
}

public Future<JwtClaims> verify(String token, String expectedAudience) {
return this.vertx.<JwtClaims>executeBlocking(promise -> {
// execute blocking, as jose .process() is blocking
return this.vertx.<JwtClaims>executeBlocking(
promise -> {
// execute blocking, as jose .process() is blocking

JwtConsumer jwtConsumer = new JwtConsumerBuilder()
.setVerificationKeyResolver(this.oidcDiscoveryConfig.getJwksVerificationKeyResolver())
.setExpectedAudience(expectedAudience)
.setExpectedIssuer(this.oidcDiscoveryConfig.getIssuer())
.build();
JwtConsumer jwtConsumer = new JwtConsumerBuilder()
.setVerificationKeyResolver(this.oidcDiscoveryConfig.getJwksVerificationKeyResolver())
.setExpectedAudience(expectedAudience)
.setExpectedIssuer(this.oidcDiscoveryConfig.getIssuer())
.build();

try {
JwtContext jwtContext = jwtConsumer.process(token);
try {
JwtContext jwtContext = jwtConsumer.process(token);

promise.complete(jwtContext.getJwtClaims());
} catch (InvalidJwtException e) {
promise.fail(e);
}
});
promise.complete(jwtContext.getJwtClaims());
} catch (InvalidJwtException e) {
promise.fail(e);
}
},
false);
}

public Future<JwtClaims> verify(final HttpServerRequest request, String expectedAudience) {
Expand Down

0 comments on commit 59a4503

Please sign in to comment.