session-adapters
Requests transport adapters for bearer-authenticated http(s)://, file://,
s3://, and oci:// URLs.
Why This Project
session-adapters lets you use a standard requests.Session with authenticated
HTTP requests and non-HTTP backends:
http://andhttps://with bearer token authenticationfile://for local filesystem artifactss3://for AWS S3 objects and prefix listingsoci://for OCI registry artifacts (via ORAS client)
This keeps one client interface while changing only the URL scheme.
Installation
pip install session-adapters
Quick Start
import requests
from session_adapters.bearer_auth_http_adapter import BearerAuthHTTPAdapter
from session_adapters.file_adapter import FileAdapter
from session_adapters.oci_adapter import OCIAdapter
from session_adapters.s3_adapter import S3Adapter
session = requests.Session()
session.mount("https://", BearerAuthHTTPAdapter("my-token"))
session.mount("file://", FileAdapter())
session.mount("s3://", S3Adapter())
session.mount("oci://", OCIAdapter())
# Bearer-authenticated HTTPS request
resp = session.get("https://api.example.com/resource")
print(resp.status_code)
# Local file
resp = session.get("file:///tmp/example.txt")
print(resp.status_code)
# S3 object
resp = session.get("s3://my-bucket/path/to/object.json")
print(resp.status_code)
# OCI artifact
resp = session.get("oci://registry.example.com/my-repo:latest")
print(resp.status_code)
Adapter Notes
Bearer Auth HTTP Adapter
- Adds an
Authorization: Bearer <token>header to every request it handles - Replaces an existing
Authorizationheader - Can be mounted on a specific URL prefix to limit where the token is sent
- Mount separate adapters for
http://andhttps://if both schemes are needed
File Adapter
- Supports
GET,HEAD,PUT,DELETE - Uses local filesystem paths from
file://URLs
S3 Adapter
- Supports
GET,HEAD,PUT,DELETE - Supports query options like:
range=bytes=0-99versionId=...delimiter=/maxKeys=...
OCI Adapter
- Supports
GET,HEAD,PUT,DELETE - Parses refs as tags (
:tag) or digests (@sha256:...) - Uses
oras.client.OrasClientunder the hood
Development
Run tests:
hatch run test:test-q
Run lint checks:
hatch run dev:check
ruff format --check .
License
session-adapters is distributed under the terms of the MIT license.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file session_adapters-0.4.0.tar.gz.
File metadata
- Download URL: session_adapters-0.4.0.tar.gz
- Upload date:
- Size: 22.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f59f20f3d5c8c7590e0488fb8e1e481ec5b3734e9711cefd6d283902c896e0c0
|
|
| MD5 |
459aaa0915eae5fdc47dbc22ec00c61e
|
|
| BLAKE2b-256 |
807b4db84cfbad47f0b359a65d2a4dc0dd103c3961dafa66a2bddef1619de4d1
|
Provenance
The following attestation bundles were made for session_adapters-0.4.0.tar.gz:
Publisher:
package.yaml on Terradue/session-adapters
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
session_adapters-0.4.0.tar.gz -
Subject digest:
f59f20f3d5c8c7590e0488fb8e1e481ec5b3734e9711cefd6d283902c896e0c0 - Sigstore transparency entry: 2173060415
- Sigstore integration time:
-
Permalink:
Terradue/session-adapters@eedf4760718d25658638772f45961337c21ad07b -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/Terradue
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
package.yaml@eedf4760718d25658638772f45961337c21ad07b -
Trigger Event:
push
-
Statement type:
File details
Details for the file session_adapters-0.4.0-py3-none-any.whl.
File metadata
- Download URL: session_adapters-0.4.0-py3-none-any.whl
- Upload date:
- Size: 21.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e16d311e424c43044d39bdf6b2cfb35e1ef33f41b76fa36a5d05027e1cf9ebb0
|
|
| MD5 |
ee907c20fd6037604275a750d5259ddf
|
|
| BLAKE2b-256 |
f148420d1e7898b92658f96bcaa761ff00ca7c59163f74eb4dc96cbae943ed65
|
Provenance
The following attestation bundles were made for session_adapters-0.4.0-py3-none-any.whl:
Publisher:
package.yaml on Terradue/session-adapters
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
session_adapters-0.4.0-py3-none-any.whl -
Subject digest:
e16d311e424c43044d39bdf6b2cfb35e1ef33f41b76fa36a5d05027e1cf9ebb0 - Sigstore transparency entry: 2173060425
- Sigstore integration time:
-
Permalink:
Terradue/session-adapters@eedf4760718d25658638772f45961337c21ad07b -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/Terradue
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
package.yaml@eedf4760718d25658638772f45961337c21ad07b -
Trigger Event:
push
-
Statement type: