pass the oauth2 token to the fastapi Security
This commit is contained in:
parent
a39cdb93ee
commit
5686a6fd63
1 changed files with 1 additions and 2 deletions
|
|
@ -70,13 +70,12 @@ async def api_key_security(
|
||||||
|
|
||||||
|
|
||||||
async def get_current_user(
|
async def get_current_user(
|
||||||
request: Request,
|
token: str = Security(oauth2_login),
|
||||||
query_param: str = Security(api_key_query),
|
query_param: str = Security(api_key_query),
|
||||||
header_param: str = Security(api_key_header),
|
header_param: str = Security(api_key_header),
|
||||||
db: Session = Depends(get_session),
|
db: Session = Depends(get_session),
|
||||||
) -> User:
|
) -> User:
|
||||||
try:
|
try:
|
||||||
token = oauth2_login(request)
|
|
||||||
return await get_current_user_by_jwt(token, db)
|
return await get_current_user_by_jwt(token, db)
|
||||||
except HTTPException:
|
except HTTPException:
|
||||||
user = await api_key_security(query_param, header_param, db)
|
user = await api_key_security(query_param, header_param, db)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue