Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add OPA policy to registry-memory #548

Merged
merged 3 commits into from
Sep 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/golang/protobuf v1.5.2
github.com/kelseyhightower/envconfig v1.4.0
github.com/networkservicemesh/api v1.4.1-0.20220711153918-a59689088578
github.com/networkservicemesh/sdk v0.5.1-0.20220914233340-97e00ecbb074
github.com/networkservicemesh/sdk v0.5.1-0.20220916121847-88b2169efe99
github.com/sirupsen/logrus v1.9.0
github.com/spiffe/go-spiffe/v2 v2.0.0
github.com/stretchr/testify v1.8.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182aff
github.com/miekg/dns v1.1.50 h1:DQUfb9uc6smULcREF09Uc+/Gd46YWqJd5DbpPE9xkcA=
github.com/networkservicemesh/api v1.4.1-0.20220711153918-a59689088578 h1:2MZD6SGFULqTgMKA8BFy7F+ldRErAyxsWht7oCwCVRM=
github.com/networkservicemesh/api v1.4.1-0.20220711153918-a59689088578/go.mod h1:hOF2844BSstH1311oDMDgqqXS+kdc77htZNPRKl9mf8=
github.com/networkservicemesh/sdk v0.5.1-0.20220914233340-97e00ecbb074 h1:UzfImaVm+EnC6gFlT4KmcAvaYLPgHcuXLBoMOfalvMY=
github.com/networkservicemesh/sdk v0.5.1-0.20220914233340-97e00ecbb074/go.mod h1:YnWv4wspKOtfFsc7kC5tfs7n95Snj3C0MRCal7yytVE=
github.com/networkservicemesh/sdk v0.5.1-0.20220916121847-88b2169efe99 h1:kidNCyBjAx0T3ynKbMggWhVtzpVohvVuy7zW8bYobU0=
github.com/networkservicemesh/sdk v0.5.1-0.20220916121847-88b2169efe99/go.mod h1:YnWv4wspKOtfFsc7kC5tfs7n95Snj3C0MRCal7yytVE=
github.com/open-policy-agent/opa v0.44.0 h1:sEZthsrWBqIN+ShTMJ0Hcz6a3GkYsY4FaB2S/ou2hZk=
github.com/open-policy-agent/opa v0.44.0/go.mod h1:YpJaFIk5pq89n/k72c1lVvfvR5uopdJft2tMg1CW/yU=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
Expand Down
14 changes: 10 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

//go:build !windows

// Package main defines a registry-memory application
package main

import (
Expand All @@ -41,6 +42,7 @@ import (
"google.golang.org/grpc/credentials"

"github.com/networkservicemesh/sdk/pkg/registry/chains/memory"
"github.com/networkservicemesh/sdk/pkg/registry/common/authorize"
"github.com/networkservicemesh/sdk/pkg/tools/debug"
"github.com/networkservicemesh/sdk/pkg/tools/grpcutils"
"github.com/networkservicemesh/sdk/pkg/tools/log"
Expand Down Expand Up @@ -137,13 +139,17 @@ func main() {
grpc.WithDefaultCallOptions(grpc.WaitForReady(true)),
grpc.WithTransportCredentials(
grpcfd.TransportCredentials(
credentials.NewTLS(
tlsClientConfig,
),
credentials.NewTLS(tlsClientConfig),
),
),
)
memory.NewServer(ctx, time.Minute, &config.ProxyRegistryURL, clientOptions...).Register(server)
memory.NewServer(
ctx,
memory.WithAuthorizeNSRegistryServer(authorize.NewNetworkServiceRegistryServer()),
memory.WithAuthorizeNSERegistryServer(authorize.NewNetworkServiceEndpointRegistryServer()),
memory.WithExpireDuration(time.Minute),
memory.WithProxyRegistryURL(&config.ProxyRegistryURL),
memory.WithDialOptions(clientOptions...)).Register(server)

for i := 0; i < len(config.ListenOn); i++ {
srvErrCh := grpcutils.ListenAndServe(ctx, &config.ListenOn[i], server)
Expand Down
1 change: 1 addition & 0 deletions pkg/imports/imports_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
_ "github.com/kelseyhightower/envconfig"
_ "github.com/networkservicemesh/api/pkg/api/registry"
_ "github.com/networkservicemesh/sdk/pkg/registry/chains/memory"
_ "github.com/networkservicemesh/sdk/pkg/registry/common/authorize"
_ "github.com/networkservicemesh/sdk/pkg/registry/common/begin"
_ "github.com/networkservicemesh/sdk/pkg/registry/common/refresh"
_ "github.com/networkservicemesh/sdk/pkg/registry/core/next"
Expand Down