Repository navigation
feat(python): accept a credentials object for token signing - #19
Merged
Merged
Conversation
Lets a caller sign with a credentials object it already holds — the one behind an existing boto3 client, for instance — instead of a session. Credentials take precedence over the session and are still re-read per token, so rotation is preserved.
mwaisaida-13
left a comment
Collaborator
There was a problem hiding this comment.
Thanks, this is a clean addition! A few things before merge:
-
CHANGELOG, please add the new parameter under Unreleased / Added. -
README. The Credentials section only describes the default chain. Could you add a short "bring your own credentials" paragraph with the snippet from the PR description?
mwaisaida-13
approved these changes
Oct 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds an optional
credentialsparameter togenerate_iam_auth_token,ElastiCacheIAMAuthTokenProvider, andElastiCacheIAMAuthTokenManager, so a caller can sign with a botocore credentials object it already holds instead of supplying a session.credentialstakes precedence when both are given. Existing callers are unaffected.Why
A client that integrates with an application's existing boto3 client has the credentials behind that client but not the session it was created from — a boto3 client keeps no reference back to one. Today the only way to sign a cache token with the application's own identity is to ask it for the session as well, which is an extra argument that exists purely to reach
get_credentials().The session was already used for just two things:
get_credentials()and, as a last fallback,get_config_variable("region"). A caller that passes a region explicitly only needs the first.Rotation is preserved
_resolve_credentialsstill re-reads per token request and callsget_frozen_credentials(), so a refreshable credentials object refreshes itself exactly as the session's would: the refresh callable is captured inside the object when the chain resolves it, so it needs nothing from the session afterwards. The new tests cover aRefreshableCredentialsobject vending rotated keys across twoget_token()calls.