mirror of
https://github.com/grafana/grafana.git
synced 2025-07-30 05:12:36 +08:00
Snapshots: Disallow anonymous user to create snapshots (#31263)
This commit is contained in:

committed by
GitHub

parent
b5cbbc3db1
commit
8f20b13f1c
@ -119,15 +119,17 @@ func AdminOrFeatureEnabled(enabled bool) macaron.Handler {
|
||||
}
|
||||
}
|
||||
|
||||
// SnapshotPublicModeOrSignedIn creates a middleware that allows access
|
||||
// if snapshot public mode is enabled or if user is signed in.
|
||||
func SnapshotPublicModeOrSignedIn(cfg *setting.Cfg) macaron.Handler {
|
||||
return func(c *models.ReqContext) {
|
||||
if cfg.SnapshotPublicMode {
|
||||
return
|
||||
}
|
||||
|
||||
_, err := c.Invoke(ReqSignedIn)
|
||||
if err != nil {
|
||||
c.JsonApiErr(500, "Failed to invoke required signed in middleware", err)
|
||||
if !c.IsSignedIn {
|
||||
notAuthorized(c)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user