Skip to content

Commit

Permalink
Revert "evaluate opa policy through inbound filter"
Browse files Browse the repository at this point in the history
This reverts commit c7ff6ed.
  • Loading branch information
qlonik committed Feb 26, 2024
1 parent 54be19f commit 0c1d42d
Showing 1 changed file with 0 additions and 49 deletions.
49 changes: 0 additions & 49 deletions privacy-profile-composer/pkg/envoyfilter/inbound_filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"net/url"

"github.com/envoyproxy/envoy/contrib/golang/common/go/api"
"github.com/open-policy-agent/opa/sdk"
"github.com/openzipkin/zipkin-go"
"github.com/openzipkin/zipkin-go/model"
"google.golang.org/grpc"
Expand Down Expand Up @@ -59,54 +58,6 @@ func (f *inboundFilter) DecodeHeaders(header api.RequestHeaderMap, endStream boo

common.LogDecodeHeaderData(header)

ctx := context.Background()
// Replace url with http://prose-server.prose-system.svc.cluster.local:8080
// Remove the leading /bundles/ in the resource // bundles.default.resource=bundle.tar.gz
opa_config := []byte(`{
"services": {
"bundles": {
"url": "http://prose-server.prose-system.svc.cluster.local:8080"
}
},
"bundles": {
"default": {
"resource": "/bundles/bundle.tar.gz",
"polling": {
"min_delay_seconds": 120,
"max_delay_seconds": 3600,
}
}
},
"decision_logs": {
"console": true
}
}`)

log.Printf("about to instantiate a new opaObj sdk object\n")
// create an instance of the OPA object
opaObj, err := sdk.New(ctx, sdk.Options{
ID: "opaObj-test-1",
Config: bytes.NewReader(opa_config),
})
log.Printf("got a response from sdk.New\n")

if err != nil {
log.Printf("could not initialize an OPA object --- this means that the data plane cannot evaluate the target privacy policy ----- %s\n", err)
return api.Continue
}

defer opaObj.Stop(ctx)
log.Printf("initialized an OPA object\n")

// get the named policy decision for the specified input
if result, err := opaObj.Decision(ctx, sdk.DecisionOptions{Path: "/authz/allow", Input: map[string]interface{}{"hello": "world"}}); err != nil {
log.Printf("had an error evaluating the policy: %s\n", err)
} else if decision, ok := result.Result.(bool); !ok || !decision {
log.Printf("result: descision: %v, ok: %v\n", decision, ok)
} else {
log.Printf("policy accepted the input data \n")
}

return api.Continue
}

Expand Down

0 comments on commit 0c1d42d

Please sign in to comment.