[JWT] Enable configurable early token refresh in Java Client
- Dominant language
- Java
- Stars
- 15.3k
- Forks
- 3.8k
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 160
Description
### Search before asking
- [X] I searched in the [issues](https://github.com/apache/pulsar/issues) and found nothing similar.
### Motivation
Same as this https://github.com/apache/pulsar/pull/13951 - but to support the "simpler" JWT auth workflow/client setup.
### Solution
Similar to `AuthenticationOAuth2` - firstly `AuthenticationToken` will need to cache the authenticating JWT in a `transient volatile` field.
This value will also be injected into `AuthenticationDataToken` - and `getCommandData` will now return this value - and not lazily generate a new token.
Meanwhile, a scheduled task will be created, similar to https://github.com/apache/pulsar/pull/13951 to refresh the cached token.
Respect backwards compatibility.
### Alternatives
Complete https://github.com/apache/pulsar/pull/13951 - and use it. In some cases though, using the OAuth client is not appropriate. For example, when using Vault as an OIDC - while also providing apps a Vault agent to do the Vault auth - a clientID and secretID are not needed by the app (as again the OIDC/Vault auth is abstracted away)
### Anything else?
_No response_
### Are you willing to submit a PR?
- [X] I'm willing to submit a PR!
Contributor guide
Assessment
This issue has not been assessed yet.