mirror of
https://github.com/grafana/grafana.git
synced 2024-11-28 03:34:15 -06:00
80d694d205
* rendering: headless chrome progress * renderer: minor change * grpc: version hell * updated grpc libs * wip: minor progess * rendering: new image rendering plugin is starting to work * feat: now phantomjs works as well and updated alerting to use new rendering service * refactor: renamed renderer package and service to rendering to make renderer name less confusing (rendering is internal service that handles the renderer plugin now) * rendering: now render key is passed and render auth is working in plugin mode * removed unneeded lines from gitignore * rendering: now plugin mode supports waiting for all panels to complete rendering * fix: LastSeenAt fix for render calls, was not set which causes a lot of updates to Last Seen at during rendering, this should fix sqlite db locked issues in seen in previous releases * change: changed render tz url parameter to use proper timezone name as chrome does not handle UTC offset TZ values * fix: another update to tz param generation * renderer: added http mode to renderer service, new ini setting [rendering] server_url
57 lines
1.0 KiB
Go
57 lines
1.0 KiB
Go
package middleware
|
|
|
|
import (
|
|
"sync"
|
|
"time"
|
|
|
|
m "github.com/grafana/grafana/pkg/models"
|
|
"github.com/grafana/grafana/pkg/util"
|
|
)
|
|
|
|
var renderKeysLock sync.Mutex
|
|
var renderKeys map[string]*m.SignedInUser = make(map[string]*m.SignedInUser)
|
|
|
|
func initContextWithRenderAuth(ctx *m.ReqContext) bool {
|
|
key := ctx.GetCookie("renderKey")
|
|
if key == "" {
|
|
return false
|
|
}
|
|
|
|
renderKeysLock.Lock()
|
|
defer renderKeysLock.Unlock()
|
|
|
|
renderUser, exists := renderKeys[key]
|
|
if !exists {
|
|
ctx.JsonApiErr(401, "Invalid Render Key", nil)
|
|
return true
|
|
}
|
|
|
|
ctx.IsSignedIn = true
|
|
ctx.SignedInUser = renderUser
|
|
ctx.IsRenderCall = true
|
|
ctx.LastSeenAt = time.Now()
|
|
return true
|
|
}
|
|
|
|
func AddRenderAuthKey(orgId int64, userId int64, orgRole m.RoleType) string {
|
|
renderKeysLock.Lock()
|
|
|
|
key := util.GetRandomString(32)
|
|
|
|
renderKeys[key] = &m.SignedInUser{
|
|
OrgId: orgId,
|
|
OrgRole: orgRole,
|
|
UserId: userId,
|
|
}
|
|
|
|
renderKeysLock.Unlock()
|
|
|
|
return key
|
|
}
|
|
|
|
func RemoveRenderAuthKey(key string) {
|
|
renderKeysLock.Lock()
|
|
delete(renderKeys, key)
|
|
renderKeysLock.Unlock()
|
|
}
|