removed WithIDTokenExtractorOption, and other PR feedback

This commit is contained in:
Claudiu Dragalina-Paraipan 2024-09-03 15:42:50 +03:00
parent 21220c2cca
commit d09e14c26a
2 changed files with 4 additions and 15 deletions

View File

@ -25,11 +25,11 @@ type GrpcServerConfig struct {
AllowedAudiences []string AllowedAudiences []string
} }
func ReadGprcServerConfig(cfg *setting.Cfg) (*GrpcServerConfig, error) { func ReadGprcServerConfig(cfg *setting.Cfg) *GrpcServerConfig {
section := cfg.SectionWithEnvOverrides("grpc_server_authentication") section := cfg.SectionWithEnvOverrides("grpc_server_authentication")
return &GrpcServerConfig{ return &GrpcServerConfig{
SigningKeysURL: section.Key("signing_keys_url").MustString(""), SigningKeysURL: section.Key("signing_keys_url").MustString(""),
AllowedAudiences: section.Key("allowed_audiences").Strings(","), AllowedAudiences: section.Key("allowed_audiences").Strings(","),
}, nil }
} }

View File

@ -13,7 +13,6 @@ import (
"google.golang.org/grpc" "google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure" "google.golang.org/grpc/credentials/insecure"
"github.com/grafana/grafana/pkg/apimachinery/identity"
"github.com/grafana/grafana/pkg/infra/tracing" "github.com/grafana/grafana/pkg/infra/tracing"
"github.com/grafana/grafana/pkg/services/accesscontrol" "github.com/grafana/grafana/pkg/services/accesscontrol"
"github.com/grafana/grafana/pkg/services/featuremgmt" "github.com/grafana/grafana/pkg/services/featuremgmt"
@ -116,18 +115,8 @@ func newInProcLegacyClient(server *legacyServer) (authzlib.MultiTenantClient, er
func newGrpcLegacyClient(authCfg *Cfg) (authzlib.MultiTenantClient, error) { func newGrpcLegacyClient(authCfg *Cfg) (authzlib.MultiTenantClient, error) {
// This client interceptor is a noop, as we don't send an access token // This client interceptor is a noop, as we don't send an access token
grpcClientConfig := authnlib.GrpcClientConfig{} clientConfig := authnlib.GrpcClientConfig{}
clientInterceptor, err := authnlib.NewGrpcClientInterceptor(&grpcClientConfig, clientInterceptor, err := authnlib.NewGrpcClientInterceptor(&clientConfig, authnlib.WithDisableAccessTokenOption())
authnlib.WithDisableAccessTokenOption(),
authnlib.WithIDTokenExtractorOption(func(ctx context.Context) (string, error) {
r, err := identity.GetRequester(ctx)
if err != nil {
return "", err
}
token := r.GetIDToken()
return token, nil
}),
)
if err != nil { if err != nil {
return nil, err return nil, err
} }