Auth Backend Module
Reusable FastAPI authentication backend module with JWT tokens and OAuth support.
Features
- ✅ Email/password registration and login
- ✅ Google OAuth integration
- ✅ JWT access and refresh tokens
- ✅ Token refresh with rotation
- ✅ Secure password hashing (bcrypt)
- ✅ PostgreSQL database with SQLAlchemy
- ✅ Token revocation on logout
Installation
# Using Poetry
poetry add path/to/auth-backend
# Using pip
pip install -e path/to/auth-backend
Usage
from fastapi import FastAPI
from auth_backend import auth_router, init_db
app = FastAPI()
# Initialize database
init_db("postgresql://user:password@localhost/dbname")
# Include auth routes
app.include_router(auth_router, prefix="/auth", tags=["auth"])
API Endpoints
POST /auth/register- Register new userPOST /auth/login- Login with email/passwordPOST /auth/google- Login with Google OAuthPOST /auth/refresh- Refresh access tokenPOST /auth/logout- Logout (revoke refresh token)GET /auth/me- Get current user info
Environment Variables
DATABASE_URL=postgresql://user:password@localhost/dbname
SECRET_KEY=your-secret-key-here
Database Models
- User - User accounts
- RefreshToken - JWT refresh tokens
- OAuthAccount - OAuth provider accounts
Security Notes
⚠️ Important: Change the SECRET_KEY in security.py for production use!
Metadata
Release files for auth-backend 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| auth_backend-0.1.0.tar.gz | 6.1 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| auth_backend-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 14.2 kB
Release files / auth_backend-0.1.0.tar.gz
| Download URL | auth_backend-0.1.0.tar.gz |
|---|---|
| Size | 6.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b58f107a57d002e57b36a095514f55ab05d2d81a9a405f7fdcaf733acec88003
|
|
BLAKE2b-256 checksum How to use checksums |
51a6a6ca0578e0ffc325074e8159e6c37a82f8cddaccfdb00c6bdbb9fd6cb1e7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.2.1 CPython/3.14.0 Windows/11
|
Release files / auth_backend-0.1.0-py3-none-any.whl
| Download URL | auth_backend-0.1.0-py3-none-any.whl |
|---|---|
| Size | 8.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7d2cb1a7dc0baf2d6351d1ec7223b578f1a4ec3e129af76453ebd23fcd111112
|
|
BLAKE2b-256 checksum How to use checksums |
3aa98078c0b7acd5f35f52057004257a216e4ee03faa5d8af548178fa89df265
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.2.1 CPython/3.14.0 Windows/11
|
Security for auth-backend 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.