delboy1978uk / bone-firewall
Firewall package for Bone Framework
Installs: 1 373
Dependents: 2
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: ^8.2
- delboy1978uk/barnacle: ^2.3
- delboy1978uk/bone-http: ^2.4
- delboy1978uk/bone-router: ^1.4
- psr/http-message: ^2.0
- psr/http-server-middleware: ^1.0
Requires (Dev)
- codeception/codeception: ^5.1
- codeception/module-asserts: ^3.0
- codeception/module-phpbrowser: ^3.0
- laminas/laminas-diactoros: ^3.3
- roave/security-advisories: dev-latest
README
Firewall package for controlling Bone Framework vendor package routes.
installation
Use Composer
composer require delboy1978uk/bone-firewall
usage
Simply add to the config/packages.php
<?php // use statements here use Bone\Firewall\Firewall\FirewallPackage; return [ 'packages' => [ // packages here..., FirewallPackage::class, ], // ... ];
blocking routes
And add a list of blockedRoutes
to your config. As an example here, package delboy1978uk/bone-user
has an endpoint
for a visitor to register a user account. If you don't want endpoints like these exposed you can add the path that is
configured in the package's addRoutes(Container $c, Router $router)
method that adds the routes, you can use the
wildcard strings too as shown here.
<?php return [ 'blockedRoutes' => [ '/user/register', '/user/lost-password/{email}', ], ];
adding middleware
Sometimes you might want to add middleware to a route coming from a vendor package, you can do this also by adding the following config key. Each key can hold either an actual instance of the middleware, a string representing the middleware which would be found in the container, or an array of either if you wish to add multiple middlewares.
return [ 'blockedRoutes' => [ // etc ], 'routeMiddleware' => [ '/api/some/endpoint' => SomeMiddleware::class, '/api/another/endpoint' => new AwesomeMiddleware(), '/api/yet/another/endpoint' => [ new AwesomeMiddleware(), SomeMidlleware::class, ], ], ];