Implement Policy Enforcer Plugin

- Added a new Policy Enforcer plugin to evaluate incoming messages against OPA policies.
- Configurable via YAML with options for policy sources, actions, and query.
- Integrated into existing configuration files for BAP and BPP.
- Updated related tests and documentation for the new functionality.
- Enhanced plugin manager to support Policy Enforcer instantiation.
This commit is contained in:
Ayush Rawat
2026-02-26 17:46:52 +05:30
parent fe541227b9
commit 3617c9b4a6
22 changed files with 1341 additions and 39 deletions

View File

@@ -0,0 +1,26 @@
// Package main provides the plugin entry point for the Policy Enforcer plugin.
// This file is compiled as a Go plugin (.so) and loaded by beckn-onix at runtime.
package main
import (
"context"
"github.com/beckn-one/beckn-onix/pkg/plugin/definition"
"github.com/beckn-one/beckn-onix/pkg/plugin/implementation/policyenforcer"
)
// provider implements the PolicyEnforcerProvider interface for plugin loading.
type provider struct{}
// New creates a new PolicyEnforcer instance.
func (p provider) New(ctx context.Context, cfg map[string]string) (definition.PolicyEnforcer, func(), error) {
enforcer, err := policyenforcer.New(cfg)
if err != nil {
return nil, nil, err
}
return enforcer, enforcer.Close, nil
}
// Provider is the exported symbol that beckn-onix plugin manager looks up.
var Provider = provider{}