Skip to content

Commit 385b5cb

Browse files
committed
refactor(library): rename library fastapi-api-key to keyshield
1 parent c751f33 commit 385b5cb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+462
-462
lines changed

AGENTS.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Follow existing patterns and run the same tooling as humans.
66
## Project overview
77

88
- Language: Python 3.9+
9-
- Package: `fastapi_api_key` (src layout)
9+
- Package: `keyshield` (src layout)
1010
- Async-first services and repositories
1111
- Optional extras for FastAPI, SQLAlchemy, Argon2, bcrypt, aiocache
1212

@@ -90,7 +90,7 @@ Artifacts: `coverage.xml`, `htmlcov/`, `junit.xml`.
9090

9191
### Error handling
9292

93-
- Domain exceptions live in `fastapi_api_key.domain.errors`.
93+
- Domain exceptions live in `keyshield.domain.errors`.
9494
- Raise domain errors in services and repositories, translate to HTTP exceptions in API layer.
9595
- Preserve original errors with `raise ... from exc`.
9696
- Use specific exceptions (`KeyNotFound`, `InvalidKey`, `ConfigurationError`) rather than `ValueError` unless appropriate.
@@ -123,7 +123,7 @@ Artifacts: `coverage.xml`, `htmlcov/`, `junit.xml`.
123123

124124
## Repository layout
125125

126-
- `src/fastapi_api_key/` core library
126+
- `src/keyshield/` core library
127127
- `tests/` unit/integration tests
128128
- `examples/` example applications (used in docs)
129129

CONTRIBUTING.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Contributing
22

3-
Thanks for helping improve `fastapi-api-key`! This guide walks you through the toolchain, branching model, and tooling conventions we follow.
3+
Thanks for helping improve `keyshield`! This guide walks you through the toolchain, branching model, and tooling conventions we follow.
44

55
## Prerequisites
66

@@ -13,12 +13,12 @@ Thanks for helping improve `fastapi-api-key`! This guide walks you through the t
1313
1. **Fork** the repository to your own GitHub account.
1414
2. **Clone** your fork locally:
1515
```bash
16-
git clone https://github.com/<you>/fastapi-api-key.git
17-
cd fastapi-api-key
16+
git clone https://github.com/<you>/keyshield.git
17+
cd keyshield
1818
```
1919
3. **Add the upstream remote** so you can sync later:
2020
```bash
21-
git remote add upstream https://github.com/Athroniaeth/fastapi-api-key.git
21+
git remote add upstream https://github.com/Athroniaeth/keyshield.git
2222
```
2323
4. **Create a feature branch** from the active integration branch (default: `development`):
2424
```bash
@@ -71,7 +71,7 @@ source .venv/bin/activate # or .venv\Scripts\Activate.ps1 on Windows
7171
git push origin feat/<short-topic>
7272
```
7373

74-
6. **Open a pull request** targeting `Athroniaeth/fastapi-api-key:development`. Summarise the change, mention tests/docs runs, and link related issues if applicable.
74+
6. **Open a pull request** targeting `Athroniaeth/keyshield:development`. Summarise the change, mention tests/docs runs, and link related issues if applicable.
7575

7676
## Pull request checklist
7777

README.md

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
# FastAPI Api Key
22

3-
![Python Version from PEP 621 TOML](https://img.shields.io/python/required-version-toml?tomlFilePath=https%3A%2F%2Fraw.githubusercontent.com%2FAthroniaeth%2Ffastapi-api-key%2Fmain%2Fpyproject.toml)
3+
![Python Version from PEP 621 TOML](https://img.shields.io/python/required-version-toml?tomlFilePath=https%3A%2F%2Fraw.githubusercontent.com%2FAthroniaeth%2Fkeyshield%2Fmain%2Fpyproject.toml)
44
[![Tested with pytest](https://img.shields.io/badge/tests-pytest-informational.svg)](https://pytest.org/)
5-
[![PyPI version](https://img.shields.io/pypi/v/fastapi-api-key.svg)](https://pypi.org/project/fastapi-api-key/)
6-
[![Docs](https://img.shields.io/badge/docs-online-blue.svg)](https://athroniaeth.github.io/fastapi-api-key/)
7-
[![codecov](https://codecov.io/gh/Athroniaeth/fastapi-api-key/graph/badge.svg)](https://codecov.io/gh/Athroniaeth/fastapi-api-key)
5+
[![PyPI version](https://img.shields.io/pypi/v/keyshield.svg)](https://pypi.org/project/keyshield/)
6+
[![Docs](https://img.shields.io/badge/docs-online-blue.svg)](https://athroniaeth.github.io/keyshield/)
7+
[![codecov](https://codecov.io/gh/Athroniaeth/keyshield/graph/badge.svg)](https://codecov.io/gh/Athroniaeth/keyshield)
88
[![Security: bandit](https://img.shields.io/badge/security-bandit-yellow.svg)](https://bandit.readthedocs.io/)
99
[![Deps: uv](https://img.shields.io/badge/deps-managed%20with%20uv-3E4DD8.svg)](https://docs.astral.sh/uv/)
1010
[![Code style: Ruff](https://img.shields.io/badge/code%20style-ruff-4B32C3.svg)](https://docs.astral.sh/ruff/)
1111

12-
`fastapi-api-key` provides a backend-agnostic library that provides a production-ready, secure API key system, with optional FastAPI and Typer connectors.
12+
`keyshield` provides a backend-agnostic library that provides a production-ready, secure API key system, with optional FastAPI and Typer connectors.
1313

1414
## Links
1515

16-
- **Documentation:** [https://athroniaeth.github.io/fastapi-api-key/](https://athroniaeth.github.io/fastapi-api-key/)
17-
- **PyPI package:** [https://pypi.org/project/fastapi-api-key/](https://pypi.org/project/fastapi-api-key/)
16+
- **Documentation:** [https://athroniaeth.github.io/keyshield/](https://athroniaeth.github.io/keyshield/)
17+
- **PyPI package:** [https://pypi.org/project/keyshield/](https://pypi.org/project/keyshield/)
1818

1919
## Features
2020

@@ -41,8 +41,8 @@ This library try to follow best practices and relevant RFCs for API key manageme
4141
This project is not published to PyPI. Use a tool like [uv](https://docs.astral.sh/uv/) to manage dependencies.
4242

4343
```bash
44-
uv add fastapi-api-key
45-
uv pip install fastapi-api-key
44+
uv add keyshield
45+
uv pip install keyshield
4646
```
4747

4848
### Development installation
@@ -60,18 +60,18 @@ For lighter setups you can choose individual extras:
6060

6161
| Installation mode | Command | Description |
6262
|--------------------------------|-------------------------------|-----------------------------------------------------------------------------|
63-
| **Base installation** | `fastapi-api-key` | Installs the core package without any optional dependencies. |
64-
| **With Bcrypt support** | `fastapi-api-key[bcrypt]` | Adds support for password hashing using **bcrypt** |
65-
| **With Argon2 support** | `fastapi-api-key[argon2]` | Adds support for password hashing using **Argon2** |
66-
| **With SQLAlchemy support** | `fastapi-api-key[sqlalchemy]` | Adds database integration via **SQLAlchemy** |
67-
| **With Cache Service support** | `fastapi-api-key[aiocache]` | Adds database integration via **Aiocache** |
68-
| **Core setup** | `fastapi-api-key[core]` | Installs the **core dependencies** (SQLAlchemy + Argon2 + bcrypt + aiocache |
69-
| **FastAPI only** | `fastapi-api-key[fastapi]` | Installs **FastAPI** as an optional dependency |
70-
| **Full installation** | `fastapi-api-key[all]` | Installs **all optional dependencies** |
63+
| **Base installation** | `keyshield` | Installs the core package without any optional dependencies. |
64+
| **With Bcrypt support** | `keyshield[bcrypt]` | Adds support for password hashing using **bcrypt** |
65+
| **With Argon2 support** | `keyshield[argon2]` | Adds support for password hashing using **Argon2** |
66+
| **With SQLAlchemy support** | `keyshield[sqlalchemy]` | Adds database integration via **SQLAlchemy** |
67+
| **With Cache Service support** | `keyshield[aiocache]` | Adds database integration via **Aiocache** |
68+
| **Core setup** | `keyshield[core]` | Installs the **core dependencies** (SQLAlchemy + Argon2 + bcrypt + aiocache |
69+
| **FastAPI only** | `keyshield[fastapi]` | Installs **FastAPI** as an optional dependency |
70+
| **Full installation** | `keyshield[all]` | Installs **all optional dependencies** |
7171

7272
```bash
73-
uv add fastapi-api-key[sqlalchemy]
74-
uv pip install fastapi-api-key[sqlalchemy]
73+
uv add keyshield[sqlalchemy]
74+
uv pip install keyshield[sqlalchemy]
7575
uv sync --extra sqlalchemy
7676
uv pip install -e ".[sqlalchemy]"
7777
```
@@ -100,8 +100,8 @@ Install `make` via `sudo apt install make` on Debian/Ubuntu or `choco install ma
100100
```python
101101
import asyncio
102102

103-
from fastapi_api_key import ApiKeyService
104-
from fastapi_api_key.repositories.in_memory import InMemoryApiKeyRepository
103+
from keyshield import ApiKeyService
104+
from keyshield.repositories.in_memory import InMemoryApiKeyRepository
105105

106106

107107
async def main():
@@ -122,9 +122,9 @@ Override the default pepper in production:
122122

123123
```python
124124
import os
125-
from fastapi_api_key import ApiKeyService
126-
from fastapi_api_key.hasher.argon2 import Argon2ApiKeyHasher
127-
from fastapi_api_key.repositories.in_memory import InMemoryApiKeyRepository
125+
from keyshield import ApiKeyService
126+
from keyshield.hasher.argon2 import Argon2ApiKeyHasher
127+
from keyshield.repositories.in_memory import InMemoryApiKeyRepository
128128

129129
pepper = os.environ["SECRET_PEPPER"]
130130
hasher = Argon2ApiKeyHasher(pepper=pepper)
@@ -178,10 +178,10 @@ from typing import AsyncIterator
178178
from fastapi import FastAPI, Depends, APIRouter
179179
from sqlalchemy.ext.asyncio import create_async_engine, async_sessionmaker, AsyncSession
180180

181-
from fastapi_api_key import ApiKey, ApiKeyService
182-
from fastapi_api_key.hasher.argon2 import Argon2ApiKeyHasher
183-
from fastapi_api_key.repositories.sql import SqlAlchemyApiKeyRepository
184-
from fastapi_api_key.api import create_api_keys_router, create_depends_api_key
181+
from keyshield import ApiKey, ApiKeyService
182+
from keyshield.hasher.argon2 import Argon2ApiKeyHasher
183+
from keyshield.repositories.sql import SqlAlchemyApiKeyRepository
184+
from keyshield.api import create_api_keys_router, create_depends_api_key
185185

186186
# Set env var to override default pepper
187187
# Using a strong, unique pepper is crucial for security

docs/index.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
# FastAPI Api Key
22

3-
![Python Version from PEP 621 TOML](https://img.shields.io/python/required-version-toml?tomlFilePath=https%3A%2F%2Fraw.githubusercontent.com%2FAthroniaeth%2Ffastapi-api-key%2Fmain%2Fpyproject.toml)
3+
![Python Version from PEP 621 TOML](https://img.shields.io/python/required-version-toml?tomlFilePath=https%3A%2F%2Fraw.githubusercontent.com%2FAthroniaeth%2Fkeyshield%2Fmain%2Fpyproject.toml)
44
[![Tested with pytest](https://img.shields.io/badge/tests-pytest-informational.svg)](https://pytest.org/)
5-
[![PyPI version](https://img.shields.io/pypi/v/fastapi-api-key.svg)](https://pypi.org/project/fastapi-api-key/)
6-
[![Docs](https://img.shields.io/badge/docs-online-blue.svg)](https://athroniaeth.github.io/fastapi-api-key/)
7-
[![codecov](https://codecov.io/gh/Athroniaeth/fastapi-api-key/graph/badge.svg)](https://codecov.io/gh/Athroniaeth/fastapi-api-key)
5+
[![PyPI version](https://img.shields.io/pypi/v/keyshield.svg)](https://pypi.org/project/keyshield/)
6+
[![Docs](https://img.shields.io/badge/docs-online-blue.svg)](https://athroniaeth.github.io/keyshield/)
7+
[![codecov](https://codecov.io/gh/Athroniaeth/keyshield/graph/badge.svg)](https://codecov.io/gh/Athroniaeth/keyshield)
88
[![Security: bandit](https://img.shields.io/badge/security-bandit-yellow.svg)](https://bandit.readthedocs.io/)
99
[![Deps: uv](https://img.shields.io/badge/deps-managed%20with%20uv-3E4DD8.svg)](https://docs.astral.sh/uv/)
1010
[![Code style: Ruff](https://img.shields.io/badge/code%20style-ruff-4B32C3.svg)](https://docs.astral.sh/ruff/)
1111

12-
`fastapi-api-key` provides a backend-agnostic library that provides a production-ready, secure API key system, with optional FastAPI and Typer connectors.
12+
`keyshield` provides a backend-agnostic library that provides a production-ready, secure API key system, with optional FastAPI and Typer connectors.
1313

1414
## Links
1515

16-
- **Documentation:** [https://athroniaeth.github.io/fastapi-api-key/](https://athroniaeth.github.io/fastapi-api-key/)
17-
- **PyPI package:** [https://pypi.org/project/fastapi-api-key/](https://pypi.org/project/fastapi-api-key/)
16+
- **Documentation:** [https://athroniaeth.github.io/keyshield/](https://athroniaeth.github.io/keyshield/)
17+
- **PyPI package:** [https://pypi.org/project/keyshield/](https://pypi.org/project/keyshield/)
1818

1919
## Features
2020

docs/quickstart.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ This quickstart guide helps you set up the package and create your first API key
88
This project is published on PyPI. Use a tool like [uv](https://docs.astral.sh/uv/) to manage dependencies.
99

1010
```bash
11-
uv add fastapi-api-key
11+
uv add keyshield
1212
```
1313

1414
or using pip:
1515
```bash
16-
pip install fastapi-api-key
16+
pip install keyshield
1717
```
1818

1919
## 2. Create api key

docs/usage/database.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ This guide covers SQLAlchemy setup with aiosqlite for persistent API key storage
77
Install the SQLAlchemy extra:
88

99
```bash
10-
pip install fastapi-api-key[sqlalchemy]
10+
pip install keyshield[sqlalchemy]
1111
```
1212

1313
## Example

docs/usage/django.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Django Integration
22

3-
`fastapi-api-key` supports [Django](https://www.djangoproject.com/) 4.1+ via the
4-
`fastapi_api_key.django` package.
3+
`keyshield` supports [Django](https://www.djangoproject.com/) 4.1+ via the
4+
`keyshield.django` package.
55

66
The integration provides:
77

@@ -15,7 +15,7 @@ The integration provides:
1515
## Installation
1616

1717
```bash
18-
uv add fastapi_api_key[django]
18+
uv add keyshield[django]
1919
```
2020

2121
## Setup
@@ -26,24 +26,24 @@ Add the app to `INSTALLED_APPS` in your Django settings:
2626
# settings.py
2727
INSTALLED_APPS = [
2828
...
29-
"fastapi_api_key.django",
29+
"keyshield.django",
3030
]
3131
```
3232

3333
Then run migrations to create the `api_keys` table:
3434

3535
```bash
36-
python manage.py makemigrations fastapi_api_key_django
36+
python manage.py makemigrations keyshield_django
3737
python manage.py migrate
3838
```
3939

4040
## Quick start
4141

4242
```python
4343
# myapp/api_keys.py
44-
from fastapi_api_key.django import DjangoApiKeyRepository
45-
from fastapi_api_key.services.base import ApiKeyService
46-
from fastapi_api_key.hasher.argon2 import Argon2ApiKeyHasher
44+
from keyshield.django import DjangoApiKeyRepository
45+
from keyshield.services.base import ApiKeyService
46+
from keyshield.hasher.argon2 import Argon2ApiKeyHasher
4747

4848
async def get_service() -> ApiKeyService:
4949
return ApiKeyService(
@@ -57,7 +57,7 @@ Register the management endpoints in your URL configuration:
5757
```python
5858
# myapp/urls.py
5959
from django.urls import path, include
60-
from fastapi_api_key.django.urls import create_api_keys_urlpatterns
60+
from keyshield.django.urls import create_api_keys_urlpatterns
6161
from myapp.api_keys import get_service
6262

6363
urlpatterns = [
@@ -71,7 +71,7 @@ Use the `require_api_key` decorator on any async view:
7171

7272
```python
7373
from django.http import JsonResponse
74-
from fastapi_api_key.django.decorators import require_api_key
74+
from keyshield.django.decorators import require_api_key
7575
from myapp.api_keys import get_service
7676

7777
@require_api_key(svc_factory=get_service)
@@ -111,7 +111,7 @@ Django's `as_view(svc_factory=...)` pattern is used for dependency injection.
111111
You can wire up any service factory, including one backed by caching:
112112

113113
```python
114-
from fastapi_api_key.services.cached import CachedApiKeyService
114+
from keyshield.services.cached import CachedApiKeyService
115115

116116
async def get_service() -> CachedApiKeyService:
117117
return CachedApiKeyService(

docs/usage/litestar.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Litestar Integration
22

3-
`fastapi-api-key` provides first-class support for [Litestar](https://litestar.dev/) via
4-
`fastapi_api_key.litestar_api`. The integration exposes two helpers:
3+
`keyshield` provides first-class support for [Litestar](https://litestar.dev/) via
4+
`keyshield.litestar_api`. The integration exposes two helpers:
55

66
| Helper | Purpose |
77
|---|---|
@@ -11,17 +11,17 @@
1111
## Installation
1212

1313
```bash
14-
uv add fastapi_api_key[litestar]
14+
uv add keyshield[litestar]
1515
```
1616

1717
## Quick start
1818

1919
```python
2020
from litestar import Litestar
21-
from fastapi_api_key.litestar_api import create_api_keys_router, create_api_key_guard
22-
from fastapi_api_key.services.base import ApiKeyService
23-
from fastapi_api_key.repositories.in_memory import InMemoryApiKeyRepository
24-
from fastapi_api_key.hasher.argon2 import Argon2ApiKeyHasher
21+
from keyshield.litestar_api import create_api_keys_router, create_api_key_guard
22+
from keyshield.services.base import ApiKeyService
23+
from keyshield.repositories.in_memory import InMemoryApiKeyRepository
24+
from keyshield.hasher.argon2 import Argon2ApiKeyHasher
2525

2626
# Shared service provider (called once per request by Litestar DI)
2727
async def provide_svc() -> ApiKeyService:
@@ -41,7 +41,7 @@ app = Litestar(route_handlers=[mgmt_router])
4141
```python
4242
from litestar import Litestar, get
4343
from litestar.connection import Request
44-
from fastapi_api_key.litestar_api import create_api_key_guard
44+
from keyshield.litestar_api import create_api_key_guard
4545

4646
guard = create_api_key_guard(provide_svc=provide_svc)
4747

@@ -93,7 +93,7 @@ lifecycle handles session management transparently:
9393

9494
```python
9595
from sqlalchemy.ext.asyncio import AsyncSession, create_async_engine, async_sessionmaker
96-
from fastapi_api_key.repositories.sql import SqlAlchemyApiKeyRepository, Base
96+
from keyshield.repositories.sql import SqlAlchemyApiKeyRepository, Base
9797

9898
engine = create_async_engine("postgresql+asyncpg://user:pass@localhost/db")
9999
SessionLocal = async_sessionmaker(engine, class_=AsyncSession, expire_on_commit=False)
@@ -107,11 +107,11 @@ async def provide_svc() -> ApiKeyService:
107107

108108
## Caching
109109

110-
The `CachedApiKeyService` from `fastapi_api_key.services.cached` works
110+
The `CachedApiKeyService` from `keyshield.services.cached` works
111111
identically in Litestar:
112112

113113
```python
114-
from fastapi_api_key.services.cached import CachedApiKeyService
114+
from keyshield.services.cached import CachedApiKeyService
115115

116116
async def provide_svc() -> CachedApiKeyService:
117117
return CachedApiKeyService(

0 commit comments

Comments
 (0)