Skip to content

Commit 1f951c3

Browse files
committed
if the "next" query string value is sent to the logout view, pass that along to keycloak as "post_logout_redirect_uri" instead of settings.LOGOUT_REDIRECT_URL
1 parent 2b319ed commit 1f951c3

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

authentication/views.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,13 @@ def _keycloak_logout_url(self, user):
3333
user, provider=OlOpenIdConnectAuth.name
3434
).first()
3535
id_token = user_social_auth_record.extra_data.get("id_token")
36+
qs_next = self.request.GET.get("next")
3637
qs = urlencode(
3738
{
3839
"id_token_hint": id_token,
39-
"post_logout_redirect_uri": self.request.build_absolute_uri(
40-
settings.LOGOUT_REDIRECT_URL
41-
),
40+
"post_logout_redirect_uri": qs_next
41+
if qs_next
42+
else self.request.build_absolute_uri(settings.LOGOUT_REDIRECT_URL),
4243
}
4344
)
4445

@@ -55,7 +56,7 @@ def get(
5556
**kwargs, # noqa: ARG002
5657
):
5758
"""
58-
GET endpoint for loggin a user out.
59+
GET endpoint for logging a user out.
5960
6061
The logout redirect path the user follows is:
6162

0 commit comments

Comments
 (0)