Skip to main content

FastAPI plugin to enable SSO to most common providers (such as Facebook login, Google login and login via Microsoft Office 365 Account)

Project description

FastAPI SSO

Supported Python Versions Test coverage Tests Workflow Status Lint Workflow Status Mypy Workflow Status Black Workflow Status CodeQL Workflow Status PyPi weekly downloads Project License PyPi Version

FastAPI 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

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 Notice

Version 0.16.0 Update: Race Condition Bug Fix & Context Manager Change

A race condition bug in the login flow that could, in rare cases, allow one user to assume the identity of another due to concurrent login requests was recently discovered by @parikls. This issue was reported in #186 and has been resolved in version 0.16.0.

Details of the Fix:

The bug was mitigated by introducing an async lock mechanism that ensures only one user can attempt the login process at any given time. This prevents race conditions that could lead to unintended user identity crossover.

Important Change:

To fully support this fix, users must now use the SSO instance within an async with context manager. This adjustment is necessary for proper handling of asynchronous operations.

The synchronous with context manager is now deprecated and will produce a warning. It will be removed in future versions to ensure best practices for async handling.

Impact:

This bug could potentially affect deployments with high concurrency or scenarios where multiple users initiate login requests simultaneously. To prevent potential issues and deprecation warnings, update to version 0.16.0 or later and modify your code to use the async with context.

Code Example Update:

# Before (deprecated)
with sso:
    openid = await sso.verify_and_process(request)

# After (recommended)
async with sso:
    openid = await sso.verify_and_process(request)

Thanks to both @parikls and the community for helping me identify and improve the security of fastapi-sso. If you encounter any issues or potential vulnerabilities, please report them immediately so they can be addressed.

For more details, refer to Issue #186 and PR #189.

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 😉.

Buy Me A Coffee

Supported login providers

Official

  • Google
  • Microsoft
  • Facebook
  • Spotify
  • Fitbit
  • Github (credits to Brandl for hint using accept header)
  • generic (see docs)
  • Notion
  • Twitter (X)

Contributed

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fastapi_sso-0.17.0.tar.gz (17.2 kB view details)

Uploaded Source

Built Distribution

fastapi_sso-0.17.0-py3-none-any.whl (25.9 kB view details)

Uploaded Python 3

File details

Details for the file fastapi_sso-0.17.0.tar.gz.

File metadata

  • Download URL: fastapi_sso-0.17.0.tar.gz
  • Upload date:
  • Size: 17.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.11.10 Linux/6.5.0-1025-azure

File hashes

Hashes for fastapi_sso-0.17.0.tar.gz
Algorithm Hash digest
SHA256 fa0e46a2a935999ea98874669c1925f4ef02d023d95ed703c8b126419275c627
MD5 c7a39540d1c5453a4291d4e113fb75ea
BLAKE2b-256 917b6f3c6ca695e5850ebbea7b5c31f3a85eab6da8d54db4a5fe2a20cc4fd70b

See more details on using hashes here.

File details

Details for the file fastapi_sso-0.17.0-py3-none-any.whl.

File metadata

  • Download URL: fastapi_sso-0.17.0-py3-none-any.whl
  • Upload date:
  • Size: 25.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.11.10 Linux/6.5.0-1025-azure

File hashes

Hashes for fastapi_sso-0.17.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5acadc7e46d7a9bd7974c7046c472048dc93fb2bf7b2d496550c012fc98d0f0f
MD5 552127d76e70fab7db601705ed9803d3
BLAKE2b-256 e1baddf5c2d7fafb503d64765b485518ad5cd49a08dfab39bdb3500d494f10f5

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page