Download the PHP package iwf-web/json-request-check-bundle without Composer
On this page you can find all versions of the php package iwf-web/json-request-check-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download iwf-web/json-request-check-bundle
More information about iwf-web/json-request-check-bundle
Files in iwf-web/json-request-check-bundle
Package json-request-check-bundle
Short Description Symfony bundle to protect against HashDos attacks by limiting JSON request size
License MIT
Informations about the package json-request-check-bundle
IWF JSON Request Check Bundle
This Symfony bundle protects against HashDos attacks by limiting the size of JSON requests.
Project
Getting Started
These instructions will help you install this library in your project and tell you how to use it.
Prerequisites
- PHP 8.2 or higher
- Symfony 6.0 or higher
- Composer for dependency management
Installing
Step 1: Install Package
Step 2: Register Bundle (Symfony < 5.0)
For Symfony versions before 5.0, you need to manually register the bundle in your config/bundles.php:
Configuration
Create a configuration file at config/packages/iwf_json_request_check.yaml:
Alternatively, you can define the default value as an environment variable in your .env file:
and then use it in your configuration file:
To have a clue about size you can find a file with a JSON of 4kb in the examples: example-payload-4kb.json
Usage
Add the Attribute to Controller Methods
How It Works
- When a JSON request is sent to your controller, the
JsonRequestCheckSubscriberchecks the size of the request. - If the size exceeds the value specified in the
JsonRequestCheckattribute, an HTTP 413 (Payload Too Large) Exception is triggered. - If no specific value is provided for the route, the global default value from the configuration is used.
Error Messages
When a request exceeds the allowed size, an HTTP 413 response is automatically returned with the message "JSON payload too large" along with details about the received size and maximum allowed size.
Local Development Setup
Installing Development Tools
This project uses PHIVE for managing PHP development tools. Follow these steps to set up your local development environment:
Step 1: Install PHIVE
Step 2: Install Development Dependencies
Running Code Quality Checks
PHP-CS-Fixer (Code Style)
Check code style violations:
Fix code style violations automatically:
PHPStan (Static Analysis)
Run PHPStan analysis:
Generate PHPStan baseline for existing issues:
Development Workflow
Before committing your changes, ensure all checks pass:
Built With
Contributing
Please read CONTRIBUTING.md for the process for submitting pull requests to us.
Versioning
We use SemVer for versioning. For the versions available, see the tags on this repository.
Authors
All the authors can be seen in the AUTHORS.md file.
Contributors can be seen in the CONTRIBUTORS.md file.
See also the full list of contributors who participated in this project.
License
This project is licensed under the MIT License - see the LICENSE.txt file for details
Acknowledgments
A list of used libraries and code with their licenses can be seen in the ACKNOWLEDGMENTS.md file.
All versions of json-request-check-bundle with dependencies
symfony/framework-bundle Version ^6.0|^7.0
symfony/dependency-injection Version ^6.0|^7.0
symfony/http-kernel Version ^6.0|^7.0
symfony/config Version ^6.0|^7.0