acrnogor/symfony-opa-form
Symfony middleware for authorization via build.security PDP/Open Policy Agent. Configure PDP host/port/policy path and timeouts in services.yaml, then use the OpenPolicyAgent service to send authz checks. Requires PHP 8+ and Symfony 4.4+.
pdp.hostname, pdp.port).pdp.policy.path).RequestContext and ResponseListenerInterface, which may need Laravel equivalents (e.g., custom middleware or a facade layer).Illuminate\Http\Request and Illuminate\Http\Response instead of Symfony’s RequestContext.// app/Http/Middleware/OpaAuthMiddleware.php
public function handle(Request $request, Closure $next) {
$response = $this->callOpa($request); // Custom logic to query OPA
if (!$response->isAllowed()) {
abort(403);
}
return $next($request);
}
config/opa.php) for consistency.OpaMiddleware).HttpClient.input.resource, input.user).ResponseListenerInterface → Laravel’s Illuminate\Contracts\Http\Kernel.RequestContext → Laravel’s Request object.config/opa.php:
return [
'endpoint' => 'http://opa-service:8181/v1/data/authz/allow',
'timeout_ms' => 5000,
];
Auth facade) to OPA.buildsecurity/symfony-opa for Laravel-compatible forks or updates.config/opa.php) to avoid hardcoded values.pdp.readTimeout.milliseconds for slow networks.| Failure Scenario | Impact | Mitigation |
|---|---|---|
| OPA Service Unavailable | All requests blocked (5xx) | Circuit breaker (e.g., Predis for Redis fallback). |
| Policy Evaluation Timeout | Request hangs | Set short timeouts; retry with fallback. |
| Malformed Policy | Silent denials or crashes | Validate policies in CI/CD. |
| Network Partition | Intermittent 403s | Local policy cache with stale-while-revalidate. |
| Policy Version Mismatch | Inconsistent authorization | Version policies (e.g., data.authz/allow/v1). |
How can I help you explore Laravel packages today?