Skip to content

Commit

Permalink
Merge pull request #61 from NikitaSkrynnik/authorize
Browse files Browse the repository at this point in the history
Add registry authorization
  • Loading branch information
denis-tingaikin authored Dec 5, 2022
2 parents 1aea982 + bf0a3d1 commit 36d0b36
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 2 additions & 0 deletions internal/pkg/imports/imports_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
_ "github.com/networkservicemesh/sdk/pkg/networkservice/core/chain"
_ "github.com/networkservicemesh/sdk/pkg/networkservice/ipam/point2pointipam"
_ "github.com/networkservicemesh/sdk/pkg/registry/chains/client"
_ "github.com/networkservicemesh/sdk/pkg/registry/common/authorize"
_ "github.com/networkservicemesh/sdk/pkg/registry/common/sendfd"
_ "github.com/networkservicemesh/sdk/pkg/tools/clientinfo"
_ "github.com/networkservicemesh/sdk/pkg/tools/debug"
Expand All @@ -34,6 +35,7 @@ import (
_ "github.com/networkservicemesh/sdk/pkg/tools/log/logruslogger"
_ "github.com/networkservicemesh/sdk/pkg/tools/opentelemetry"
_ "github.com/networkservicemesh/sdk/pkg/tools/spiffejwt"
_ "github.com/networkservicemesh/sdk/pkg/tools/token"
_ "github.com/networkservicemesh/sdk/pkg/tools/tracing"
_ "github.com/pkg/errors"
_ "github.com/sirupsen/logrus"
Expand Down
12 changes: 9 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ import (
"github.com/networkservicemesh/sdk/pkg/networkservice/core/chain"
"github.com/networkservicemesh/sdk/pkg/networkservice/ipam/point2pointipam"
registryclient "github.com/networkservicemesh/sdk/pkg/registry/chains/client"
registryauthorize "github.com/networkservicemesh/sdk/pkg/registry/common/authorize"
registrysendfd "github.com/networkservicemesh/sdk/pkg/registry/common/sendfd"
"github.com/networkservicemesh/sdk/pkg/tools/clientinfo"
"github.com/networkservicemesh/sdk/pkg/tools/debug"
Expand All @@ -69,6 +70,7 @@ import (
"github.com/networkservicemesh/sdk/pkg/tools/log/logruslogger"
"github.com/networkservicemesh/sdk/pkg/tools/opentelemetry"
"github.com/networkservicemesh/sdk/pkg/tools/spiffejwt"
"github.com/networkservicemesh/sdk/pkg/tools/token"
"github.com/networkservicemesh/sdk/pkg/tools/tracing"
)

Expand Down Expand Up @@ -259,23 +261,27 @@ func main() {
clientOptions := append(
tracing.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(),
)

nseRegistryClient := registryclient.NewNetworkServiceEndpointRegistryClient(
ctx,
registryclient.WithClientURL(&config.ConnectTo),
registryclient.WithDialOptions(clientOptions...),
registryclient.WithNSEAdditionalFunctionality(
registrysendfd.NewNetworkServiceEndpointRegistryClient(),
),
registrysendfd.NewNetworkServiceEndpointRegistryClient()),
registryclient.WithAuthorizeNSERegistryClient(registryauthorize.NewNetworkServiceEndpointRegistryClient()),
)
nse := getNseEndpoint(config, listenOn)
nse, err = nseRegistryClient.Register(ctx, nse)
Expand Down

0 comments on commit 36d0b36

Please sign in to comment.