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

Set OIDC Client ID in Thread AccesTokenAuthenticator #30626

Merged
Merged
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
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2016, 2022 IBM Corporation and others.
* Copyright (c) 2016, 2025 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
Expand Down Expand Up @@ -70,6 +70,7 @@ public class AccessTokenAuthenticator {
private static final String JWT_SEGMENTS = "-segments";
private static final String JWT_SEGMENT_INDEX = "-";
private static final String BEARER_SCHEME = "Bearer ";
public static ThreadLocal<String> threadClientID = new ThreadLocal<String>();

OidcClientUtil oidcClientUtil = new OidcClientUtil();
SSLSupport sslSupport = null;
Expand Down Expand Up @@ -105,6 +106,9 @@ public ProviderAuthenticationResult authenticate(HttpServletRequest req,
oidcClientRequest.setTokenType(OidcClientRequest.TYPE_ACCESS_TOKEN);
ProviderAuthenticationResult oidcResult = new ProviderAuthenticationResult(AuthResult.FAILURE, HttpServletResponse.SC_UNAUTHORIZED);
String accessToken = null;

setThreadClientId(clientConfig.getClientId());

if (clientConfig.getAccessTokenInLtpaCookie()) {
accessToken = getAccessTokenFromReqAsAttribute(req, true);
}
Expand Down Expand Up @@ -1104,4 +1108,11 @@ void logError(OidcClientConfig oidcClientConfig, boolean warningWhenSupported, O
}
}
}
private void setThreadClientId(String clientID) {
threadClientID.set(clientID);
}

public static String getThreadClientId() {
return threadClientID.get();
}
}