Session provider sync implementation - #48843
Conversation
|
Azure Pipelines: Successfully started running 1 pipeline(s). 9 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
🟡 Changes recommended
The tests fail to parse, and session handling has unresolved URL, audience, typing, and cache issues.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adds synchronous, shareable session-provider support atop the existing blob GET session authentication.
Changes:
- Adds session caching, signing, bearer fallback, and provider sharing.
- Exposes session configuration through synchronous clients.
- Adds session tests, sanitizers, and release notes.
File summaries
| File | Description |
|---|---|
CHANGELOG.md |
Documents session authentication. |
azure/storage/blob/__init__.py |
Exports session providers. |
_blob_service_client.py |
Documents session options. |
_blob_service_client.pyi |
Adds session parameters. |
_container_client.py |
Documents session options. |
_container_client.pyi |
Adds session parameters. |
_shared/base_client.py |
Integrates session policy/provider. |
_shared/models.py |
Adds session error codes. |
_shared/policies.py |
Implements signing and fallback. |
_shared/session.py |
Implements providers and cache. |
tests/conftest.py |
Sanitizes session credentials. |
tests/test_container.py |
Tests session behavior. |
tests/test_helpers.py |
Adds authentication test helpers. |
Review details
- Files reviewed: 13/13 changed files
- Comments generated: 10
- Review effort level: Balanced
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
| assert session2 == _parse_session_token(capture_auth_header["c2_download2"]) | ||
|
|
||
| policy = _find_session_policy(service._pipeline) | ||
| cached = policy._cache._entry[container1_name] |
| StorageSensitiveHeaderCleanupPolicy(**kwargs), | ||
| ] | ||
| use_session = bool(kwargs.pop("use_session", False)) | ||
| session_provider = kwargs.pop("session_provider", None) |
There was a problem hiding this comment.
When you are working on tests, this is good. We want a test case for a user providing a session provider.
| StorageSensitiveHeaderCleanupPolicy(**kwargs), | ||
| ] | ||
| use_session = bool(kwargs.pop("use_session", False)) | ||
| session_provider = kwargs.pop("session_provider", None) |
There was a problem hiding this comment.
When you are working on tests, this is good. We want a test case for a user providing a session provider.
| :paramtype session_provider: ~azure.storage.blob.SessionProvider | ||
| :keyword str session_account_name: The storage account name used to sign session-authenticated | ||
| requests. If omitted, it is derived from the account URL. Required when using a custom | ||
| endpoint, where the account name cannot be determined from the URL. |
There was a problem hiding this comment.
These options also need to be added to BlobClient and the BlobClient pyi also need to be updated.
Summary
This PR introduces SessionProvider building off the previous #47264. Customers can optionally supply one via session_options.session_provider and reuse it across clients to share the cache. If it's not supplied, one is created and scoped to the client, so existing behavior is unchanged.