All Projects → tomasvotava → fastapi-sso

tomasvotava / fastapi-sso

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

Programming Languages

python
139335 projects - #7 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to fastapi-sso

angular5-social-login
Social authentication module for Angular 5. Includes Facebook and Google login with AOT compatibility.
Stars: ✭ 40 (+110.53%)
Mutual labels:  facebook-authentication, google-authentication
Simple-Blog-App
Simple Blog application in Android completely based on Firebase using Firebase-RealTimeDB, Firebase-Auth, Firebase-Storage, Firebase-CloudMessaging, Firebase-AdMob
Stars: ✭ 21 (+10.53%)
Mutual labels:  facebook-authentication, google-authentication
fastapi-auth0
FastAPI authentication and authorization using auth0.com
Stars: ✭ 104 (+447.37%)
Mutual labels:  fastapi
fastapi-camelcase
Package for providing a class for camelizing request and response bodies for fastapi while keeping your python code snake cased.
Stars: ✭ 45 (+136.84%)
Mutual labels:  fastapi
yomomma-apiv2
REST-API using FastAPI for Python that gives a 'yo momma' joke
Stars: ✭ 30 (+57.89%)
Mutual labels:  fastapi
fast-api-sqlalchemy-template
Dockerized web application on FastAPI, sqlalchemy1.4, PostgreSQL
Stars: ✭ 25 (+31.58%)
Mutual labels:  fastapi
next-postgres
A minimal example web application using NextJS 12.0.7, Postgres 11, Google OAuth2 and other useful libraries.
Stars: ✭ 72 (+278.95%)
Mutual labels:  google-authentication
todo-list
A practical web application built with Node.js, Express, and MySQL for you to readily record, view, and manage your tasks with an account: Create, view, edit, delete, filter, and sort expenses are as easy as pie 🥧
Stars: ✭ 18 (-5.26%)
Mutual labels:  facebook-authentication
fastapi-users
Ready-to-use and customizable users management for FastAPI
Stars: ✭ 1,920 (+10005.26%)
Mutual labels:  fastapi
django-fastapi-docs
Django、FastAPI、MySQL、Mongodb、Redis、Devops、Nginx、Vue、Docker、Supervisor、Celery
Stars: ✭ 41 (+115.79%)
Mutual labels:  fastapi
pydantic-i18n
pydantic-i18n is an extension to support an i18n for the pydantic error messages.
Stars: ✭ 32 (+68.42%)
Mutual labels:  fastapi
fastapi-mvc
Developer productivity tool for making high-quality FastAPI production-ready APIs.
Stars: ✭ 131 (+589.47%)
Mutual labels:  fastapi
codeX
CodeX is a platform which converts code into easy to understand language.
Stars: ✭ 46 (+142.11%)
Mutual labels:  fastapi
fastapi-starter
A FastAPI based low code starter: Async SQLAlchemy, Postgres, React-Admin, pytest and cypress
Stars: ✭ 97 (+410.53%)
Mutual labels:  fastapi
fastapi-framework
A FastAPI Framework for things like Database, Redis, Logging, JWT Authentication, Rate Limits and Sessions
Stars: ✭ 26 (+36.84%)
Mutual labels:  fastapi
templates
Templates for Intility developers.
Stars: ✭ 31 (+63.16%)
Mutual labels:  fastapi
ZeroToHeroDaprCon
Demos from my Zero to Hero with Dapr session @ DaprCon
Stars: ✭ 36 (+89.47%)
Mutual labels:  fastapi
Stack-Lifecycle-Deployment
OpenSource self-service infrastructure solution that defines and manages the complete lifecycle of resources used and provisioned into a cloud! It is a terraform UI with rest api for terraform automation
Stars: ✭ 88 (+363.16%)
Mutual labels:  fastapi
fastapi-zeit-now
A simple example of deploying FastAPI as a Zeit Serverless Function
Stars: ✭ 24 (+26.32%)
Mutual labels:  fastapi
fastrates
💵 Free & open source API service for current and historical foreign exchange rates.
Stars: ✭ 26 (+36.84%)
Mutual labels:  fastapi

FastAPI SSO

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.

Installation

Install using pip

pip install fastapi-sso

Install using poetry

poetry add fastapi-sso

Example

example.py

"""This is an example usage of fastapi-sso.
"""

from fastapi import FastAPI
from starlette.requests import Request
from fastapi_sso.sso.google import GoogleSSO

app = FastAPI()

google_sso = GoogleSSO("my-client-id", "my-client-secret", "https://my.awesome-web.com/google/callback")


@app.get("/google/login")
async def google_login():
    """Generate login url and redirect"""
    return await google_sso.get_login_redirect()


@app.get("/google/callback")
async def google_callback(request: Request):
    """Process login response from Google and return user info"""
    user = await google_sso.verify_and_process(request)
    return {
        "id": user.id,
        "picture": user.picture,
        "display_name": user.display_name,
        "email": user.email,
        "provider": user.provider,
    }

Run using uvicorn example:app.

HTTP and development

You should always use https in production. But in case you need to test on localhost and do not want to use self-signed certificate, make sure you set up redirect uri within your SSO provider to http://localhost:{port} and then add this to your environment:

OAUTHLIB_INSECURE_TRANSPORT=1

And make sure you pass allow_insecure_http = True to SSO class' constructor, such as:

google_sso = GoogleSSO("client-id", "client-secret", "callback-url", allow_insecure_http=True)

See this issue for more information.

State

State is used in OAuth to make sure server is responding to the request we send. It may cause you trouble as fastsapi-sso actually saves the state content as a cookie and attempts reading upon callback and this may fail (e.g. when loging in from different domain then the callback is landing on). If this is your case, you may want to disable state checking by passing use_state = False in SSO class's constructor, such as:

google_sso = GoogleSSO("client-id", "client-secret", "callback-url", use_state=False)

See more on state here.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].