mirror of
https://github.com/grafana/grafana.git
synced 2024-12-02 05:29:42 -06:00
a4381ebc91
* #46968: add `RetrieveServiceAccountIdByName` to serviceaccounts service * #46968: improve error logging in rendering service * #46968: add oss crawler account setup * #46968: fix tests * #46968: switch back to ROLE_ADMIN * #46968: rename to crawlerAuth * comment crawler_auth.go
42 lines
1016 B
Go
42 lines
1016 B
Go
package thumbs
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/grafana/grafana/pkg/models"
|
|
)
|
|
|
|
type CrawlerAuthSetupService interface {
|
|
Setup(ctx context.Context) (CrawlerAuth, error)
|
|
}
|
|
|
|
func ProvideCrawlerAuthSetupService() *OSSCrawlerAuthSetupService {
|
|
return &OSSCrawlerAuthSetupService{}
|
|
}
|
|
|
|
type OSSCrawlerAuthSetupService struct{}
|
|
|
|
type CrawlerAuth interface {
|
|
GetUserId(orgId int64) int64
|
|
GetOrgRole() models.RoleType
|
|
}
|
|
|
|
type staticCrawlerAuth struct {
|
|
userId int64
|
|
orgRole models.RoleType
|
|
}
|
|
|
|
func (o *staticCrawlerAuth) GetOrgRole() models.RoleType {
|
|
return o.orgRole
|
|
}
|
|
|
|
func (o *staticCrawlerAuth) GetUserId(orgId int64) int64 {
|
|
return o.userId
|
|
}
|
|
|
|
func (o *OSSCrawlerAuthSetupService) Setup(ctx context.Context) (CrawlerAuth, error) {
|
|
// userId:0 and ROLE_ADMIN grants the crawler process permissions to view all dashboards in all folders & orgs
|
|
// the process doesn't and shouldn't actually need to edit/modify any resources from the UI
|
|
return &staticCrawlerAuth{userId: 0, orgRole: models.ROLE_ADMIN}, nil
|
|
}
|