Litestar SSO
Litestar plugin to enable SSO to most common providers (such as Facebook login, Google login and login via Microsoft Office 365 account).
This allows you to implement the famous Login with Google/Facebook/Microsoft buttons functionality on your
backend very easily.
Documentation: https://tomasvotava.github.io/fastapi-sso/
Source Code: https://github.com/tomasvotava/fastapi-sso
Example:
import os
from litestar import Litestar, Request, get
from litestar_sso import GoogleSSO
CLIENT_ID = os.environ["CLIENT_ID"]
CLIENT_SECRET = os.environ["CLIENT_SECRET"]
app = Litestar()
sso = GoogleSSO(
client_id=CLIENT_ID,
client_secret=CLIENT_SECRET,
redirect_uri="http://localhost:5000/auth/callback",
allow_insecure_http=True,
)
@get("/auth/login")
async def auth_init():
"""Initialize auth and redirect"""
async with sso:
return await sso.get_login_redirect(params={"prompt": "consent", "access_type": "offline"})
@get("/auth/callback")
async def auth_callback(request: Request):
"""Verify login"""
async with sso:
user = await sso.verify_and_process(request)
return user
Demo site
An awesome demo site was created and is maintained by even awesomer Chris Karvouniaris (@chrisK824). Chris has also posted multiple Medium articles about FastAPI and FastAPI SSO.
Be sure to see his tutorials, follow him and show him some appreciation!
Please see his announcement with all the links.
Quick links for the eager ones:
Security warning
Please note that versions preceding 0.7.0 had a security vulnerability.
The SSO instance could share state between requests, which could lead to security issues.
Please update to 0.7.0 or newer.
Also, the preferred way of using the SSO instances is to use with statement, which will ensure the state is cleared.
See example below.
Support this project
If you'd like to support this project, consider buying me a coffee ☕. I tend to process Pull Requests faster when properly caffeinated 😉.
Supported login providers
Official
- Microsoft
- Spotify
- Fitbit
- Github (credits to Brandl for hint using
acceptheader) - generic (see docs)
- Notion
- Twitter (X)
Contributed
- Kakao (by Jae-Baek Song - thdwoqor)
- Naver (by 1tang2bang92) - 1tang2bang92
- Gitlab (by Alessandro Pischedda) - Cereal84
- Line (by Jimmy Yeh) - jimmyyyeh
- LinkedIn (by Alessandro Pischedda) - Cereal84
- Yandex (by Akim Faskhutdinov) – akimrx
- Seznam (by Tomas Koutek) - TomasKoutek
See Contributing for a guide on how to contribute your own login provider.
Installation
Install using pip
pip install fastapi-sso
Install using poetry
poetry add fastapi-sso
Contributing
If you'd like to contribute and add your specific login provider, please see Contributing file.
Metadata
Release files for litestar-sso 0.20.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 | Actions |
|---|---|---|---|---|
| litestar_sso-0.20.0.tar.gz | 26.2 kB | Without provenance | Details for litestar_sso-0.20.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| litestar_sso-0.20.0-py3-none-any.whl | Python 3 | none | any | Details for litestar_sso-0.20.0-py3-none-any.whl |
Total release size: 79.4 kB
Release files / litestar_sso-0.20.0.tar.gz
| Download URL | litestar_sso-0.20.0.tar.gz |
|---|---|
| Size | 26.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
da6d495eb131876b07515ea39b04bc4a7f5e5ae700c831eb3c1336e5005fcd9a
|
|
BLAKE2b-256 checksum How to use checksums |
868f44af67f0d9f1625c7c2e3c36d1bebda41bb795fe6e183c977f538d35ec95
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.3.2 CPython/3.12.13 Linux/6.17.0-1008-azure
|
Release files / litestar_sso-0.20.0-py3-none-any.whl
| Download URL | litestar_sso-0.20.0-py3-none-any.whl |
|---|---|
| Size | 53.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0d7ab8e785b7d53866f4caa64921afce42b15c23798b32a8073fb1302fc85687
|
|
BLAKE2b-256 checksum How to use checksums |
435c10d9659b5efecef7c945afaba8a27dc53229d380757d096c6794af9f16fc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.3.2 CPython/3.12.13 Linux/6.17.0-1008-azure
|
Security for litestar-sso 0.20.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.