Add logout and fixed user specific requirements retrieval

This commit is contained in:
gulimabr
2025-11-30 19:24:06 -03:00
parent eb70598cab
commit 67efbfd317
4 changed files with 148 additions and 27 deletions

View File

@@ -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
)