|
|
|
@ -55,7 +55,7 @@ func ProvideAuthZClient( |
|
|
|
|
return nil, err |
|
|
|
|
} |
|
|
|
|
case ModeGRPC: |
|
|
|
|
client, err = newGrpcLegacyClient(authCfg.remoteAddress) |
|
|
|
|
client, err = newGrpcLegacyClient(authCfg) |
|
|
|
|
if err != nil { |
|
|
|
|
return nil, err |
|
|
|
|
} |
|
|
|
@ -83,7 +83,7 @@ func ProvideStandaloneAuthZClient( |
|
|
|
|
return nil, err |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return newGrpcLegacyClient(authCfg.remoteAddress) |
|
|
|
|
return newGrpcLegacyClient(authCfg) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func newInProcLegacyClient(server *legacyServer) (authzlib.MultiTenantClient, error) { |
|
|
|
@ -109,7 +109,7 @@ func newInProcLegacyClient(server *legacyServer) (authzlib.MultiTenantClient, er |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func newGrpcLegacyClient(address string) (authzlib.MultiTenantClient, error) { |
|
|
|
|
func newGrpcLegacyClient(authCfg *Cfg) (authzlib.MultiTenantClient, error) { |
|
|
|
|
// This client interceptor is a noop, as we don't send an access token
|
|
|
|
|
grpcClientConfig := authnlib.GrpcClientConfig{} |
|
|
|
|
clientInterceptor, err := authnlib.NewGrpcClientInterceptor(&grpcClientConfig, |
|
|
|
@ -119,13 +119,10 @@ func newGrpcLegacyClient(address string) (authzlib.MultiTenantClient, error) { |
|
|
|
|
return nil, err |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
cfg := authzlib.MultiTenantClientConfig{RemoteAddress: address} |
|
|
|
|
cfg := authzlib.MultiTenantClientConfig{RemoteAddress: authCfg.remoteAddress} |
|
|
|
|
client, err := authzlib.NewLegacyClient(&cfg, |
|
|
|
|
// TODO(drclau): make this configurable (e.g. allow to use insecure connections)
|
|
|
|
|
authzlib.WithGrpcDialOptionsLCOption( |
|
|
|
|
grpc.WithTransportCredentials(insecure.NewCredentials()), |
|
|
|
|
grpc.WithUnaryInterceptor(clientInterceptor.UnaryClientInterceptor), |
|
|
|
|
grpc.WithStreamInterceptor(clientInterceptor.StreamClientInterceptor), |
|
|
|
|
getDialOpts(clientInterceptor, authCfg.allowInsecure)..., |
|
|
|
|
), |
|
|
|
|
authzlib.WithNamespaceFormatterLCOption(authnlib.OnPremNamespaceFormatter), |
|
|
|
|
// TODO(drclau): remove this once we have access token support on-prem
|
|
|
|
@ -157,11 +154,8 @@ func newCloudLegacyClient(authCfg *Cfg) (authzlib.MultiTenantClient, error) { |
|
|
|
|
|
|
|
|
|
clientCfg := authzlib.MultiTenantClientConfig{RemoteAddress: authCfg.remoteAddress} |
|
|
|
|
client, err := authzlib.NewLegacyClient(&clientCfg, |
|
|
|
|
// TODO(drclau): make this configurable (e.g. allow to use insecure connections)
|
|
|
|
|
authzlib.WithGrpcDialOptionsLCOption( |
|
|
|
|
grpc.WithTransportCredentials(insecure.NewCredentials()), |
|
|
|
|
grpc.WithUnaryInterceptor(clientInterceptor.UnaryClientInterceptor), |
|
|
|
|
grpc.WithStreamInterceptor(clientInterceptor.StreamClientInterceptor), |
|
|
|
|
getDialOpts(clientInterceptor, authCfg.allowInsecure)..., |
|
|
|
|
), |
|
|
|
|
) |
|
|
|
|
if err != nil { |
|
|
|
@ -170,3 +164,16 @@ func newCloudLegacyClient(authCfg *Cfg) (authzlib.MultiTenantClient, error) { |
|
|
|
|
|
|
|
|
|
return client, nil |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func getDialOpts(interceptor *authnlib.GrpcClientInterceptor, allowInsecure bool) []grpc.DialOption { |
|
|
|
|
dialOpts := []grpc.DialOption{ |
|
|
|
|
grpc.WithUnaryInterceptor(interceptor.UnaryClientInterceptor), |
|
|
|
|
grpc.WithStreamInterceptor(interceptor.StreamClientInterceptor), |
|
|
|
|
} |
|
|
|
|
if allowInsecure { |
|
|
|
|
// allow insecure connections in development mode to facilitate testing
|
|
|
|
|
dialOpts = append(dialOpts, grpc.WithTransportCredentials(insecure.NewCredentials())) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return dialOpts |
|
|
|
|
} |
|
|
|
|