Skip to main content

FastAPI/Starlette library for authentication, throttling, caching.

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


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.2.tar.gz (43.5 kB view details)

Uploaded Source

Built Distribution

webtool-0.0.2-py3-none-any.whl (19.4 kB view details)

Uploaded Python 3

File details

Details for the file webtool-0.0.2.tar.gz.

File metadata

  • Download URL: webtool-0.0.2.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

Hashes for webtool-0.0.2.tar.gz
Algorithm Hash digest
SHA256 472c195bb6fd734b296ba262297f0454354cbae85a9df0126c551aa9b79cfb73
MD5 fad16dd061da19b683c1e8ce4440c510
BLAKE2b-256 e4da6dcb22a820fe6707da6bd2a0576f093f19da33171e44a187448a191cd417

See more details on using hashes here.

File details

Details for the file webtool-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: webtool-0.0.2-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

Hashes for webtool-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 fb3df28f4b67f0107a459bf5b4d35ad9f74535045cdfb6dfcace081c66d5a04d
MD5 32f45715eead03c0db19b5dea6015bf3
BLAKE2b-256 d138884e8432ddd5a348fe20d7a63cb4ad83a89ca10b0dd0e9130d4db1047db8

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page