ops-talent/securitybundle
A Laravel security bundle that brings common hardening tools together in one package, with configurable middleware and sensible defaults to help protect your application.
composer require ops-talent/securitybundle
app/AppKernel.php:
new OpsTalent\SecurityBundle\SecurityBundle(),
For Symfony 4+ use config/bundles.php (this package is from the 2018 era, so verify the namespace resolves — it may be OpsTalent\SecurityBundle\OpsTalentSecurityBundle).DependencyInjection/Configuration.php — the config tree and every accepted option key.Resources/config/services.yml — service IDs and tags you'll reference.README and Tests/ fixtures.opstalent/apibundle. Define a stateless firewall for your API path and a matching access_control rule:
# app/config/security.yml (Symfony 3 style)
security:
firewalls:
api:
pattern: ^/api
stateless: true
# provider/authenticator keys from the bundle's Configuration.php
access_control:
- { path: ^/api, roles: IS_AUTHENTICATED_FULLY }
apibundle routes so the security listeners apply first.stateless: true and avoid sessions for API routes. Split firewalls when you have public (login/register) vs. protected API segments.providers.your_provider on the firewall. This is the standard Symfony pattern and the bundle delegates to it.guard: { authenticators: [...] } (Symfony 3.3+) or override the entry point. Don't hand-roll a parallel authenticator unless the shipped one lacks a feature — you'll fork the bundle's config contract.opstalent/apibundle auto-generates controllers, you generally cannot annotate each action; instead express authorization with ordered access_control patterns (most specific first) keyed to URL prefixes.ROLE_API_USER, ROLE_API_ADMIN) in a config parameter so access_control and the bundle's voter/checker stay in sync.$this->denyAccessUnlessGranted()).symfony/phpunit-bridge and functional tests with a mocked token header to assert 401/403 vs. 200. This is the fastest feedback loop for a bundle with no upstream CI.app/config, web/app_dev.php era). On Symfony 4+/5+ you'll likely need to bridge legacy service definitions, KernelInterface::MASTER_REQUEST constants, and the old security.encoders config.DependencyInjection/Configuration.php — older bundles silently ignore unknown keys or fail only on container build.monolog level for the security channel and inspect dev.log for authenticator decisions — the bundle's entry point typically logs to this channel.kernel.request/kernel.exception, a custom user provider, or a compiler pass that decorates the bundle's entry-point/authenticator service. All survive composer update.composer.json (e.g. "ops-talent/securitybundle": "1.*") so a future tag or branch rename doesn't silently change your auth surface.cache:clear (or rm -rf var/cache) after every security.yml edit — otherwise stale firewall definitions cause confusing 404s on /api.How can I help you explore Laravel packages today?