mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Auth: Should redirect to login when anonymous enabled and URL with different org than anonymous specified (#28158)
If anonymous access is enabled for an org and there are multiple orgs. When requesting a page that requires user to be logged in and orgId query string is set in the request url to an org not equal the anonymous org, if the user is not logged in should be redirected to the login page. Fixes #26120 Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com> Co-authored-by: Sofia Papagiannaki <papagian@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
090c683fea
commit
3be82ecd4e
@@ -94,6 +94,14 @@ func Auth(options *AuthOptions) macaron.Handler {
|
||||
if err == nil {
|
||||
forceLogin = forceLoginParam
|
||||
}
|
||||
|
||||
if !forceLogin {
|
||||
orgIDValue := c.Req.URL.Query().Get("orgId")
|
||||
orgID, err := strconv.ParseInt(orgIDValue, 10, 64)
|
||||
if err == nil && orgID > 0 && orgID != c.OrgId {
|
||||
forceLogin = true
|
||||
}
|
||||
}
|
||||
}
|
||||
requireLogin := !c.AllowAnonymous || forceLogin
|
||||
if !c.IsSignedIn && options.ReqSignedIn && requireLogin {
|
||||
|
Reference in New Issue
Block a user