feat(clients): Add permission and expiry overrides to Session.mint_token#432
Draft
feat(clients): Add permission and expiry overrides to Session.mint_token#432
Conversation
Allow callers to mint tokens with a subset of the session's permissions and/or a custom expiry, so they can hand out restricted tokens to downstream consumers. Rust client: - `Session::mint_token()` returns a `MintTokenBuilder` (with deferred error via internal `Result`, matching `ClientBuilder` pattern). - Builder exposes `.permissions()` and `.expiry_seconds()` setters. - `.mint()` terminal method surfaces any accumulated errors. - New error variants: `NoTokenGenerator`, `PermissionEscalation`. Python client: - `Session.mint_token(permissions=..., expiry_seconds=...)` with optional overrides. - Raises `ValueError` when no `TokenGenerator` is configured or when requested permissions exceed the generator's configured set. Both clients now use a separate internal method for auth headers, keeping `mint_token` as a public API exclusively for producing restricted tokens.
Semver Impact of This PR🟡 Minor (new features) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨
🤖 This preview updates automatically when you update the PR. |
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.
Summary
Allow callers to mint tokens with a subset of the session's permissions and/or a custom expiry, so they can hand out restricted tokens to downstream consumers.
Rust client
Session::mint_token()returns aMintTokenBuilderwith deferred error via internalResult, matching theClientBuilderpattern..permissions(&[Permission])and.expiry_seconds(u64)setters..mint()terminal method surfaces any accumulated errors.NoTokenGenerator,PermissionEscalation.Python client
Session.mint_token(permissions=..., expiry_seconds=...)with optional overrides.ValueErrorwhen noTokenGeneratoris configured or when requested permissions exceed the generator's configured set.Shared behavior
auth_token/_auth_token), keepingmint_tokenas a public API exclusively for producing restricted tokens.Test plan
cargo test -p objectstore-client --all-features— all passingcargo clippy --workspace --all-targets --all-features --no-deps— cleanuv run pytest tests/ -x -q— all 26 tests passinguv run ruff check && uv run mypy .— clean