forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show how to handle multiple OIDC token audiences
- Loading branch information
1 parent
f7b8d69
commit a8ad8d9
Showing
4 changed files
with
79 additions
and
3 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
...wiremock/src/main/java/io/quarkus/it/keycloak/CodeFlowVerifyIdAndAccessTokenResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package io.quarkus.it.keycloak; | ||
|
||
import jakarta.inject.Inject; | ||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.Path; | ||
|
||
import org.eclipse.microprofile.jwt.JsonWebToken; | ||
|
||
import io.quarkus.oidc.IdToken; | ||
import io.quarkus.oidc.runtime.DefaultTokenIntrospectionUserInfoCache; | ||
import io.quarkus.security.Authenticated; | ||
import io.vertx.ext.web.RoutingContext; | ||
|
||
@Path("/code-flow-verify-id-and-access-tokens") | ||
public class CodeFlowVerifyIdAndAccessTokenResource { | ||
|
||
@Inject | ||
@IdToken | ||
JsonWebToken idToken; | ||
|
||
@Inject | ||
JsonWebToken accessToken; | ||
|
||
@Inject | ||
RoutingContext routingContext; | ||
|
||
@Inject | ||
DefaultTokenIntrospectionUserInfoCache tokenCache; | ||
|
||
@GET | ||
@Authenticated | ||
public String access() { | ||
return "access token verified: " + (routingContext.get("code_flow_access_token_result") != null) | ||
+ ", id_token issuer: " + idToken.getIssuer() | ||
+ ", access_token issuer: " + accessToken.getIssuer() | ||
+ ", id_token audience: " + idToken.getAudience().iterator().next() | ||
+ ", access_token audience: " + accessToken.getAudience().iterator().next() | ||
+ ", cache size: " + tokenCache.getCacheSize(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters