OAuth2 3rd party integration libray for your favorite framework
Project description
FastAuth
OAuth2 library for FastAPI.
Current providers
- GitHub
- 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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
autheon-0.0.0.tar.gz
(15.5 kB
view details)
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
autheon-0.0.0-py3-none-any.whl
(24.0 kB
view details)
File details
Details for the file autheon-0.0.0.tar.gz.
File metadata
- Download URL: autheon-0.0.0.tar.gz
- Upload date:
- Size: 15.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.0.1 CPython/3.11.11 Linux/6.8.0-1020-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5e9c085b189c17e6a4ea48a5a853fb4c4591a234682cafc741b67dd6535f48df
|
|
| MD5 |
a05f8fa6638c547d5c1a9d90d77b9813
|
|
| BLAKE2b-256 |
d7a8b4580252f3de332466d10ebc2efc191c7070edf67261065d35de682a21c2
|
File details
Details for the file autheon-0.0.0-py3-none-any.whl.
File metadata
- Download URL: autheon-0.0.0-py3-none-any.whl
- Upload date:
- Size: 24.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.0.1 CPython/3.11.11 Linux/6.8.0-1020-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d7072c92dc5969c8b8f028ac4b3eecce85b9679cc6bc376c1ce7d5a88782ed98
|
|
| MD5 |
7e86efbe9aa405f2d2a1260d1c674902
|
|
| BLAKE2b-256 |
d02c8afc723381271ec250cd0c5ece502ebd343bac33925a939feca7bccd56cc
|