AuthZ: Make NewGrpcTokenAuth public (#101352)
* AuthZ: Expose NewGrpcTokenAuth * Lint
This commit is contained in:
@@ -33,8 +33,8 @@ import (
|
||||
"github.com/grafana/grafana/pkg/storage/legacysql"
|
||||
)
|
||||
|
||||
// `authzService` is hardcoded in authz-service
|
||||
const authzServiceAudience = "authzService"
|
||||
// AuthzServiceAudience is the audience for the authz service.
|
||||
const AuthzServiceAudience = "authzService"
|
||||
|
||||
// ProvideAuthZClient provides an AuthZ client and creates the AuthZ service.
|
||||
func ProvideAuthZClient(
|
||||
@@ -123,7 +123,7 @@ func newRemoteRBACClient(clientCfg *authzClientSettings, tracer tracing.Tracer)
|
||||
clientCfg.remoteAddress,
|
||||
grpc.WithTransportCredentials(insecure.NewCredentials()),
|
||||
grpc.WithPerRPCCredentials(
|
||||
newGRPCTokenAuth(authzServiceAudience, clientCfg.tokenNamespace, tokenClient),
|
||||
NewGRPCTokenAuth(AuthzServiceAudience, clientCfg.tokenNamespace, tokenClient),
|
||||
),
|
||||
)
|
||||
if err != nil {
|
||||
|
||||
@@ -6,7 +6,8 @@ import (
|
||||
"github.com/grafana/authlib/authn"
|
||||
)
|
||||
|
||||
func newGRPCTokenAuth(audience, namespace string, tc authn.TokenExchanger) *tokenAuth {
|
||||
// TODO: move this to authlib
|
||||
func NewGRPCTokenAuth(audience, namespace string, tc authn.TokenExchanger) *tokenAuth {
|
||||
return &tokenAuth{audience, namespace, tc}
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ func ProvideZanzana(cfg *setting.Cfg, db db.DB, tracer tracing.Tracer, features
|
||||
// TODO: add TLS support
|
||||
grpc.WithTransportCredentials(insecure.NewCredentials()),
|
||||
grpc.WithPerRPCCredentials(
|
||||
newGRPCTokenAuth(authzServiceAudience, fmt.Sprintf("stacks-%s", cfg.StackID), tokenClient),
|
||||
NewGRPCTokenAuth(AuthzServiceAudience, fmt.Sprintf("stacks-%s", cfg.StackID), tokenClient),
|
||||
),
|
||||
}
|
||||
|
||||
@@ -172,7 +172,7 @@ func (z *Zanzana) start(ctx context.Context) error {
|
||||
|
||||
authenticator := authnlib.NewAccessTokenAuthenticator(
|
||||
authnlib.NewAccessTokenVerifier(
|
||||
authnlib.VerifierConfig{AllowedAudiences: []string{authzServiceAudience}},
|
||||
authnlib.VerifierConfig{AllowedAudiences: []string{AuthzServiceAudience}},
|
||||
authnlib.NewKeyRetriever(authnlib.KeyRetrieverConfig{
|
||||
SigningKeysURL: z.cfg.ZanzanaServer.SigningKeysURL,
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user