Facebook,Google,Microsoft,github 等单点登录sso插件,类似于国内社会化登录插件
天问 9d63c3823e Update 'README.md' | 8 months ago | |
---|---|---|
README.md | 8 months ago |
Facebook,Google,Microsoft,github 等单点登录sso插件,类似于国内社会化登录插件,注意安装最新版本!
pip install fastapi-sso
from fastapi import FastAPI
from fastapi_sso import SSO
from fastapi_sso.sso.github import GithubSSO
app = FastAPI()
sso = SSO()
@app.get("/login")
def login():
# 使用 SSO 实例
with sso:
# 执行登录逻辑
# ...
@app.get("/protected")
def protected():
# 验证登录状态
if sso.is_authenticated():
return {"message": "Welcome to the protected area!"}
else:
return {"message": "Please log in first."}