-
Notifications
You must be signed in to change notification settings - Fork 0
refactor: remove OPA/Cedar/permit.io stubs from engine #176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -3,7 +3,6 @@ package module | |||||
| import ( | ||||||
| "context" | ||||||
| "fmt" | ||||||
| "log/slog" | ||||||
| "sync" | ||||||
|
|
||||||
| "github.com/CrisisTextLine/modular" | ||||||
|
|
@@ -31,7 +30,7 @@ type PolicyInfo struct { | |||||
| } | ||||||
|
|
||||||
| // PolicyEngineModule is a workflow module wrapping a pluggable PolicyEngine backend. | ||||||
| // Supported backends: "mock", "opa", "cedar". | ||||||
| // Supported backends: "mock". For OPA or Cedar, use external plugins. | ||||||
| type PolicyEngineModule struct { | ||||||
| name string | ||||||
| config map[string]any | ||||||
|
|
@@ -54,20 +53,13 @@ func (m *PolicyEngineModule) Init(app modular.Application) error { | |||||
| m.backend = "mock" | ||||||
| } | ||||||
|
|
||||||
| allowStub := isTruthy(m.config["allow_stub_backends"]) | ||||||
|
|
||||||
| switch m.backend { | ||||||
| case "mock": | ||||||
| m.engine = newMockPolicyEngine() | ||||||
| case "opa": | ||||||
| endpoint, _ := m.config["endpoint"].(string) | ||||||
| m.engine = newOPAPolicyEngine(endpoint, allowStub) | ||||||
| slog.Warn("WARNING: using stub policy engine — all requests will be DENIED. Set allow_stub_backends: true in config to use stub backends for testing.", | ||||||
| "module", m.name, "backend", "opa", "allow_stub_backends", allowStub) | ||||||
| return fmt.Errorf("opa backend not built-in; use the workflow-plugin-policy-opa external plugin") | ||||||
| case "cedar": | ||||||
| m.engine = newCedarPolicyEngine(allowStub) | ||||||
| slog.Warn("WARNING: using stub policy engine — all requests will be DENIED. Set allow_stub_backends: true in config to use stub backends for testing.", | ||||||
| "module", m.name, "backend", "cedar", "allow_stub_backends", allowStub) | ||||||
| return fmt.Errorf("cedar backend not built-in; use the workflow-plugin-policy-cedar external plugin") | ||||||
|
||||||
| return fmt.Errorf("cedar backend not built-in; use the workflow-plugin-policy-cedar external plugin") | |
| return fmt.Errorf("cedar backend not built-in; install and load the workflow-plugin-policy-cedar external plugin, then use backend: 'mock' or configure the Cedar module type from the plugin") |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error message could be more actionable by including a brief instruction on how to use the external plugin. Consider: "opa backend not built-in; install and load the workflow-plugin-policy-opa external plugin, then use backend: 'mock' or configure the OPA module type from the plugin"