Skip to content

Commit

Permalink
Shanbady/log out flow (#1199)
Browse files Browse the repository at this point in the history
* adding post logout redirect to keycloak

* urlencoding query string
  • Loading branch information
shanbady authored Jun 28, 2024
1 parent 197f341 commit c6ba23b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion authentication/views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Authentication views"""

from urllib.parse import urlencode

from django.conf import settings
from django.contrib.auth import views
from django.http import Http404
Expand Down Expand Up @@ -32,7 +34,13 @@ def _keycloak_logout_url(self, user):
user, provider=OlOpenIdConnectAuth.name
).first()
id_token = user_social_auth_record.extra_data.get("id_token")
return f"{settings.KEYCLOAK_BASE_URL}/realms/{settings.KEYCLOAK_REALM_NAME}/protocol/openid-connect/logout?id_token_hint={id_token}&post_logout_redirect_uri={settings.LOGOUT_REDIRECT_URL}" # noqa: E501
qs = urlencode(
{
"id_token_hint": id_token,
"post_logout_redirect_uri": settings.LOGOUT_REDIRECT_URL,
}
)
return f"{settings.KEYCLOAK_BASE_URL}/realms/{settings.KEYCLOAK_REALM_NAME}/protocol/openid-connect/logout?{qs}" # noqa: E501

def get(
self,
Expand Down

0 comments on commit c6ba23b

Please sign in to comment.