mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Misc: Remove unused params and impossible logic (#83756)
* remove unused params and impossible logic * remove unused param
This commit is contained in:
parent
11d341d2bb
commit
0aebb9ee39
@ -654,7 +654,7 @@ func (hs *HTTPServer) declareFixedRoles() error {
|
||||
// Metadata helpers
|
||||
// getAccessControlMetadata returns the accesscontrol metadata associated with a given resource
|
||||
func (hs *HTTPServer) getAccessControlMetadata(c *contextmodel.ReqContext,
|
||||
orgID int64, prefix string, resourceID string) ac.Metadata {
|
||||
prefix string, resourceID string) ac.Metadata {
|
||||
ids := map[string]bool{resourceID: true}
|
||||
return hs.getMultiAccessControlMetadata(c, prefix, ids)[resourceID]
|
||||
}
|
||||
|
@ -136,7 +136,7 @@ func (hs *HTTPServer) GetDataSourceById(c *contextmodel.ReqContext) response.Res
|
||||
dto := hs.convertModelToDtos(c.Req.Context(), dataSource)
|
||||
|
||||
// Add accesscontrol metadata
|
||||
dto.AccessControl = hs.getAccessControlMetadata(c, c.SignedInUser.GetOrgID(), datasources.ScopePrefix, dto.UID)
|
||||
dto.AccessControl = hs.getAccessControlMetadata(c, datasources.ScopePrefix, dto.UID)
|
||||
|
||||
return response.JSON(http.StatusOK, &dto)
|
||||
}
|
||||
@ -222,7 +222,7 @@ func (hs *HTTPServer) GetDataSourceByUID(c *contextmodel.ReqContext) response.Re
|
||||
dto := hs.convertModelToDtos(c.Req.Context(), ds)
|
||||
|
||||
// Add accesscontrol metadata
|
||||
dto.AccessControl = hs.getAccessControlMetadata(c, c.SignedInUser.GetOrgID(), datasources.ScopePrefix, dto.UID)
|
||||
dto.AccessControl = hs.getAccessControlMetadata(c, datasources.ScopePrefix, dto.UID)
|
||||
|
||||
return response.JSON(http.StatusOK, &dto)
|
||||
}
|
||||
|
@ -587,9 +587,6 @@ func (hs *HTTPServer) configureHttps() error {
|
||||
}
|
||||
|
||||
tlsCiphers := hs.getDefaultCiphers(minTlsVersion, string(setting.HTTPSScheme))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
hs.log.Info("HTTP Server TLS settings", "Min TLS Version", hs.Cfg.MinTLSVersion,
|
||||
"configured ciphers", util.TlsCipherIdsToString(tlsCiphers))
|
||||
|
@ -287,7 +287,7 @@ func (hs *HTTPServer) trySetEncryptedCookie(ctx *contextmodel.ReqContext, cookie
|
||||
return err
|
||||
}
|
||||
|
||||
cookies.WriteCookie(ctx.Resp, cookieName, hex.EncodeToString(encryptedError), 60, hs.CookieOptionsFromCfg)
|
||||
cookies.WriteCookie(ctx.Resp, cookieName, hex.EncodeToString(encryptedError), maxAge, hs.CookieOptionsFromCfg)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ func (hs *HTTPServer) getUserUserProfile(c *contextmodel.ReqContext, userID int6
|
||||
userProfile.IsGrafanaAdminExternallySynced = login.IsGrafanaAdminExternallySynced(hs.Cfg, oauthInfo, authInfo.AuthModule)
|
||||
}
|
||||
|
||||
userProfile.AccessControl = hs.getAccessControlMetadata(c, c.SignedInUser.GetOrgID(), "global.users:id:", strconv.FormatInt(userID, 10))
|
||||
userProfile.AccessControl = hs.getAccessControlMetadata(c, "global.users:id:", strconv.FormatInt(userID, 10))
|
||||
userProfile.AvatarURL = dtos.GetGravatarUrl(hs.Cfg, userProfile.Email)
|
||||
|
||||
return response.JSON(http.StatusOK, userProfile)
|
||||
|
@ -37,7 +37,7 @@ func Middleware(ac AccessControl) func(Evaluator) web.Handler {
|
||||
}
|
||||
|
||||
if !c.IsSignedIn && forceLogin {
|
||||
unauthorized(c, nil)
|
||||
unauthorized(c)
|
||||
return
|
||||
}
|
||||
}
|
||||
@ -49,7 +49,7 @@ func Middleware(ac AccessControl) func(Evaluator) web.Handler {
|
||||
return
|
||||
}
|
||||
|
||||
unauthorized(c, c.LookupTokenErr)
|
||||
unauthorized(c)
|
||||
return
|
||||
}
|
||||
|
||||
@ -113,7 +113,7 @@ func deny(c *contextmodel.ReqContext, evaluator Evaluator, err error) {
|
||||
})
|
||||
}
|
||||
|
||||
func unauthorized(c *contextmodel.ReqContext, err error) {
|
||||
func unauthorized(c *contextmodel.ReqContext) {
|
||||
if c.IsApiRequest() {
|
||||
c.WriteErrOrFallback(http.StatusUnauthorized, http.StatusText(http.StatusUnauthorized), c.LookupTokenErr)
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user