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:
26
pkg/plugin/implementation/policyenforcer/cmd/plugin.go
Normal file
26
pkg/plugin/implementation/policyenforcer/cmd/plugin.go
Normal 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{}
|
||||
Reference in New Issue
Block a user