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 custom policies support #566

Merged
Merged
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
26 changes: 16 additions & 10 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,14 @@ import (

// Config is configuration for cmd-registry-memory
type Config struct {
ListenOn []url.URL `default:"unix:///listen.on.socket" desc:"url to listen on." split_words:"true"`
MaxTokenLifetime time.Duration `default:"10m" desc:"maximum lifetime of tokens" split_words:"true"`
ProxyRegistryURL url.URL `desc:"url to the proxy registry that handles this domain" split_words:"true"`
ExpirePeriod time.Duration `default:"1s" desc:"period to check expired NSEs" 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"`
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"`
ProxyRegistryURL url.URL `desc:"url to the proxy registry that handles this domain" split_words:"true"`
ExpirePeriod time.Duration `default:"1s" desc:"period to check expired NSEs" 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 @@ -151,10 +153,14 @@ func main() {
memory.NewServer(
ctx,
spiffejwt.TokenGeneratorFunc(source, config.MaxTokenLifetime),
memory.WithAuthorizeNSERegistryServer(authorize.NewNetworkServiceEndpointRegistryServer()),
memory.WithAuthorizeNSERegistryClient(authorize.NewNetworkServiceEndpointRegistryClient()),
memory.WithAuthorizeNSRegistryServer(authorize.NewNetworkServiceRegistryServer()),
memory.WithAuthorizeNSRegistryClient(authorize.NewNetworkServiceRegistryClient()),
memory.WithAuthorizeNSERegistryServer(authorize.NewNetworkServiceEndpointRegistryServer(
authorize.WithPolicies(config.RegistryServerPolicies...))),
memory.WithAuthorizeNSERegistryClient(authorize.NewNetworkServiceEndpointRegistryClient(
authorize.WithPolicies(config.RegistryClientPolicies...))),
memory.WithAuthorizeNSRegistryServer(authorize.NewNetworkServiceRegistryServer(
authorize.WithPolicies(config.RegistryServerPolicies...))),
memory.WithAuthorizeNSRegistryClient(authorize.NewNetworkServiceRegistryClient(
authorize.WithPolicies(config.RegistryClientPolicies...))),
memory.WithExpireDuration(time.Minute),
memory.WithProxyRegistryURL(&config.ProxyRegistryURL),
memory.WithDialOptions(clientOptions...)).Register(server)
Expand Down