Chore: clean up access control for data sources (#73010)
* move DS guardian interfaces to OSS, move allow guardian to OSS * update codeowner file
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
package guardian
|
||||
|
||||
import (
|
||||
"github.com/grafana/grafana/pkg/services/datasources"
|
||||
)
|
||||
|
||||
var _ DatasourceGuardian = new(AllowGuardian)
|
||||
|
||||
// AllowGuardian is used whenever an enterprise build is running without a license.
|
||||
// It allows every one to Query all data sources and will not filter out any of them
|
||||
type AllowGuardian struct{}
|
||||
|
||||
func (n AllowGuardian) CanQuery(datasourceID int64) (bool, error) {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func (n AllowGuardian) FilterDatasourcesByQueryPermissions(ds []*datasources.DataSource) ([]*datasources.DataSource, error) {
|
||||
return ds, nil
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package guardian
|
||||
|
||||
import (
|
||||
"github.com/grafana/grafana/pkg/services/datasources"
|
||||
"github.com/grafana/grafana/pkg/services/user"
|
||||
)
|
||||
|
||||
type DatasourceGuardianProvider interface {
|
||||
New(orgID int64, user *user.SignedInUser, dataSources ...datasources.DataSource) DatasourceGuardian
|
||||
}
|
||||
|
||||
type DatasourceGuardian interface {
|
||||
CanQuery(datasourceID int64) (bool, error)
|
||||
FilterDatasourcesByQueryPermissions([]*datasources.DataSource) ([]*datasources.DataSource, error)
|
||||
}
|
||||
|
||||
func ProvideGuardian() *OSSProvider {
|
||||
return &OSSProvider{}
|
||||
}
|
||||
|
||||
type OSSProvider struct{}
|
||||
|
||||
func (p *OSSProvider) New(orgID int64, user *user.SignedInUser, dataSources ...datasources.DataSource) DatasourceGuardian {
|
||||
return &AllowGuardian{}
|
||||
}
|
||||
Reference in New Issue
Block a user