Reusable backend components for JWT authentication and S3-compatible storage.
Project description
rgc-backend-kit
rgc-backend-kit is a reusable Python backend component library extracted from ai_recipes.
It currently provides:
rgc_backend_kit.security: framework-neutral JWT token lifecycle management.rgc_backend_kit.storage: S3-compatible object storage clients, capability presets, and profile routing.
The package is designed for business services that need shared infrastructure without importing another application's settings, ORM models, response classes, or global factories.
Host applications still own business logic such as login, password verification, permissions, file records, upload policies, and response schemas. See Integration Boundary.
Requirements
- Python
>=3.10 pyjwtfor JWT support- Optional
redisfor Redis-backed token storage - Optional
fastapifor FastAPI dependency adapters - Optional
boto3/botocorefor S3-compatible storage
Install
From PyPI:
pip install rgc-backend-kit
With optional features:
pip install "rgc-backend-kit[fastapi,redis,storage]"
Local development:
uv sync --extra dev
JWT Quick Start
from datetime import timedelta
from rgc_backend_kit.security import JWTConfig, JWTManager, RedisTokenStore
manager = JWTManager(
config=JWTConfig(
secret="replace-with-a-long-random-secret",
issuer="my-service",
audience="my-client",
access_token_ttl=timedelta(minutes=60),
refresh_token_ttl=timedelta(days=7),
),
token_store=RedisTokenStore(redis),
)
token_pair = await manager.issue_pair(subject="user-id", claims={"role": "admin"})
payload = await manager.decode_access_token(token_pair.access_token)
rotated = await manager.rotate_refresh_token(token_pair.refresh_token)
await manager.revoke_access_token(rotated.access_token)
Storage Quick Start
from rgc_backend_kit.storage import (
MINIO_CAPABILITIES,
S3StorageConfig,
StorageFactory,
StorageProfileConfig,
)
factory = StorageFactory.from_configs(
client_configs={
"minio_public": S3StorageConfig(
access_key="minio",
secret_key="minio123",
endpoint="127.0.0.1:9000",
public_endpoint="img.example.com",
bucket_name="public-assets",
secure=False,
secure_public=True,
capabilities=MINIO_CAPABILITIES,
)
},
profiles={
"avatars": StorageProfileConfig(
client="minio_public",
base_path="avatars",
public=True,
)
},
)
avatars = factory.get_profiled_storage("avatars")
url = avatars.build_public_url("demo.png")
Tests
Default tests do not require external services:
uv run --extra dev pytest -q
Redis integration tests require a real Redis instance:
REDIS_URL=redis://:password@127.0.0.1:6379/0 uv run --extra dev pytest -q -m integration
Build package artifacts:
uv build
Validate the built wheel in an isolated environment before publishing:
rm -rf /tmp/rgc-backend-kit-package-full-test
mkdir -p /tmp/rgc-backend-kit-package-full-test
cd /tmp/rgc-backend-kit-package-full-test
uv venv
uv pip install '/home/rgc318/Projects/rgc-backend-kit/dist/rgc_backend_kit-0.1.0-py3-none-any.whl[fastapi,redis,storage]' httpx
Documentation
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rgc_backend_kit-0.1.0.tar.gz.
File metadata
- Download URL: rgc_backend_kit-0.1.0.tar.gz
- Upload date:
- Size: 56.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6dd95f732ce26d02742ff730435d29dc9db5fe2d6cd7bf5f04fa2f824f0fd264
|
|
| MD5 |
666334ed636ba6b7da5becaf21be242c
|
|
| BLAKE2b-256 |
9f48b8f47eb524a198d88aaeba46f3c78208a6cb315fd94138f90803946c96c7
|
Provenance
The following attestation bundles were made for rgc_backend_kit-0.1.0.tar.gz:
Publisher:
publish.yml on rgc318/rgc-backend-kit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rgc_backend_kit-0.1.0.tar.gz -
Subject digest:
6dd95f732ce26d02742ff730435d29dc9db5fe2d6cd7bf5f04fa2f824f0fd264 - Sigstore transparency entry: 1629570559
- Sigstore integration time:
-
Permalink:
rgc318/rgc-backend-kit@91e1648efb52411d726a8744e30bbf433dd0a53c -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/rgc318
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@91e1648efb52411d726a8744e30bbf433dd0a53c -
Trigger Event:
push
-
Statement type:
File details
Details for the file rgc_backend_kit-0.1.0-py3-none-any.whl.
File metadata
- Download URL: rgc_backend_kit-0.1.0-py3-none-any.whl
- Upload date:
- Size: 15.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
99b4db740877daf1605bfca492481bad1287559d647e70271759b91fcd52898c
|
|
| MD5 |
38c9f0bf740134ad1b23f037f44033d9
|
|
| BLAKE2b-256 |
cf5efc0fb044e13d3ce6f03488ee478fae0c8f696cb19e0d1a0dd3f486f3bcb3
|
Provenance
The following attestation bundles were made for rgc_backend_kit-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on rgc318/rgc-backend-kit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rgc_backend_kit-0.1.0-py3-none-any.whl -
Subject digest:
99b4db740877daf1605bfca492481bad1287559d647e70271759b91fcd52898c - Sigstore transparency entry: 1629570564
- Sigstore integration time:
-
Permalink:
rgc318/rgc-backend-kit@91e1648efb52411d726a8744e30bbf433dd0a53c -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/rgc318
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@91e1648efb52411d726a8744e30bbf433dd0a53c -
Trigger Event:
push
-
Statement type: