Load a helper module without a separate decision
Use ignoreDecision for a helper module referenced by an enforcing module. The helper does not need its own allow decision. ignoreDecision does not enable automatic shadow evaluation of an independent candidate policy.
Configuration
apiVersion: kuma.io/v1alpha1
kind: MeshOPA
metadata:
name: candidate-rule
namespace: kong-mesh-demo
labels:
kuma.io/mesh: default
spec:
targetRef:
kind: Dataplane
labels:
app: backend
default:
appendPolicies:
- ignoreDecision: true
rego:
type: InsecureInline
insecureInline:
value: |
package backend.helpers
import input.attributes.request.http as http_request
method_is_get {
http_request.method == "GET"
}
- rego:
type: InsecureInline
insecureInline:
value: |
package backend.authorization
default allow = false
allow {
data.backend.helpers.method_is_get
}Copied!
type: MeshOPA
name: candidate-rule
mesh: default
spec:
targetRef:
kind: Dataplane
labels:
app: backend
default:
appendPolicies:
- ignoreDecision: true
rego:
type: InsecureInline
insecureInline:
value: |
package backend.helpers
import input.attributes.request.http as http_request
method_is_get {
http_request.method == "GET"
}
- rego:
type: InsecureInline
insecureInline:
value: |
package backend.authorization
default allow = false
allow {
data.backend.helpers.method_is_get
}Copied!
Adjust konnect_mesh_control_plane.my_meshcontrolplane.id and konnect_mesh.my_mesh.name according to your current configuration.
resource "konnect_mesh_opa" "candidate_rule" {
provider = konnect-beta
type = "MeshOPA"
name = "candidate-rule"
spec = {
target_ref = {
kind = "Dataplane"
labels = {
app = "backend"
}
}
default = {
append_policies = [
{
ignore_decision = true
rego = {
type = "InsecureInline"
insecure_inline = {
value = <<-EOT
package backend.helpers
import input.attributes.request.http as http_request
method_is_get {
http_request.method == "GET"
}
EOT
}
}
},
{
rego = {
type = "InsecureInline"
insecure_inline = {
value = <<-EOT
package backend.authorization
default allow = false
allow {
data.backend.helpers.method_is_get
}
EOT
}
}
}
]
}
}
labels = {
"kuma.io/mesh" = konnect_mesh.my_mesh.name
}
cp_id = konnect_mesh_control_plane.my_meshcontrolplane.id
mesh = konnect_mesh.my_mesh.name
}
Copied!