No project description provided
Project description
Webkit
Well-Architected Python library for authentication, throttling, caching, logging, and utilities.
Requirements
- Python 3.10+
Installation
pip install webkit
poetry add webkit
Features
Authentication
JWT token management system with Redis-backed refresh tokens.
from webkit.auth import JWTService
from webkit.cache import RedisCache
cache_client = RedisCache("redis://localhost:6379/0")
jwt_service = JWTService(cache_client)
async def get_token():
access_token = jwt_service.create_access_token({"sub": 123, "scope": ["write"]})
refresh_token = await jwt_service.create_refresh_token({"sub": 123}, access_token)
return access_token, refresh_token
Throttling
Rate limiting system for FastAPI/Starlette applications.
from webkit.throttle import limiter
from fastapi import FastAPI
app = FastAPI()
@app.get("/api/resource")
@limiter(max_requests=50, interval=3600, scope=["user"])
@limiter(max_requests=10, interval=3600, scope=["anno"])
async def get_resource():
return {"status": "success"}
MsgPack Response
MessagePack-based response.
from webkit.utils import MsgSpecJSONResponse
from fastapi import FastAPI
app = FastAPI(
default_response_class=MsgSpecJSONResponse,
)
@app.get("/api/resource")
async def get_resource():
return {"status": "success"}
License
This project is licensed under the Apache-2.0 License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
webtool-0.0.1.tar.gz
(43.5 kB
view details)
Built Distribution
webtool-0.0.1-py3-none-any.whl
(19.4 kB
view details)
File details
Details for the file webtool-0.0.1.tar.gz
.
File metadata
- Download URL: webtool-0.0.1.tar.gz
- Upload date:
- Size: 43.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.5 Darwin/24.1.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ea0af7fb916328b48c14f9e5a4ca0993a73227ded3dfbcbc36c29c67350aba20 |
|
MD5 | 14025f91f90a02a2651f06eac9cf4aed |
|
BLAKE2b-256 | bef7bcd2b0d09f133024ebcdcca964551b998598a5f6481a42b51781e55e62fb |
File details
Details for the file webtool-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: webtool-0.0.1-py3-none-any.whl
- Upload date:
- Size: 19.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.5 Darwin/24.1.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a434bc4bbd3d40076b225452d81d19dc2685b978a79464db2c1ebc66b8f775dc |
|
MD5 | 4e69f2dc3f5e3e4f2f47e94ab61d32f2 |
|
BLAKE2b-256 | 0de234279c421f3b608d0f12afe7fff739ef3f387365d2bde1f50986001627cf |