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>
51 lines
1.4 KiB
Go
51 lines
1.4 KiB
Go
package setting
|
|
|
|
import (
|
|
"slices"
|
|
)
|
|
|
|
type ZanzanaMode string
|
|
|
|
const (
|
|
ZanzanaModeClient ZanzanaMode = "client"
|
|
ZanzanaModeEmbedded ZanzanaMode = "embedded"
|
|
)
|
|
|
|
type ZanzanaSettings struct {
|
|
// Addr is only used when mode is set to client
|
|
Addr string
|
|
// Mode can either be embedded or client
|
|
Mode ZanzanaMode
|
|
// ListenHTTP enables OpenFGA http server which allows to use fga cli
|
|
ListenHTTP bool
|
|
// OpenFGA http server address which allows to connect with fga cli
|
|
HttpAddr string
|
|
// Number of check requests running concurrently
|
|
ConcurrentChecks int64
|
|
// If enabled, authorization cheks will be only performed by zanzana.
|
|
// This bypasses the performance comparison with the legacy system.
|
|
ZanzanaOnlyEvaluation bool
|
|
}
|
|
|
|
func (cfg *Cfg) readZanzanaSettings() {
|
|
s := ZanzanaSettings{}
|
|
|
|
sec := cfg.Raw.Section("zanzana")
|
|
s.Mode = ZanzanaMode(sec.Key("mode").MustString("embedded"))
|
|
|
|
validModes := []ZanzanaMode{ZanzanaModeEmbedded, ZanzanaModeClient}
|
|
|
|
if !slices.Contains(validModes, s.Mode) {
|
|
cfg.Logger.Warn("Invalid zanzana mode", "expected", validModes, "got", s.Mode)
|
|
s.Mode = "embedded"
|
|
}
|
|
|
|
s.Addr = sec.Key("address").MustString("")
|
|
s.ListenHTTP = sec.Key("listen_http").MustBool(false)
|
|
s.HttpAddr = sec.Key("http_addr").MustString("127.0.0.1:8080")
|
|
s.ConcurrentChecks = sec.Key("concurrent_checks").MustInt64(10)
|
|
s.ZanzanaOnlyEvaluation = sec.Key("zanzana_only_evaluation").MustBool(false)
|
|
|
|
cfg.Zanzana = s
|
|
}
|