Skip to content

Comments

RANGER-5496: Decouple JWT lifecycle from Ranger plugin via pluggable JWT provider#857

Open
kumaab wants to merge 2 commits intoapache:masterfrom
kumaab:ranger_5496
Open

RANGER-5496: Decouple JWT lifecycle from Ranger plugin via pluggable JWT provider#857
kumaab wants to merge 2 commits intoapache:masterfrom
kumaab:ranger_5496

Conversation

@kumaab
Copy link
Contributor

@kumaab kumaab commented Feb 21, 2026

What changes were proposed in this pull request?

Currently JWT is fetched during plugin initialization (via 3 different ways: env, file, cred file) and captured statically in the REST client filter. This enhancement introduces a pluggable JWT provider interface allowing services to manage JWT lifecycle independently while enabling Ranger plugins to fetch the latest JWT dynamically for each outbound REST call to Ranger Admin. PR includes a default implementation of JwtProvider.

How was this patch tested?

Pending

@kumaab kumaab self-assigned this Feb 21, 2026
@kumaab kumaab requested a review from mneethiraj February 23, 2026 20:34

public class DefaultJwtProvider implements JwtProvider {
private static final Logger LOG = LoggerFactory.getLogger(DefaultJwtProvider.class);
public static final String JWT_SOURCE = ".policy.rest.client.jwt.source";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest making .policy.rest.client part of propertyPrefix (line 48) to make this class generic for use in other contexts as well, like to fetch JWT to talk to services like Ranger KMS, Ranger RAZ, Ranger RMS, and other non-Ranger endpoints.

String line = null;
while ((line = reader.readLine()) != null) {
if (StringUtils.isNotBlank(line) && !line.startsWith("#")) {
jwt = line;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Introduce break; after line 71?

String credAlias = config.get(propertyPrefix + JWT_CRED_ALIAS);
if (StringUtils.isNotEmpty(credFilePath) && StringUtils.isNotEmpty(credAlias)) {
String jwtFromCredFile = RangerCredentialProvider.getInstance().getCredentialString(credFilePath, credAlias);
if (StringUtils.isNotBlank(jwt)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jwt => jwtFromCredFile

private RangerAdminClient adminClient;

public RangerPluginContext(RangerPluginConfig config) {
this.config = config;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initialize DefaultJwtProvider instance with following call:
jwtProvider.setJwt(config.getPropertyPrefix() + ".policy.rest.client", config);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants