mirror of
https://github.com/grafana/grafana.git
synced 2024-11-27 03:11:01 -06:00
d0a80c59f3
By storing render key in remote cache it will enable image renderer to use public facing url or load balancer url to render images and thereby remove the requirement of image renderer having to use the url of the originating Grafana instance when running HA setup (multiple Grafana instances). Fixes #17704 Ref grafana/grafana-image-renderer#91
33 lines
669 B
Go
33 lines
669 B
Go
package middleware
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/grafana/grafana/pkg/services/rendering"
|
|
|
|
m "github.com/grafana/grafana/pkg/models"
|
|
)
|
|
|
|
func initContextWithRenderAuth(ctx *m.ReqContext, renderService rendering.Service) bool {
|
|
key := ctx.GetCookie("renderKey")
|
|
if key == "" {
|
|
return false
|
|
}
|
|
|
|
renderUser, exists := renderService.GetRenderUser(key)
|
|
if !exists {
|
|
ctx.JsonApiErr(401, "Invalid Render Key", nil)
|
|
return true
|
|
}
|
|
|
|
ctx.IsSignedIn = true
|
|
ctx.SignedInUser = &m.SignedInUser{
|
|
OrgId: renderUser.OrgID,
|
|
UserId: renderUser.UserID,
|
|
OrgRole: m.RoleType(renderUser.OrgRole),
|
|
}
|
|
ctx.IsRenderCall = true
|
|
ctx.LastSeenAt = time.Now()
|
|
return true
|
|
}
|