Add logout and fixed user specific requirements retrieval
This commit is contained in:
@@ -126,13 +126,25 @@ class AuthController:
|
||||
@staticmethod
|
||||
def logout() -> JSONResponse:
|
||||
"""
|
||||
Logout the user by clearing the authentication cookie.
|
||||
Logout the user by clearing the authentication cookie and returning
|
||||
the Keycloak logout URL for full session termination.
|
||||
|
||||
Returns:
|
||||
JSONResponse: Success message with cookie cleared.
|
||||
JSONResponse: Contains the Keycloak logout URL and clears the cookie.
|
||||
"""
|
||||
# Build Keycloak logout URL
|
||||
keycloak_logout_url = (
|
||||
f"{settings.keycloak_external_url}realms/{settings.keycloak_realm}"
|
||||
f"/protocol/openid-connect/logout"
|
||||
f"?client_id={settings.keycloak_client_id}"
|
||||
f"&post_logout_redirect_uri={settings.frontend_url}"
|
||||
)
|
||||
|
||||
response = JSONResponse(
|
||||
content={"message": "Successfully logged out"},
|
||||
content={
|
||||
"message": "Successfully logged out",
|
||||
"logout_url": keycloak_logout_url
|
||||
},
|
||||
status_code=status.HTTP_200_OK
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user