Skip to content

Commit

Permalink
Merge pull request #36459 from sberyozkin/oidc_token_propagation_clie…
Browse files Browse the repository at this point in the history
…nt_name

Let custom OIDC token propagation filters provide client name
  • Loading branch information
sberyozkin authored Oct 13, 2023
2 parents b3a623a + 283389b commit 9483701
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ public AccessTokenRequestReactiveFilter() {
public void initExchangeTokenClient() {
if (exchangeToken) {
OidcClients clients = Arc.container().instance(OidcClients.class).get();
exchangeTokenClient = oidcClientName.isPresent() ? clients.getClient(oidcClientName.get()) : clients.getClient();
String clientName = getClientName();
exchangeTokenClient = clientName != null ? clients.getClient(clientName) : clients.getClient();
Grant.Type exchangeTokenGrantType = ConfigProvider.getConfig()
.getValue(
"quarkus.oidc-client." + (oidcClientName.isPresent() ? oidcClientName.get() + "." : "")
Expand Down Expand Up @@ -113,6 +114,10 @@ public void accept(Throwable t) {
}
}

protected String getClientName() {
return oidcClientName.orElse(null);
}

public void propagateToken(ResteasyReactiveClientRequestContext requestContext, String accessToken) {
if (accessToken != null) {
requestContext.getHeaders().add(HttpHeaders.AUTHORIZATION, BEARER_SCHEME_WITH_SPACE + accessToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ public AccessTokenRequestFilter() {
public void initExchangeTokenClient() {
if (exchangeToken) {
OidcClients clients = Arc.container().instance(OidcClients.class).get();
exchangeTokenClient = oidcClientName.isPresent() ? clients.getClient(oidcClientName.get()) : clients.getClient();
String clientName = getClientName();
exchangeTokenClient = clientName != null ? clients.getClient(clientName) : clients.getClient();
Grant.Type exchangeTokenGrantType = ConfigProvider.getConfig()
.getValue(
"quarkus.oidc-client." + (oidcClientName.isPresent() ? oidcClientName.get() + "." : "")
Expand Down Expand Up @@ -92,6 +93,10 @@ private String exchangeTokenIfNeeded(String token) {
}
}

protected String getClientName() {
return oidcClientName.orElse(null);
}

private boolean acquireTokenCredentialFromCtx(ClientRequestContext requestContext) {
if (enabledDuringAuthentication) {
TokenCredential tokenCredential = getTokenCredentialFromContext();
Expand Down

0 comments on commit 9483701

Please sign in to comment.