Skip to content

Commit

Permalink
Merge pull request #150 from denis-tingaikin/fix-registry-url
Browse files Browse the repository at this point in the history
qfix: Add missed NewPerRPCCredentials to prevent OPA issues
  • Loading branch information
edwarnicke authored Jun 6, 2021
2 parents df218af + 9bd8229 commit b18fea6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions internal/imports/imports_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
_ "github.com/networkservicemesh/sdk/pkg/tools/opentracing"
_ "github.com/networkservicemesh/sdk/pkg/tools/spiffejwt"
_ "github.com/networkservicemesh/sdk/pkg/tools/spire"
_ "github.com/networkservicemesh/sdk/pkg/tools/token"
_ "github.com/sirupsen/logrus"
_ "github.com/spiffe/go-spiffe/v2/bundle/x509bundle"
_ "github.com/spiffe/go-spiffe/v2/spiffetls/tlsconfig"
Expand Down
17 changes: 14 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"github.com/edwarnicke/grpcfd"

"github.com/networkservicemesh/sdk/pkg/tools/opentracing"
"github.com/networkservicemesh/sdk/pkg/tools/token"

registryconnect "github.com/networkservicemesh/sdk/pkg/registry/common/connect"

Expand Down Expand Up @@ -122,22 +123,32 @@ func main() {
dialOptions := append(
opentracing.WithTracingDial(),
grpc.WithBlock(),
grpc.WithDefaultCallOptions(grpc.WaitForReady(true)),
grpc.WithDefaultCallOptions(
grpc.WaitForReady(true),
grpc.PerRPCCredentials(token.NewPerRPCCredentials(spiffejwt.TokenGeneratorFunc(source, config.MaxTokenLifetime))),
),
grpc.WithTransportCredentials(
grpcfd.TransportCredentials(
credentials.NewTLS(
tlsconfig.MTLSClientConfig(source, source, tlsconfig.AuthorizeAny()),
),
),
),
grpcfd.WithChainStreamInterceptor(),
grpcfd.WithChainUnaryInterceptor(),
)

listenURL := getPublicURL(defaultURL(config))

log.FromContext(ctx).Infof("Listening url: %v", listenURL)

nsmgrproxy.NewServer(
ctx,
config.RegistryProxyURL,
config.RegistryURL,
config.RegistryProxyURL,
spiffejwt.TokenGeneratorFunc(source, config.MaxTokenLifetime),
nsmgrproxy.WithName(config.Name),
nsmgrproxy.WithListenOn(getPublicURL(defaultURL(config))),
nsmgrproxy.WithListenOn(listenURL),
nsmgrproxy.WithRegistryConnectOptions(registryconnect.WithDialOptions(dialOptions...)),
nsmgrproxy.WithConnectOptions(connect.WithDialOptions(dialOptions...)),
nsmgrproxy.WithMapIPFilePath(config.MapIPFilePath),
Expand Down

0 comments on commit b18fea6

Please sign in to comment.