Zanzana: Split up settings into client and server sections (#99066)
* Split up zanzana settings into client and server sections * Update workspace
This commit is contained in:
@@ -473,7 +473,8 @@ type Cfg struct {
|
||||
|
||||
RBAC RBACSettings
|
||||
|
||||
Zanzana ZanzanaSettings
|
||||
ZanzanaClient ZanzanaClientSettings
|
||||
ZanzanaServer ZanzanaServerSettings
|
||||
|
||||
// GRPC Server.
|
||||
GRPCServer GRPCServerSettings
|
||||
|
||||
@@ -12,20 +12,24 @@ const (
|
||||
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
|
||||
type ZanzanaClientSettings struct {
|
||||
// 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
|
||||
// If enabled, authorization cheks will be only performed by zanzana.
|
||||
// This bypasses the performance comparison with the legacy system.
|
||||
ZanzanaOnlyEvaluation bool
|
||||
// Number of concurrent check requests running by Grafana.
|
||||
ConcurrentChecks int64
|
||||
// Addr is the address of the Zanzana server.
|
||||
// Only used when mode is set to client.
|
||||
Addr string
|
||||
// Token used to perform the exchange request.
|
||||
// Only used when mode is set to client.
|
||||
Token string
|
||||
// URL called to perform exchange request.
|
||||
// Only used when mode is set to client.
|
||||
TokenExchangeURL string
|
||||
}
|
||||
|
||||
type ZanzanaServerSettings struct {
|
||||
// OpenFGA http server address which allows to connect with fga cli.
|
||||
// Can only be used in dev mode.
|
||||
OpenFGAHttpAddr string
|
||||
// Enable cache for Check() requests
|
||||
CheckQueryCache bool
|
||||
// TTL for cached requests. Default is 10 seconds.
|
||||
@@ -37,42 +41,38 @@ type ZanzanaSettings struct {
|
||||
// Use streamed version of list objects.
|
||||
// Returns full list of objects, but takes more time.
|
||||
UseStreamedListObjects bool
|
||||
|
||||
// Token used to perform the exchange request.
|
||||
Token string
|
||||
// URL called to perform exchange request.
|
||||
TokenExchangeURL string
|
||||
// URL for signing keys
|
||||
// URL for fetching signing keys.
|
||||
SigningKeysURL string
|
||||
}
|
||||
|
||||
func (cfg *Cfg) readZanzanaSettings() {
|
||||
s := ZanzanaSettings{}
|
||||
|
||||
sec := cfg.Raw.Section("zanzana")
|
||||
s.Mode = ZanzanaMode(sec.Key("mode").MustString("embedded"))
|
||||
zc := ZanzanaClientSettings{}
|
||||
clientSec := cfg.Raw.Section("zanzana.client")
|
||||
|
||||
zc.Mode = ZanzanaMode(clientSec.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"
|
||||
if !slices.Contains(validModes, zc.Mode) {
|
||||
cfg.Logger.Warn("Invalid zanzana mode", "expected", validModes, "got", zc.Mode)
|
||||
zc.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)
|
||||
s.CheckQueryCache = sec.Key("check_query_cache").MustBool(true)
|
||||
s.CheckQueryCacheTTL = sec.Key("check_query_cache_ttl").MustDuration(10 * time.Second)
|
||||
s.ListObjectsDeadline = sec.Key("list_objects_deadline").MustDuration(3 * time.Second)
|
||||
s.ListObjectsMaxResults = uint32(sec.Key("list_objects_max_results").MustUint(1000))
|
||||
s.UseStreamedListObjects = sec.Key("use_streamed_list_objects").MustBool(false)
|
||||
zc.Token = clientSec.Key("token").MustString("")
|
||||
zc.TokenExchangeURL = clientSec.Key("token_exchange_url").MustString("")
|
||||
zc.Addr = clientSec.Key("address").MustString("")
|
||||
|
||||
s.Token = sec.Key("token").MustString("")
|
||||
s.TokenExchangeURL = sec.Key("token_exchange_url").MustString("")
|
||||
s.SigningKeysURL = sec.Key("signing_keys_url").MustString("")
|
||||
cfg.ZanzanaClient = zc
|
||||
|
||||
cfg.Zanzana = s
|
||||
zs := ZanzanaServerSettings{}
|
||||
serverSec := cfg.Raw.Section("zanzana.server")
|
||||
|
||||
zs.OpenFGAHttpAddr = serverSec.Key("http_addr").MustString("127.0.0.1:8080")
|
||||
zs.CheckQueryCache = serverSec.Key("check_query_cache").MustBool(true)
|
||||
zs.CheckQueryCacheTTL = serverSec.Key("check_query_cache_ttl").MustDuration(10 * time.Second)
|
||||
zs.ListObjectsDeadline = serverSec.Key("list_objects_deadline").MustDuration(3 * time.Second)
|
||||
zs.ListObjectsMaxResults = uint32(serverSec.Key("list_objects_max_results").MustUint(1000))
|
||||
zs.UseStreamedListObjects = serverSec.Key("use_streamed_list_objects").MustBool(false)
|
||||
zs.SigningKeysURL = serverSec.Key("signing_keys_url").MustString("")
|
||||
|
||||
cfg.ZanzanaServer = zs
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user