Skip to content

Commit

Permalink
Added support for params in logout URL and encoded post redirect URL
Browse files Browse the repository at this point in the history
  • Loading branch information
wluyima committed Jun 13, 2024
1 parent b7e96b9 commit 29e295b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion auth_oidc/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,15 @@ def logout(self, redirect="/web/login"):
p = request.env["auth.oauth.provider"].sudo().browse(user.oauth_provider_id.id)

Check warning on line 62 in auth_oidc/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

auth_oidc/controllers/main.py#L62

Added line #L62 was not covered by tests
if p.logout_endpoint:
r = request.env['ir.config_parameter'].sudo().get_param('web.base.url') + redirect
logout_url = p.logout_endpoint + "?client_id=" + p.client_id + "&post_logout_redirect_uri=" + r
logout_base_url = p.logout_endpoint
params = {}

Check warning on line 66 in auth_oidc/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

auth_oidc/controllers/main.py#L64-L66

Added lines #L64 - L66 were not covered by tests
if '?' in p.logout_endpoint:
url_parts = p.logout_endpoint.split("?")
logout_base_url = url_parts[0]
params = url_decode(url_parts[1])
params["client_id"] = p.client_id
params["post_logout_redirect_uri"] = r
logout_url = f"{logout_base_url}?{url_encode(params)}"
return super().logout(redirect=logout_url)

Check warning on line 74 in auth_oidc/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

auth_oidc/controllers/main.py#L68-L74

Added lines #L68 - L74 were not covered by tests
# User has no account with any provider or no logout URL is configured for the provider
return super().logout(redirect=redirect)

0 comments on commit 29e295b

Please sign in to comment.