-
Notifications
You must be signed in to change notification settings - Fork 967
Expose Athenz TokenClient as public API #6460
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
base: main
Are you sure you want to change the base?
Conversation
| import com.linecorp.armeria.common.util.Exceptions; | ||
|
|
||
| final class AccessTokenClient implements TokenClient { | ||
| public final class AccessTokenClient implements TokenClient { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding the public keyword doesn’t necessarily mean the user can use it right away.
TokenClientclient is still in private.- There are no public constructors or builder methods to create
AccessTokenClientor `RoleTokenClient.
Suggestion:
- Should we only make
TokenClientpublic class? Let's keepAccessTokenClientandRoleTokenClientpackage-private. Overrideasmethod to obtain an instance ofTokenClientinAthenzClient?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realized that overriding as is not a feasible solution as AthenzClient.newDecorator() returns a function. Instead, let's add a factory method TokenClient.
public interface TokenClient {
TokenClient of(....) {
if (tokenType.isRoleToken()) {
return new RoleTokenClient(ztsBaseClient, domainName, roleNames, refreshBefore);
} else {
return new AccessTokenClient(ztsBaseClient, domainName, roleNames, refreshBefore);
}
}
Motivation:
AccessTokenClient and RoleTokenClient are currently declared as package-private, preventing users of the Armeria library from directly instantiating or using these classes.
As wrote in #6431, some users may want to obtain only the Athenz token for use with non-Armeria clients.
This PR provides flexibility by exposing these classes as public API, allowing users to fetch tokens directly.
Modifications:
armeria/athenz/src/main/java/com/linecorp/armeria/client/athenz/AccessTokenClient.javaChanged final class AccessTokenClient to public final class AccessTokenClient.
armeria/athenz/src/main/java/com/linecorp/armeria/client/athenz/RoleTokenClient.javaChanged final class RoleTokenClient to public final class RoleTokenClient.
Result:
Closes #6431
After this PR is merged, users will be able to directly import and instantiate
com.linecorp.armeria.client.athenz.AccessTokenClientandcom.linecorp.armeria.client.athenz.RoleTokenClient.