rossetta-fastapi
End-to-end encryption middleware for FastAPI applications.
Installation
pip install rossetta-fastapi
Usage
Add the middleware to your FastAPI application with a single line:
from fastapi import FastAPI
from rossetta_fastapi import RossettaMiddleware
app = FastAPI()
# Add the middleware - that's it!
app.add_middleware(RossettaMiddleware)
# All your existing routes now have e2e encryption
@app.get("/api/data")
async def get_data():
return {"message": "This response is automatically encrypted!"}
@app.post("/api/submit")
async def submit_data(data: dict):
# Request is automatically decrypted
return {"received": data}
Features
- Zero Code Changes: Add middleware and all routes are automatically protected
- Transparent Encryption: Works with existing FastAPI code
- Automatic Key Exchange: ECDH key exchange handled automatically
- Replay Attack Prevention: Built-in timestamp and nonce validation
- Session Management: Automatic session lifecycle management
Configuration
app.add_middleware(
RossettaMiddleware,
session_duration=3600, # Session duration in seconds (default: 1 hour)
max_timestamp_drift=300, # Max timestamp drift in seconds (default: 5 minutes)
)
How It Works
- Client initiates ECDH key exchange via
/__rossetta_handshake__endpoint - Middleware derives shared secret from key exchange
- All subsequent requests are encrypted with the shared session key
- Middleware decrypts requests, validates nonce/timestamp
- Processes request through normal FastAPI handlers
- Encrypts response before sending back to client
Requirements
- Python 3.8+
- FastAPI 0.100.0+
- cryptography 41.0.0+
Client Compatibility
Works with rossetta-client npm package for JavaScript/TypeScript clients.
License
MIT
Metadata
Release files for rossetta-fastapi 0.2.0
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 |
|---|---|---|---|---|
| rossetta_fastapi-0.2.0.tar.gz | 13.0 kB | Without provenance | Details for rossetta_fastapi-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| rossetta_fastapi-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for rossetta_fastapi-0.2.0-py3-none-any.whl |
Total release size: 24.2 kB
Release files / rossetta_fastapi-0.2.0.tar.gz
| Download URL | rossetta_fastapi-0.2.0.tar.gz |
|---|---|
| Size | 13.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d7af0e5ac1ee794a53b84ae36148750b4b6c5a88436fe12ccca5a59b719734bd
|
|
BLAKE2b-256 checksum How to use checksums |
b8958a708389f0a58a373bc026888dc6a6e9c39ef9e31983ede6a90a121c7cd8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|
Release files / rossetta_fastapi-0.2.0-py3-none-any.whl
| Download URL | rossetta_fastapi-0.2.0-py3-none-any.whl |
|---|---|
| Size | 11.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
90094cea44cfa8f61648bd9f06d16658ce4013347d99eb10c12b2ea7faca0931
|
|
BLAKE2b-256 checksum How to use checksums |
5cb511bb4e8ddb891a8dd0e24542bd137537fccf3692fe783ffc7ee1fb3f84da
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|
Security for rossetta-fastapi 0.2.0
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.