myq*_* sh 6 single-sign-on saml-2.0 okta fastapi
我正在编写一个 fastapi Web 应用程序,它使用 OKTA iDP 和 SAML 2.0 SSO 进行身份验证。我想在网络应用程序中保护我的 API。我知道 fastapi 仅具有基于 Oauth2/token 的 API 保护,而不是基于 cookie 或会话的保护。但是,在身份验证成功后,我们仅从 IDP 收到会话信息(会话索引)。如何使用此会话索引信息来保护 Web 应用程序中的 api?有什么方法可以将接收到的会话转换为令牌并将其保存在 fastapi 应用程序中以用于保护吗?或者请建议我其他方式?
from fastapi import FastAPI
app = FastAPI()
@app.login("/sso/login")
async def login():
# got sessionindex from Okta IDP
return session
@app.logout("/sso/logout")
async def logout():
# delete session received from Okta IDP on logout
return
@app.get_graph() <----------------------
async def get_graph():
# how can i protect this api. so that i can access only
# on successful authentication?
return
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
824 次 |
| 最近记录: |