py-xshl-session
Session in JWT
Python library for managing JWT/JWE sessions with key management and XSHL Target integration.
- 🇷🇺 Russian version: see
README_RU.md - 📚 Full docs:
docs/index.md→ Quickstart, Guides, API, Security - 🌐 Localized docs (RU):
docs/ru/index.md
Features
- 🔐 JWT/JWE support for signing and encryption
- 🎯 XSHL integration: Target-aware JWKS loading
- ⚡ Background refresh of JWKS with TTL
- 🛡️ Extended claims validation via custom
SessionClaims - 📦 JWE serialization/deserialization helpers
- 🔍 Built-in request tracing
Constants
DEFAULT_SESSION_VERSION = 1DEFAULT_SESSION_EXPIRES = 120DEFAULT_UID = "00000000-0000-0000-0000-000000000000"DEFAULT_STR = "undef"
Quickstart
See docs/quickstart.md for a complete guide.
from xshl.session.keys import Keys
from xshl.session import Session, ConfigSession
import uuid
keys = Keys(name="session_name", url="https://example.org/jwks.json")
config = ConfigSession(
keys=keys,
app=uuid.uuid4(),
audience=["service-api"],
header={"alg": "RS256", "kid": "<kid>"},
version=1,
expires=3600,
key=b"<private-key-pem>"
)
session = Session(config, "trace-1", "trace-2")
session.sub = "user-123"
session.aud = "service-api"
session.scope = ["read", "write"]
jwt_token = session.jwt
Note: Session.jwt uses a JsonDumps context internally to serialize claims because Authlib JWT encoding does not expose a default hook for JSON; see API docs.
Merge note: all claims are copied on session + token, and claims in Session.merge_attributes are merged.
JWE helpers:
protected = {"alg": "RSA-OAEP-256", "enc": "A256GCM", "kid": "<kid>"}
serialized = session.serialize(b"payload", protected)
plaintext = session.deserialize(serialized)
Documentation
- API details in
docs/api.md - Configuration and operational tips in
docs/guides.md - Security recommendations in
docs/security.md
License
GPL v3 — see LICENSE and COPYRIGHT.
Contributing
- Issues and feature requests: open on GitHub
- Pull requests welcome. Please ensure:
- Tests pass
- Lint/style are respected
- Tests are added for new functionality
- You understand GPL v3 requirements for contributions
Metadata
Release files for xshl-session 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| xshl_session-0.0.3.tar.gz | 39.5 kB | Without provenance | Details for xshl_session-0.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| xshl_session-0.0.3-py3-none-any.whl | Python 3 | none | any | Details for xshl_session-0.0.3-py3-none-any.whl |
Total release size: 74.7 kB
Release files / xshl_session-0.0.3.tar.gz
| Download URL | xshl_session-0.0.3.tar.gz |
|---|---|
| Size | 39.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
351847e069b7f419bd47654db8131345efb5afd40edeee3a187202b2b3e645ae
|
|
BLAKE2b-256 checksum How to use checksums |
4957e38ce4e46a432df7270349cba499ea69b922a6e6e41c19e4875de47017d8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Release files / xshl_session-0.0.3-py3-none-any.whl
| Download URL | xshl_session-0.0.3-py3-none-any.whl |
|---|---|
| Size | 35.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6288b583720e78e093a4e8aee2876c2e600235f532a11e965cd5b6fb5db7ae36
|
|
BLAKE2b-256 checksum How to use checksums |
d1fba12bb9b81df35f0d5328d22c8baf1549968ce6e04474caeb72289c45ab1d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Security for xshl-session 0.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.