Repository navigation
feat(py-client)!: Restore TokenGenerator and sign_for_scope names - #713
Closed
sentry-junior[bot] wants to merge 1 commit into
Closed
sentry-junior[bot] wants to merge 1 commit into
sentry-junior[bot] wants to merge 1 commit into
Conversation
Co-Authored-By: Lorenzo Cian <17258265+lcian@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #713 +/- ##
==========================================
- Coverage 91.81% 91.81% -0.01%
==========================================
Files 116 116
Lines 24065 24063 -2
==========================================
- Hits 22095 22093 -2
Misses 1970 1970
☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
lcian
marked this pull request as ready for review
October 22, 2026 10:36
lcian
approved these changes
Oct 22, 2026
This was referenced Oct 22, 2026
lcian
added a commit
that referenced
this pull request
Oct 22, 2026
**Breaking change** for the Python client. Splits the Python client's auth type into two concepts, matching the shape the Rust client already has: - **`SecretKey(kid, secret_key)`**: only the signing identity. Signs canonical forms for pre-signed URLs (`signature_for_canonical_form`) and carries no token defaults. - **`TokenGenerator(key, expiry_seconds=60, permissions=None)`**: the token policy. Holds the default expiry and the permission ceiling, and signs JWTs via `token_for_scope`. This is what you pass to `Client(token=...)`. Previously `SecretKey` held both the key and the token defaults (`expiry_seconds`, `permissions`), and `TokenGenerator` / `sign_for_scope` were aliases marked deprecated only in code comments. Both aliases are removed. Other changes: - Adds a `Token = str` alias for static pre-signed JWTs; `TokenProvider` is now `TokenGenerator | Token`. Both are exported from `objectstore_client`. - `Session.mint_token`, `object_url(token_validity=...)` and `presigned_object_url` require a `TokenGenerator`; pre-signing uses `generator.key`. The error message is now `no token generator configured on this session`. - README, docstrings and tests updated. `tests/test_auth.py` covers JWT signing with the wrapped key, the permission ceiling, and canonical-form signing (moved from `test_presign.py`). Supersedes #713 and #719 (Python) and #720 (Rust rename), which are closed. No Rust change is needed: `TokenGenerator::new(SecretKey { kid, secret_key })` already separates the two. **Downstream:** `getsentry/sentry` builds `TokenGenerator(**signing_key_options)` from settings. The upgrade PR needs to construct `TokenGenerator(SecretKey(kid, secret_key), expiry_seconds=..., permissions=...)` instead. ### Changelog Entry - (py-client) Split the signing key from the token policy: `SecretKey(kid, secret_key)` now only holds the EdDSA key, and `TokenGenerator(key, expiry_seconds=60, permissions=None)` wraps it with the token defaults and is what you pass to `Client(token=...)`. The deprecated `sign_for_scope()` alias is removed. - Replace `SecretKey(kid, secret_key, expiry_seconds, permissions)` or `TokenGenerator(kid, secret_key, ...)` with `TokenGenerator(SecretKey(kid, secret_key), expiry_seconds, permissions)`. ```python # Before client = Client(url, token=SecretKey(kid, secret_key, expiry_seconds=300)) # After key = SecretKey(kid, secret_key) client = Client(url, token=TokenGenerator(key, expiry_seconds=300)) ``` - Replace `.sign_for_scope(...)` with `.token_for_scope(...)`. <!-- junior-request-attribution:start --> via @lcian. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:slack%3AC0C641CPPS8%3A1792662581.533099 --> -- [View Junior Session](https://junior-prod.sentry.dev/conversations/slack%3AC0C641CPPS8%3A1792662581.533099) [[Sentry]](https://sentry.sentry.io/explore/conversations/slack%3AC0C641CPPS8%3A1792662581.533099/?project=4510944073809921) <!-- junior-session-footer:end --> --------- Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: Lorenzo Cian <17258265+lcian@users.noreply.github.com>
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.
Breaking change for the Python client.
#544 renamed
TokenGeneratortoSecretKeyandsign_for_scope()totoken_for_scope(), and kept the old names as aliases marked deprecated only in code comments. This reverts the rename and removes the aliases, so the Python client uses the sameTokenGeneratorname as the Rust client again:SecretKey→TokenGenerator. It no longer exists as a separate name or export.token_for_scope()→sign_for_scope().Behavior doesn't change. Pre-signed URLs still go through
TokenGenerator.Sentry already uses
TokenGenerator(src/sentry/objectstore/__init__.py) and never callstoken_for_scope, so it shouldn't need changes. Callers that switched toSecretKeyortoken_for_scopemust switch back.Changelog Entry
SecretKeyback toTokenGeneratorandtoken_for_scope()back tosign_for_scope(), matching the Rust client, and remove the aliasesSecretKey(...)withTokenGenerator(...)..token_for_scope(...)with.sign_for_scope(...).via @lcian.
--
View Junior Session [Sentry]