The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
grafana/pkg/services/authn/grpcutils/config.go

67 lines
1.6 KiB

package grpcutils
import (
"fmt"
"github.com/grafana/grafana/pkg/setting"
)
type Mode string
func (s Mode) IsValid() bool {
switch s {
case ModeOnPrem, ModeCloud:
return true
}
return false
}
const (
ModeOnPrem Mode = "on-prem"
ModeCloud Mode = "cloud"
)
type GrpcClientConfig struct {
Token string
TokenExchangeURL string
TokenNamespace string
Mode Mode
}
func ReadGrpcClientConfig(cfg *setting.Cfg) (*GrpcClientConfig, error) {
section := cfg.SectionWithEnvOverrides("grpc_client_authentication")
mode := Mode(section.Key("mode").MustString(string(ModeOnPrem)))
if !mode.IsValid() {
return nil, fmt.Errorf("grpc_client_authentication: invalid mode %q", mode)
}
return &GrpcClientConfig{
Token: section.Key("token").MustString(""),
TokenExchangeURL: section.Key("token_exchange_url").MustString(""),
TokenNamespace: section.Key("token_namespace").MustString("stack-" + cfg.StackID),
Mode: mode,
}, nil
}
10 months ago
type GrpcServerConfig struct {
SigningKeysURL string
AllowedAudiences []string
Mode Mode
10 months ago
}
func ReadGprcServerConfig(cfg *setting.Cfg) (*GrpcServerConfig, error) {
10 months ago
section := cfg.SectionWithEnvOverrides("grpc_server_authentication")
mode := Mode(section.Key("mode").MustString(string(ModeOnPrem)))
if !mode.IsValid() {
return nil, fmt.Errorf("grpc_server_authentication: invalid mode %q", mode)
}
10 months ago
return &GrpcServerConfig{
SigningKeysURL: section.Key("signing_keys_url").MustString(""),
AllowedAudiences: section.Key("allowed_audiences").Strings(","),
Mode: mode,
}, nil
10 months ago
}