Download the PHP package kuick/security without Composer
On this page you can find all versions of the php package kuick/security. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download kuick/security
More information about kuick/security
Files in kuick/security
Package security
Short Description Kuick Security is a package for security related tasks. Includes PSR-15 middleware implementation
License MIT
Informations about the package security
Kuick Security
Security package implementing PSR-15 middleware
Key features
- PSR-15(https://www.php-fig.org/psr/psr-15/) security middleware implementation
- Support for flexible Guards (any callable)
- Guardhouse service with methods to register Guards (regex path support)
Installation
Usage
1. Create a guard
A guard is any invokable object (or closure) accepting a ServerRequestInterface and returning void|null.
Throw a Kuick\Http\HttpException to deny the request.
2. Register guards in the Guardhouse
Use addGuard(string $path, object $guard, array $methods = [...]) to register guards.
The $path is a full regex (anchored as #^…$#). Named capture groups are merged into the request's query params.
By default (when $methods is omitted), a guard matches all HTTP methods: GET, POST, PUT, PATCH, DELETE, OPTIONS. HEAD is automatically included whenever GET is listed.
3. Wire up the PSR-15 middleware
Pass the Guardhouse to SecurityMiddleware and add it to your PSR-15 middleware stack.
If a guard throws a Kuick\Http\HttpException the exception propagates up — your framework's error handler is responsible for converting it into an HTTP response. If all guards pass, the request is forwarded to $nextHandler.
Path regex & captured parameters
Regex captures (named or positional) from the matched path are merged into the request's query params before the guard is invoked: