mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
AuthN: Optionally use tokens for unified storage client authentication (#91665)
* extracted in-proc mode to #93124 * allow insecure conns in dev mode + refactoring * removed ModeCloud, relying on ModeGrpc and stackID instead to discover if we're running in Cloud * remove the NamespaceAuthorizer would fail in legacy mode. It will be added back in the future. * use FlagAppPlatformGrpcClientAuth to enable new behavior, instead of legacy * extracted authz package changes in #95120 * extracted server side changes in #95086 --------- Co-authored-by: Gabriel MABILLE <gamab@users.noreply.github.com> Co-authored-by: gamab <gabriel.mabille@grafana.com> Co-authored-by: Dan Cech <dcech@grafana.com>
This commit is contained in:
committed by
GitHub
parent
f7fcc14f69
commit
830600dab0
@@ -43,3 +43,19 @@ func ReadGrpcServerConfig(cfg *setting.Cfg) (*GrpcServerConfig, error) {
|
||||
LegacyFallback: section.Key("legacy_fallback").MustBool(true),
|
||||
}, nil
|
||||
}
|
||||
|
||||
type GrpcClientConfig struct {
|
||||
Token string
|
||||
TokenExchangeURL string
|
||||
TokenNamespace string
|
||||
}
|
||||
|
||||
func ReadGrpcClientConfig(cfg *setting.Cfg) *GrpcClientConfig {
|
||||
section := cfg.SectionWithEnvOverrides("grpc_client_authentication")
|
||||
|
||||
return &GrpcClientConfig{
|
||||
Token: section.Key("token").MustString(""),
|
||||
TokenExchangeURL: section.Key("token_exchange_url").MustString(""),
|
||||
TokenNamespace: section.Key("token_namespace").MustString("stacks-" + cfg.StackID),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,12 +69,10 @@ func ProvideService(cfg *setting.Cfg, features featuremgmt.FeatureToggles, authe
|
||||
}
|
||||
}
|
||||
|
||||
var opts []grpc.ServerOption
|
||||
|
||||
// Default auth is admin token check, but this can be overridden by
|
||||
// services which implement ServiceAuthFuncOverride interface.
|
||||
// See https://github.com/grpc-ecosystem/go-grpc-middleware/blob/main/interceptors/auth/auth.go#L30.
|
||||
opts = append(opts, []grpc.ServerOption{
|
||||
opts := []grpc.ServerOption{
|
||||
grpc.StatsHandler(otelgrpc.NewServerHandler()),
|
||||
grpc.ChainUnaryInterceptor(
|
||||
grpcAuth.UnaryServerInterceptor(authenticator.Authenticate),
|
||||
@@ -86,7 +84,7 @@ func ProvideService(cfg *setting.Cfg, features featuremgmt.FeatureToggles, authe
|
||||
grpcAuth.StreamServerInterceptor(authenticator.Authenticate),
|
||||
middleware.StreamServerInstrumentInterceptor(grpcRequestDuration),
|
||||
),
|
||||
}...)
|
||||
}
|
||||
|
||||
if s.cfg.GRPCServerTLSConfig != nil {
|
||||
opts = append(opts, grpc.Creds(credentials.NewTLS(cfg.GRPCServerTLSConfig)))
|
||||
|
||||
Reference in New Issue
Block a user