Skip to content

feat: implement vended credential refresh - #3751

Open
gabeiglio wants to merge 1 commit into
apache:mainfrom
gabeiglio:vended-credentials-provider
Open

feat: implement vended credential refresh#3751
gabeiglio wants to merge 1 commit into
apache:mainfrom
gabeiglio:vended-credentials-provider

Conversation

@gabeiglio

@gabeiglio gabeiglio commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Third time's a charm (prev PR closed due to staleness) :) Closes #3506

Rationale for this change

Implement automatic vended credential refresh in PyIceberg.

Are these changes tested?

Yes,

  1. catalog/test_credential_provider.py test the VendedCredential class
  2. test_rest.py tests the attach logic and overall refresh feature
  3. io/test_credential_provider.py tests caching and locking

Are there any user-facing changes?

Yes, users will have the option to set the refresh credentials configurations in the catalog

@gabeiglio
gabeiglio force-pushed the vended-credentials-provider branch from 350dc82 to 010d6bc Compare August 5, 2026 10:20
@gabeiglio
gabeiglio marked this pull request as ready for review August 5, 2026 10:41
@gabeiglio

Copy link
Copy Markdown
Contributor Author

@kevinjqliu I opened this PR as the previous one was closed for being stale. Here I've hopefully addressed your comments!

  1. CredentialsProvider now accepts a refresh_fn (passed in by the catalog) to fetch new credentials when needed.
  2. FileIO now caches filesystems by credentials too, so a cache hit can no longer return a filesystem built with expired credentials.
  3. CredentialsProvider owns the credential resolution logic, and the longest-prefix-match against storage credentials.
  4. CredentialsProvider exposes a per-scheme hook so refresh logic can be implemented individually per scheme (currently only implemented for S3).

@dossett

dossett commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

+1 (non-binding). GCS support would be pretty to add to this.

@rambleraptor rambleraptor left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I've got a couple concerns around refresh intervals + pickling.

Thanks a lot for getting this started! Excited to get this merged in.

catalog=self,
)

def _attach_credentials_provider(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can we rename this to _attach_credentials_provider_to_io?

longest-prefix matching against the freshly vended credentials.
"""
if storage_credentials and property_as_bool(self.properties, REFRESH_CREDENTIALS_ENABLED, False):
io.set_credentials_provider(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This breaks pickling support on FileIO. We can't pickle lambdas.

We have some tests for pickling FileIO, but none of them break because this is behind REFRESH_CREDENTIALS_ENABLE


def _can_refresh(self, location: str) -> bool:
scheme = urlparse(location).scheme
refresh_by_scheme = self._needs_refresh_by_scheme.get(scheme)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

If the TTL on a S3 token is < 300s (the default value), we'll attempt to refresh on every call. That's a lot of possibly unnecessary refreshes.

It seems like we should track when the last refresh was and use that information to determine when we should next refresh.

Java does something similar in scheduleCredentialRefresh

The refresh callback returns the full LoadCredentialsResponse so the provider can re-run
longest-prefix matching against the freshly vended credentials.
"""
if storage_credentials and property_as_bool(self.properties, REFRESH_CREDENTIALS_ENABLED, False):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We should check that the server has access to the LoadCredentials endpoint. Otherwise, it'll probably throw an error.

(If you're setting this property, your catalog probably has the proper endpoints, but we should verify anyways)

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.

feat: Automatic Vended Credential Refresh

3 participants