Skip to content

Commit

Permalink
Merge pull request #400 from NikitaSkrynnik/add-policies
Browse files Browse the repository at this point in the history
Add custom policies support
  • Loading branch information
denis-tingaikin authored Dec 18, 2022
2 parents 4f13c13 + f51ed0c commit 39be043
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,16 @@ import (

// Config is configuration for cmd-nsmgr-proxy
type Config struct {
ListenOn []url.URL `default:"unix:///listen.on.socket" desc:"url to listen on." split_words:"true"`
Name string `default:"nsmgr-proxy" desc:"Name of Network service manager proxy"`
MaxTokenLifetime time.Duration `default:"10m" desc:"maximum lifetime of tokens" split_words:"true"`
MapIPFilePath string `default:"map-ip.yaml" desc:"Path to file that contains map of internal to external IPs" split_words:"true"`
RegistryProxyURL *url.URL `desc:"URL to registry proxy. All incoming interdomain registry requests will be proxying by the URL" split_words:"true"`
RegistryURL *url.URL `desc:"URL to registry. All incoming local registry requests will be proxying by the URL" split_words:"true"`
LogLevel string `default:"INFO" desc:"Log level" split_words:"true"`
OpenTelemetryEndpoint string `default:"otel-collector.observability.svc.cluster.local:4317" desc:"OpenTelemetry Collector Endpoint"`
ListenOn []url.URL `default:"unix:///listen.on.socket" desc:"url to listen on." split_words:"true"`
Name string `default:"nsmgr-proxy" desc:"Name of Network service manager proxy"`
MaxTokenLifetime time.Duration `default:"10m" desc:"maximum lifetime of tokens" split_words:"true"`
RegistryServerPolicies []string `default:"etc/nsm/opa/common/.*.rego,etc/nsm/opa/registry/.*.rego,etc/nsm/opa/server/.*.rego" desc:"paths to files and directories that contain registry server policies" split_words:"true"`
RegistryClientPolicies []string `default:"etc/nsm/opa/common/.*.rego,etc/nsm/opa/registry/.*.rego,etc/nsm/opa/client/.*.rego" desc:"paths to files and directories that contain registry client policies" split_words:"true"`
MapIPFilePath string `default:"map-ip.yaml" desc:"Path to file that contains map of internal to external IPs" split_words:"true"`
RegistryProxyURL *url.URL `desc:"URL to registry proxy. All incoming interdomain registry requests will be proxying by the URL" split_words:"true"`
RegistryURL *url.URL `desc:"URL to registry. All incoming local registry requests will be proxying by the URL" split_words:"true"`
LogLevel string `default:"INFO" desc:"Log level" split_words:"true"`
OpenTelemetryEndpoint string `default:"otel-collector.observability.svc.cluster.local:4317" desc:"OpenTelemetry Collector Endpoint"`
}

func main() {
Expand Down Expand Up @@ -150,9 +152,7 @@ func main() {
),
grpc.WithTransportCredentials(
grpcfd.TransportCredentials(
credentials.NewTLS(
tlsClientConfig,
),
credentials.NewTLS(tlsClientConfig),
),
),
grpcfd.WithChainStreamInterceptor(),
Expand All @@ -172,8 +172,14 @@ func main() {
nsmgrproxy.WithListenOn(listenURL),
nsmgrproxy.WithDialOptions(dialOptions...),
nsmgrproxy.WithMapIPFilePath(config.MapIPFilePath),
nsmgrproxy.WithAuthorizeNSERegistryServer(authorize.NewNetworkServiceEndpointRegistryServer(authorize.Any())),
nsmgrproxy.WithAuthorizeNSRegistryServer(authorize.NewNetworkServiceRegistryServer(authorize.Any())),
nsmgrproxy.WithAuthorizeNSERegistryServer(authorize.NewNetworkServiceEndpointRegistryServer(authorize.WithPolicies(
config.RegistryServerPolicies...))),
nsmgrproxy.WithAuthorizeNSERegistryClient(authorize.NewNetworkServiceEndpointRegistryClient(authorize.WithPolicies(
config.RegistryClientPolicies...))),
nsmgrproxy.WithAuthorizeNSRegistryServer(authorize.NewNetworkServiceRegistryServer(authorize.WithPolicies(
config.RegistryServerPolicies...))),
nsmgrproxy.WithAuthorizeNSRegistryClient(authorize.NewNetworkServiceRegistryClient(authorize.WithPolicies(
config.RegistryClientPolicies...))),
).Register(server)

for i := 0; i < len(config.ListenOn); i++ {
Expand Down

0 comments on commit 39be043

Please sign in to comment.