Skip to content

Commit

Permalink
Merge pull request #544 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 8b1b623 + b399c4c commit 5346c0b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions internal/imports/imports_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
_ "github.com/networkservicemesh/sdk-sriov/pkg/tools/tokens"
_ "github.com/networkservicemesh/sdk/pkg/networkservice/common/authorize"
_ "github.com/networkservicemesh/sdk/pkg/registry/chains/client"
_ "github.com/networkservicemesh/sdk/pkg/registry/common/authorize"
_ "github.com/networkservicemesh/sdk/pkg/registry/common/begin"
_ "github.com/networkservicemesh/sdk/pkg/registry/common/expire"
_ "github.com/networkservicemesh/sdk/pkg/registry/common/memory"
Expand Down
8 changes: 7 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import (
sriovtoken "github.com/networkservicemesh/sdk-sriov/pkg/sriov/token"
"github.com/networkservicemesh/sdk/pkg/networkservice/common/authorize"
registryclient "github.com/networkservicemesh/sdk/pkg/registry/chains/client"
registryauthorize "github.com/networkservicemesh/sdk/pkg/registry/common/authorize"
"github.com/networkservicemesh/sdk/pkg/registry/common/sendfd"
"github.com/networkservicemesh/sdk/pkg/tools/debug"
"github.com/networkservicemesh/sdk/pkg/tools/grpcutils"
Expand Down Expand Up @@ -270,14 +271,18 @@ 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,
Expand All @@ -286,6 +291,7 @@ func main() {
registryclient.WithNSEAdditionalFunctionality(
sendfd.NewNetworkServiceEndpointRegistryClient(),
),
registryclient.WithAuthorizeNSERegistryClient(registryauthorize.NewNetworkServiceEndpointRegistryClient()),
)
_, err = nseRegistryClient.Register(ctx, &registryapi.NetworkServiceEndpoint{
Name: config.Name,
Expand Down

0 comments on commit 5346c0b

Please sign in to comment.