Skip to content

Commit

Permalink
fix: Properly handle jwt bearer call value
Browse files Browse the repository at this point in the history
  • Loading branch information
dominik003 committed Oct 16, 2023
1 parent edac1cf commit cf93dac
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ async def api_refresh_token(body: RefreshTokenRequest):


@router.delete("/tokens", name="Invalidate the token (log out)")
async def logout(jwt_decoded=fastapi.Depends(JWTBearer())):
username, _ = jwt_decoded
async def logout(username: str = fastapi.Depends(JWTBearer())):
for account in ad_session().get_accounts():
if account["username"] == username:
return ad_session().remove_account(account)
Expand All @@ -97,10 +96,9 @@ async def logout(jwt_decoded=fastapi.Depends(JWTBearer())):
@router.get("/tokens", name="Validate the token")
async def validate_token(
scope: Role | None,
jwt_information=fastapi.Depends(JWTBearer()),
username: str = fastapi.Depends(JWTBearer()),
db: orm.Session = fastapi.Depends(database.get_db),
):
username, _ = jwt_information
if scope and scope.ADMIN:
auth_injectables.RoleVerification(required_role=Role.ADMIN)(
username, db
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,9 @@ async def logout():
@router.get("/tokens", name="Validate the token")
async def validate_token(
scope: Role | None,
jwt_information=fastapi.Depends(JWTBearer()),
username: str = fastapi.Depends(JWTBearer()),
db: orm.Session = fastapi.Depends(database.get_db),
):
username, _ = jwt_information
if scope and scope.ADMIN:
auth_injectables.RoleVerification(required_role=Role.ADMIN)(
username, db
Expand Down

0 comments on commit cf93dac

Please sign in to comment.