Skip to main content

FastAuth

OAuth2 library for FastAPI.

Current providers

  • Google
  • GitHub
  • Reddit
  • Discord
  • Spotify

Setup

This setup currently works, but up for change, since this project is still under development

from fastapi import FastAPI

from dotenv import load_dotenv
from os import getenv

from autheon.libtypes import UserInfo, FallbackSecrets

from autheon.jwts.helpers import generate_secret
from autheon.oauth2_options import OAuthOptions
from autheon.providers.google.google import Google

from autheon.adapters.fastapi.csrf_middleware import CSRFMitigationMiddleware

load_dotenv()


# What happens when someone logs in
async def push_to_db(user_info: UserInfo) -> None:
    with open("my_db", "w") as f:
        f.write(user_info["name"])


# One router takes care of everything
auth = OAuthOptions(
    debug=True,
    provider=Google(
        client_id=getenv("GOOGLE_CLIENT_ID"),
        client_secret=getenv("GOOGLE_CLIENT_SECRET"),
        redirect_uri=getenv("GOOGLE_REDIRECT_URI"),
    ),
    signin_callback=push_to_db,
    fallback_secrets=FallbackSecrets(
        secret_1=getenv("SECRET"),
        secret_2=generate_secret(),
        secret_3=generate_secret(),
        secret_4=generate_secret(),
        secret_5=generate_secret(),
    ),
)

app = FastAPI()
# Plug in the router
app.include_router(auth)

# Optional for OAuth flow, but highly recommended
app.add_middleware(CSRFMitigationMiddleware)

Usage

@app.get("/auth/in")
def logged():
    return "youre in"

@app.get("/auth/out")
def out():
    return "out"

Development setup

Checkout justfile

License

MIT

Metadata

Release files for autheon 0.0.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 autheon 0.0.0
File Size Uploaded Provenance Actions
autheon-0.0.0.tar.gz 15.5 kB Without provenance Details for autheon-0.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for autheon 0.0.0
File Interpreter ABI Platform Actions
autheon-0.0.0-py3-none-any.whl Python 3 none any Details for autheon-0.0.0-py3-none-any.whl

Total release size: 39.5 kB

Release files / autheon-0.0.0.tar.gz

Download URL autheon-0.0.0.tar.gz
Size 15.5 kB
Tags Source
SHA-256 checksum
How to use checksums
5e9c085b189c17e6a4ea48a5a853fb4c4591a234682cafc741b67dd6535f48df
BLAKE2b-256 checksum
How to use checksums
d7a8b4580252f3de332466d10ebc2efc191c7070edf67261065d35de682a21c2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.0.1 CPython/3.11.11 Linux/6.8.0-1020-azure

Release files / autheon-0.0.0-py3-none-any.whl

Download URL autheon-0.0.0-py3-none-any.whl
Size 24.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d7072c92dc5969c8b8f028ac4b3eecce85b9679cc6bc376c1ce7d5a88782ed98
BLAKE2b-256 checksum
How to use checksums
d02c8afc723381271ec250cd0c5ece502ebd343bac33925a939feca7bccd56cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.0.1 CPython/3.11.11 Linux/6.8.0-1020-azure

Security for autheon 0.0.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.0.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