🛡️ USSO Python Client SDK
The USSO Python Client SDK (usso) provides a universal, secure JWT authentication layer for Python microservices and web frameworks.
It’s designed to integrate seamlessly with the USSO Identity Platform — or any standards-compliant token issuer.
🔗 Relationship to the USSO Platform
This SDK is the official verification client for the USSO identity service, which provides multi-tenant authentication, RBAC, token flows, and more.
You can use the SDK with:
- Self-hosted USSO via Docker
- Any identity provider that issues signed JWTs (with proper config)
✨ Features
- ✅ Token verification for EdDSA, RS256, HS256, and more
- ✅ Claim validation (
exp,nbf,aud,iss) - ✅ Remote JWK support for key rotation
- ✅ Typed payload parsing via
UserData(Pydantic) - ✅ Token extraction from:
Authorizationheader- Cookies
- Custom headers
- ✅ FastAPI integration with dependency injection
- ✅ Django middleware for request-based user resolution
- 🧪 90% tested with
pytestandtox
📦 Installation
pip install usso
With framework extras:
pip install "usso[fastapi]" # for FastAPI integration
pip install "usso[django]" # for Django integration
🚀 Quick Start (FastAPI)
from usso.fastapi.integration import get_authenticator
from usso.schemas import JWTConfig, JWTHeaderConfig, UserData
from usso.jwt.enums import Algorithm
config = JWTConfig(
key="your-ed25519-public-key",
issuer="https://sso.example.com",
audience="api.example.com",
type=Algorithm.EdDSA,
header=JWTHeaderConfig(type="Authorization"),
)
authenticator = get_authenticator(config)
@app.get("/me")
def get_me(user: UserData = Depends(authenticator)):
return {"user_id": user.sub, "roles": user.roles}
🧱 Project Structure
src/usso/
├── fastapi/ # FastAPI adapter
├── django/ # Django middleware
├── jwt/ # Core JWT logic and algorithms
├── session/ # Stateless session support
├── models/ # JWTConfig, UserData, etc.
├── exceptions/ # Shared exceptions
├── authenticator.py # High-level API (token + user resolution)
🐳 Integrate with USSO (Docker)
Run your own identity provider:
docker run -p 8000:8000 ghcr.io/ussoio/usso:latest
Then configure your app to verify tokens issued by this service, using its public JWKS endpoint:
JWTConfig(
jwks_url="http://localhost:8000/.well-known/jwks.json",
...
)
🧪 Testing
pytest
tox
USSO Lite for standalone FastAPI applications
Install the local identity dependencies and mount the router:
pip install "usso[lite,fastapi]"
from fastapi import FastAPI
from usso.lite import EXCEPTION_HANDLERS, LiteConfig, create_lite_router
app = FastAPI()
config = LiteConfig(
database_url="sqlite+aiosqlite:///./identity.db",
issuer="https://api.example.com",
audience="api.example.com",
otp_sender=send_otp, # async (identifier_type, identifier, code)
)
app.include_router(create_lite_router(config))
for exception, handler in EXCEPTION_HANDLERS.items():
app.add_exception_handler(exception, handler)
Lite emits the same UserData-compatible claims as USSO and publishes its
public signing key at /.well-known/jwks.json. A service can therefore move
to full USSO by changing its issuer/JWKS configuration without changing its
authorization code.
Security defaults:
- public registration cannot assign roles or scopes;
- user-management routes require
admin:usso/lite/users(or a broader USSO scope); - OTP values are never returned by HTTP unless
expose_otp_in_response=Trueis explicitly enabled for local development; - refresh tokens are single-use and sessions are checked on every local authenticated request;
- login, registration, and OTP requests are rate-limited.
For initial provisioning, pass a trusted FastAPI dependency as
admin_dependency= (for example, a deployment-only API-key dependency), use
POST /users to create the first scoped administrator, then remove that
bootstrap dependency. Do not grant the admin scope through default_scopes,
because defaults apply to every public registration.
🤝 Contributing
We welcome contributions!
📝 License
MIT License © [mahdikiani]
Metadata
Release files for usso 0.33.5
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 |
|---|---|---|---|---|
| usso-0.33.5.tar.gz | 202.3 kB | Without provenance | Details for usso-0.33.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| usso-0.33.5-py3-none-any.whl | Python 3 | none | any | Details for usso-0.33.5-py3-none-any.whl |
Total release size: 279.7 kB
Release files / usso-0.33.5.tar.gz
| Download URL | usso-0.33.5.tar.gz |
|---|---|
| Size | 202.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a917cc66f89002cabcf5978811b0d44139afca73a55e84697861e58f041937f0
|
|
BLAKE2b-256 checksum How to use checksums |
cdcd8f74152a8b64502de69ad3d64885032b1061a9a5dae8884aed7b7bd39508
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / usso-0.33.5-py3-none-any.whl
| Download URL | usso-0.33.5-py3-none-any.whl |
|---|---|
| Size | 77.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
82b76b3a1aba3b99cf9f1b1675ae353e12e9ed6d37c1abae94dacb21a4edb257
|
|
BLAKE2b-256 checksum How to use checksums |
32c4938995694c6e5ac80e1e5a4e3f6abda7eb7b08afd537bb8530a1b5ea2953
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Security for usso 0.33.5
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.