Skip to content

[python] Support DLF token path authentication - #9089

Merged
JingsongLi merged 2 commits into
apache:masterfrom
liujiayi771:feat/pypaimon-dlf-token-path
Aug 7, 2026
Merged

[python] Support DLF token path authentication#9089
JingsongLi merged 2 commits into
apache:masterfrom
liujiayi771:feat/pypaimon-dlf-token-path

Conversation

@liujiayi771

Copy link
Copy Markdown
Contributor

Purpose

Add dlf.token-path authentication support to PyPaimon REST catalogs.

PyPaimon now loads temporary DLF credentials from a local JSON file, retries transient file-read failures, and reloads expiring credentials. The behavior aligns with the existing Java local_file token loader.

Tests

  • PYTHONPATH=. python -m pytest pypaimon/tests/rest/token_loader_test.py pypaimon/tests/rest/dlf_signer_test.py pypaimon/tests/rest/api_test.py -q

@liujiayi771
liujiayi771 marked this pull request as ready for review August 7, 2026 04:40
@liujiayi771

Copy link
Copy Markdown
Contributor Author

@JingsongLi JingsongLi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

One Java-alignment issue needs to be addressed.

)
role_name = options.get(CatalogOptions.DLF_TOKEN_ECS_ROLE_NAME)
return DLFECSTokenLoader(ecs_metadata_url, role_name)
if loader == 'local_file':

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could we make the credential-source precedence match Java here? When dlf.token-path (or dlf.token-loader=local_file) is configured together with static dlf.access-key-id / dlf.access-key-secret, this factory returns a loader, but AuthProviderFactory also passes DLFToken.from_options(options) to DLFAuthProvider. Because that static token has no expiration, get_token() never calls the loader, so the token file is silently ignored. Java selects the loader/path before static AK/SK. Please choose a single source in the Python factory (for example, pass token=None whenever a loader exists) and add a mixed-configuration regression test.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for catching this! You are right. I updated AuthProviderFactory to select a single credential source: when an explicit token loader or the implicit local_file loader from dlf.token-path is present, the provider now gets token=None, so the loader takes precedence over static AK/SK, matching Java. Unknown explicit loader names now fail instead of falling back to static credentials. I also added regression coverage for mixed configurations with both implicit dlf.token-path and explicit dlf.token-loader=local_file.

liujiayi771 and others added 2 commits August 7, 2026 20:48
Add a local-file DLF token loader with retry and credential-safe errors, and wire dlf.token-path into DLF loader selection and refresh.

Co-Authored-By: Codex <noreply@openai.com>
Ensure configured token loaders take precedence over static credentials and reject unknown loader identifiers.
@liujiayi771
liujiayi771 force-pushed the feat/pypaimon-dlf-token-path branch from d5ec018 to f9bf147 Compare August 7, 2026 12:50
@JingsongLi

Copy link
Copy Markdown
Contributor

+1

@JingsongLi
JingsongLi merged commit 507a121 into apache:master Aug 7, 2026
8 of 9 checks passed
@liujiayi771
liujiayi771 deleted the feat/pypaimon-dlf-token-path branch August 7, 2026 17:27
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