Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Let custom OIDC token propagation filters provide client name #36459

Merged
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 @@ -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