feat: add allowed parent namespaces for signature validation

This commit is contained in:
Nirmal N R
2026-01-20 19:52:45 +05:30
parent ce9583279a
commit 95e5c991a5
4 changed files with 168 additions and 7 deletions

View File

@@ -4,6 +4,7 @@ import (
"context"
"errors"
"strconv"
"strings"
"github.com/beckn-one/beckn-onix/pkg/log"
"github.com/beckn-one/beckn-onix/pkg/plugin/definition"
@@ -34,6 +35,10 @@ func (d dediRegistryProvider) New(ctx context.Context, config map[string]string)
}
}
if rawNamespaces, exists := config["allowedParentNamespaces"]; exists && rawNamespaces != "" {
dediConfig.AllowedParentNamespaces = parseAllowedParentNamespaces(rawNamespaces)
}
log.Debugf(ctx, "DeDi Registry config mapped: %+v", dediConfig)
dediClient, closer, err := dediregistry.New(ctx, dediConfig)
@@ -46,5 +51,18 @@ func (d dediRegistryProvider) New(ctx context.Context, config map[string]string)
return dediClient, closer, nil
}
func parseAllowedParentNamespaces(raw string) []string {
parts := strings.Split(raw, ",")
namespaces := make([]string, 0, len(parts))
for _, part := range parts {
item := strings.TrimSpace(part)
if item == "" {
continue
}
namespaces = append(namespaces, item)
}
return namespaces
}
// Provider is the exported plugin instance
var Provider = dediRegistryProvider{}