Skip to main content

IA Auth Sessions

Standard session-based authentication for FastAPI applications using secure signed cookies.

Features

  • Signed Cookies: HMAC-SHA256 via itsdangerous prevents tampering
  • Bcrypt Password Hashing: Industry standard with automatic salt generation via pwdlib
  • Python 3.13+ Ready: Uses modern pwdlib instead of deprecated passlib
  • Secure Cookie Flags: HttpOnly, Secure, SameSite protection
  • Session Management: Create, validate, destroy, and auto-cleanup
  • Database Agnostic: PostgreSQL and SQLite via NexusQL
  • WebSocket Support: Authenticate WebSocket connections

Available Routes

  • POST /auth/register - Register new user
  • POST /auth/login - Login and create session
  • POST /auth/logout - Logout and destroy session
  • GET /auth/me - Get current user info
  • POST /auth/logout-all - Logout from all devices

Installation

pip install ia-auth-sessions

For local development:

pip install -e ../ia_auth_sessions

Publishing

See PUBLISHING.md for instructions on publishing to PyPI.

To test the build locally:

python test_publish.py --skip-tests

Quick Start

from fastapi import FastAPI, Depends
from ia_auth_sessions import SessionMiddleware, get_current_user
from ia_auth_sessions.routes import router as auth_router

app = FastAPI()

# Add middleware and routes
app.add_middleware(SessionMiddleware, secret_key="your-secret-key", ...)
app.include_router(auth_router)

# Protected route
@app.get("/protected")
async def protected(user: dict = Depends(get_current_user)):
    return {"message": f"Hello {user['username']}!"}

See USAGE.md for complete setup instructions.

Documentation

Database Schema

Automatically creates:

  • users: User accounts with bcrypt-hashed passwords
  • sessions: Active sessions with metadata and expiry timestamps

License

MIT

Metadata

Release files for ia-auth-sessions 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ia-auth-sessions 0.1.0
File Size Uploaded Provenance
ia_auth_sessions-0.1.0.tar.gz 17.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for ia-auth-sessions 0.1.0
File Interpreter ABI Platform
ia_auth_sessions-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 34.2 kB

Release files / ia_auth_sessions-0.1.0.tar.gz

Download URL ia_auth_sessions-0.1.0.tar.gz
Size 17.6 kB
Tags Source
SHA-256 checksum
How to use checksums
a5c2f1dbb909dc45b3416a69939b314fab503de28713f5918ce27469cd30abe2
BLAKE2b-256 checksum
How to use checksums
64bfa04f368e2adcac8849684e758b84f92df226cab9534288b21686c43a9b3f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.14

Release files / ia_auth_sessions-0.1.0-py3-none-any.whl

Download URL ia_auth_sessions-0.1.0-py3-none-any.whl
Size 16.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2600d734376a7508b29e4c257776c2762cc5b991a33adb78aa5fb429b3fec93b
BLAKE2b-256 checksum
How to use checksums
62b964307b7726f92b0581fff3fa808ba7d5029bfc39e718093c17738b83079b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.14

Security for ia-auth-sessions 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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page