mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
* Zanzana: Search in a background and compare results * refactor * Search with check * instrument zanzana client * add single_read option * refactor * refactor move check into separate function * Fix tests * refactor * refactor getFindDashboardsFn * add resource type to span attributes * run ListObjects concurrently * Use list and search in less cases * adjust metrics buckets * refactor: move Check and ListObjects to AccessControl implementation * Revert "Fix tests" This reverts commitb0c2f072a2
. * refactor: use own types for Check and ListObjects inside accesscontrol package * Fix search scenario with low limit and empty query string * more accurate search with checks * revert * fix linter * Revert "revert" This reverts commitee5f14eea8
. * add search errors metric * fix query performance under some conditions * simplify check strategy * fix pagination * refactor findDashboardsZanzanaList * Iterate over multiple pages while making check request * refactor listUserResources * avoid unnecessary db call * remove unused zclient * Add notes for SkipAccessControlFilter * use more accurate check loop * always use check for search with provided UIDs * rename single_read to zanzana_only_evaluation * refactor * update go workspace * fix linter * don't use deprecated fields * refactor * fail if no org specified * refactor * initial integration tests * Fix tests * fix linter errors * fix linter * Fix tests * review suggestions Co-authored-by: Gabriel MABILLE <gamab@users.noreply.github.com> * fix limit * refactor * refactor tests * fix db config in tests * fix migrator (postgres) --------- Co-authored-by: Gabriel MABILLE <gamab@users.noreply.github.com>
48 lines
1.5 KiB
Go
48 lines
1.5 KiB
Go
package accesscontrol
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/grafana/grafana/pkg/apimachinery/identity"
|
|
"github.com/grafana/grafana/pkg/services/accesscontrol"
|
|
)
|
|
|
|
type recordingAccessControlFake struct {
|
|
Disabled bool
|
|
EvaluateRecordings []struct {
|
|
Permissions map[string][]string
|
|
Evaluator accesscontrol.Evaluator
|
|
}
|
|
Callback func(user identity.Requester, evaluator accesscontrol.Evaluator) (bool, error)
|
|
}
|
|
|
|
func (a *recordingAccessControlFake) Evaluate(_ context.Context, ur identity.Requester, evaluator accesscontrol.Evaluator) (bool, error) {
|
|
a.EvaluateRecordings = append(a.EvaluateRecordings, struct {
|
|
Permissions map[string][]string
|
|
Evaluator accesscontrol.Evaluator
|
|
}{Permissions: ur.GetPermissions(), Evaluator: evaluator})
|
|
if a.Callback == nil {
|
|
return evaluator.Evaluate(ur.GetPermissions()), nil
|
|
}
|
|
return a.Callback(ur, evaluator)
|
|
}
|
|
|
|
func (a *recordingAccessControlFake) RegisterScopeAttributeResolver(prefix string, resolver accesscontrol.ScopeAttributeResolver) {
|
|
// TODO implement me
|
|
panic("implement me")
|
|
}
|
|
|
|
func (a *recordingAccessControlFake) WithoutResolvers() accesscontrol.AccessControl {
|
|
panic("unimplemented")
|
|
}
|
|
|
|
func (a *recordingAccessControlFake) Check(ctx context.Context, in accesscontrol.CheckRequest) (bool, error) {
|
|
return false, nil
|
|
}
|
|
|
|
func (a *recordingAccessControlFake) ListObjects(ctx context.Context, in accesscontrol.ListObjectsRequest) ([]string, error) {
|
|
return nil, nil
|
|
}
|
|
|
|
var _ accesscontrol.AccessControl = &recordingAccessControlFake{}
|