Skip to content

Commit

Permalink
Added an optional callback_url to the logout route
Browse files Browse the repository at this point in the history
  • Loading branch information
dudil committed Dec 4, 2023
1 parent 87e56e7 commit 2669da4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions fastapi_msal/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,12 @@ async def _post_token_route(
token: AuthToken = await self.handler.authorize_access_token(request=request, code=code, state=state)
return BearerToken(access_token=token.id_token)

async def _logout_route(self, request: Request, referer: Annotated[OptStr, Header()] = None) -> RedirectResponse:
callback_url = referer if referer else str(self.return_to_path)
async def _logout_route(
self, request: Request, callback_url: OptStr, referer: Annotated[OptStr, Header()] = None
) -> RedirectResponse:
# check if callback_url is set, if not try to get it from referer header
if not callback_url:
callback_url = referer if referer else str(self.return_to_path)
return self.handler.logout(request=request, callback_url=callback_url)

async def get_session_token(self, request: Request) -> Optional[AuthToken]:
Expand Down

0 comments on commit 2669da4

Please sign in to comment.