mirror of https://github.com/grafana/grafana
Previews: create crawler auth setup service (#47349)
* #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.gopull/47633/head^2
parent
5cb5141c72
commit
a4381ebc91
@ -0,0 +1,41 @@ |
||||
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 |
||||
} |
||||
Loading…
Reference in new issue