Skip to main content

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 token
  • POST /token/verify — Verify token validity
  • POST /token/revoke — Revoke a token by name
  • GET /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

  1. Update your database URL in db.py:
DATABASE_URL = "postgresql+asyncpg://user:password@localhost/tokenkeeper"
  1. 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>"]
  1. 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

tokenkeeper_api-0.0.3.tar.gz (11.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tokenkeeper_api-0.0.3-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

Details for the file tokenkeeper_api-0.0.3.tar.gz.

File metadata

  • Download URL: tokenkeeper_api-0.0.3.tar.gz
  • Upload date:
  • Size: 11.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for tokenkeeper_api-0.0.3.tar.gz
Algorithm Hash digest
SHA256 dd07982c3d31de3f1cdb47f0ed25451e1f847d874ebfc2d97053a01d76d0a452
MD5 42afe11405b7149c98049a47cdf951ec
BLAKE2b-256 bf37b32c26aba08d06e64c3ec0b3a46e95455aac280cf045b320694f4904d387

See more details on using hashes here.

File details

Details for the file tokenkeeper_api-0.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for tokenkeeper_api-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 0114a1c9fce55fed16177aef55062334e85e81b214f2427dba2b9577a02ee501
MD5 bd52431bf0d5e734d104ab7799c391e9
BLAKE2b-256 8d8e692e1b21d6c0e68797c6a65a5574f4191674092aed85bd042dd856bdd1d8

See more details on using hashes here.

Supported by

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