A minimal FastAPI service for creating, verifying, and revoking user-scoped API tokens. Uses Argon2 hashing and PostgreSQL for secure token management.
Project description
TokenKeeper API
TokenKeeper is a secure, FastAPI-based service for managing and verifying personal access tokens. It integrates with AWS Cognito for user authentication and uses PostgreSQL for persistent storage. Tokens are hashed with Argon2 and optionally support expiration, revocation, and last-used tracking.
Features
- 🔐 Secure token generation using Argon2 hashing
- 📅 Optional token expiration and usage tracking
- ✅ Verification and revocation of tokens
- 🧾 List non-revoked, non-expired tokens
- 🪪 Cognito-based user authentication
- 🗃️ PostgreSQL + SQLAlchemy (async) backend
API Endpoints
POST /token— Create a new tokenPOST /token/verify— Verify token validityPOST /token/revoke— Revoke a token by nameGET /token— List current user’s active tokens
Requirements
- Python 3.12+
- PostgreSQL
- AWS Cognito User Pool
asyncpg,sqlalchemy,fastapi,passlib[argon2],cognito-jwt-verifier
Getting Started
- Update your database URL in db.py:
DATABASE_URL = "postgresql+asyncpg://user:password@localhost/tokenkeeper"
- Set up your Cognito issuer and client ID in auth.py:
ISSUER = "https://cognito-idp.<region>.amazonaws.com/<user_pool_id>"
CLIENT_IDS = ["<app_client_id>"]
- Run the FastAPI app:
uvicorn tokenkeeper.main:app --reload
License
MIT
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
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 tokenkeeper_api-0.0.1.tar.gz.
File metadata
- Download URL: tokenkeeper_api-0.0.1.tar.gz
- Upload date:
- Size: 11.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f4171a3d0795fab8adf54ac964b4147cde8662187133c66bedb5e9716baa1051
|
|
| MD5 |
6e978f917e50a19d63f81717c22df682
|
|
| BLAKE2b-256 |
285b76b465dafb8824db9e3c6940d99d3c1217a9f39b3055847450c479751266
|
File details
Details for the file tokenkeeper_api-0.0.1-py3-none-any.whl.
File metadata
- Download URL: tokenkeeper_api-0.0.1-py3-none-any.whl
- Upload date:
- Size: 9.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7b304e7283023b711d43168c2347786d20748a147b9443f73275dddde2ba4fd6
|
|
| MD5 |
6c0e0c3c26e130591a2252050e6429f6
|
|
| BLAKE2b-256 |
8f12c9149803d0508f78284d91a93a82ed126f406f152adba7ffdf21f35f0151
|