Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AuthN: Fix signout redirect url #87631

Merged
merged 4 commits into from May 12, 2024
Merged

AuthN: Fix signout redirect url #87631

merged 4 commits into from May 12, 2024

Conversation

kalleep
Copy link
Contributor

@kalleep kalleep commented May 10, 2024

What is this feature?
After #79635 we did not respect signout_redirect_url configured under [auth]. It only worked with saml and oauth.

To fix this we instead default to use signout_redirect_url if configured. A client that implement LogoutClient will still take precedence. We also need to ignore the case when users don't have a session token so that the configured redirect url is used.

Which issue(s) does this PR fix?:
Fixes #85128
Fixes #84108

Special notes for your reviewer:

Please check that:

  • It works as expected from a user's perspective.
  • If this is a pre-GA feature, it is behind a feature toggle.
  • The docs are updated, and if this is a notable improvement, it's added to our What's New doc.

@kalleep kalleep added type/bug backport v11.0.x Mark PR for automatic backport to v11.0.x labels May 10, 2024
@kalleep kalleep added this to the 11.1.x milestone May 10, 2024
@kalleep kalleep self-assigned this May 10, 2024
@kalleep kalleep requested review from torkelo and a team as code owners May 10, 2024 13:51
@@ -875,7 +875,6 @@ auto_sign_up = false
url_login = false
allow_assign_grafana_admin = false
skip_org_role_sync = false
signout_redirect_url =
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this value is never read into jwt config

Copy link
Contributor

This PR must be merged before a backport PR will be created.

1 similar comment
Copy link
Contributor

This PR must be merged before a backport PR will be created.

@@ -254,6 +254,7 @@ func (hs *HTTPServer) Logout(c *contextmodel.ReqContext) {
if err != nil {
hs.log.Error("Failed perform proper logout", "error", err)
c.Redirect(hs.Cfg.AppSubURL + "/login")
return
Copy link
Contributor Author

@kalleep kalleep May 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Panic logs displayed in issues was from here. When something wen't wrong we did not return here and on line 262 we tried to use redirect.URL i.e. de-referencing a nil pointer

@IevaVasiljeva
Copy link
Contributor

I think this also fixes this issue: #79839

@kalleep kalleep merged commit 0f3080e into main May 12, 2024
29 checks passed
@kalleep kalleep deleted the authn/signout-redirect-urls branch May 12, 2024 17:53
grafana-delivery-bot bot pushed a commit that referenced this pull request May 12, 2024
* Add missing return

* Use sign out redirect url from auth config if configured

* remove option from auth.jwt that is not used

(cherry picked from commit 0f3080e)
kalleep added a commit that referenced this pull request May 13, 2024
* AuthN: Fix signout redirect url (#87631)

* Add missing return

* Use sign out redirect url from auth config if configured

* remove option from auth.jwt that is not used

(cherry picked from commit 0f3080e)

---------

Co-authored-by: Karl Persson <kalle.persson@grafana.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants