mirror of
https://github.com/grafana/grafana.git
synced 2024-11-26 19:00:54 -06:00
32 lines
681 B
Go
32 lines
681 B
Go
package middleware
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/grafana/grafana/pkg/models"
|
|
"github.com/grafana/grafana/pkg/services/rendering"
|
|
)
|
|
|
|
func initContextWithRenderAuth(ctx *models.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 = &models.SignedInUser{
|
|
OrgId: renderUser.OrgID,
|
|
UserId: renderUser.UserID,
|
|
OrgRole: models.RoleType(renderUser.OrgRole),
|
|
}
|
|
ctx.IsRenderCall = true
|
|
ctx.LastSeenAt = time.Now()
|
|
return true
|
|
}
|