PHPackages                             iwf-web/json-request-check-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Security](/categories/security)
4. /
5. iwf-web/json-request-check-bundle

ActiveSymfony-bundle[Security](/categories/security)

iwf-web/json-request-check-bundle
=================================

Symfony bundle to protect against HashDos attacks by limiting JSON request size

v1.1.0(11mo ago)21.4k↓33.3%MITPHPPHP &gt;=8.2CI passing

Since Feb 25Pushed 7mo ago8 watchersCompare

[ Source](https://github.com/iwf-web/json-request-check-bundle)[ Packagist](https://packagist.org/packages/iwf-web/json-request-check-bundle)[ RSS](/packages/iwf-web-json-request-check-bundle/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (4)Versions (4)Used By (0)

IWF JSON Request Check Bundle
=============================

[](#iwf-json-request-check-bundle)

This Symfony bundle protects against HashDos attacks by limiting the size of JSON requests.

Project

[![License](https://camo.githubusercontent.com/d75625d0563996af5edacfcf7b83dbf98e9a7e1a95144ee782c9cea6909a671c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6977662d7765622f6a736f6e2d726571756573742d636865636b2d62756e646c65)](https://github.com/iwf-web/json-request-check-bundle/blob/main/LICENSE.txt)[![Version](https://camo.githubusercontent.com/6430adbd8d6fad4a3435ec98525027d554a33cf5ce2c77f450c631b855635d16/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6977662d7765622f6a736f6e2d726571756573742d636865636b2d62756e646c653f6c6162656c3d6c617465737425323072656c65617365)](https://packagist.org/packages/iwf-web/json-request-check-bundle)[![Version (including pre-releases)](https://camo.githubusercontent.com/90e54220127c9969f3aa176725ec2b98b1e00e004ba939961bfbad231fa2bb7d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6977662d7765622f6a736f6e2d726571756573742d636865636b2d62756e646c653f696e636c7564655f70726572656c6561736573266c6162656c3d6c61746573742532307072652d72656c65617365)](https://packagist.org/packages/iwf-web/json-request-check-bundle)[![Downloads on Packagist](https://camo.githubusercontent.com/bb1738d07031014efb341ba0882c492a3356ea175ea5a020595f99cf7c9f5c65/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6977662d7765622f6a736f6e2d726571756573742d636865636b2d62756e646c65)](https://packagist.org/packages/iwf-web/json-request-check-bundle)[![Required PHP version](https://camo.githubusercontent.com/a66e5be9aad2f3bf123f5198cd87a2b7dff0927ac45371e233d536cd3e15b12e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6977662d7765622f6a736f6e2d726571756573742d636865636b2d62756e646c65)](https://packagist.org/packages/iwf-web/json-request-check-bundle)

Getting Started
---------------

[](#getting-started)

These instructions will help you install this library in your project and tell you how to use it.

### Prerequisites

[](#prerequisites)

- PHP 8.2 or higher
- Symfony 6.0 or higher
- Composer for dependency management

### Installing

[](#installing)

#### Step 1: Install Package

[](#step-1-install-package)

```
composer require iwf-web/json-request-check-bundle
```

#### Step 2: Register Bundle (Symfony &lt; 5.0)

[](#step-2-register-bundle-symfony--50)

For Symfony versions before 5.0, you need to manually register the bundle in your `config/bundles.php`:

```
// config/bundles.php
return [
    // ...
    IWF\JsonRequestCheckBundle\IWFJsonRequestCheckBundle::class => ['all' => true],
];
```

### Configuration

[](#configuration)

Create a configuration file at `config/packages/iwf_json_request_check.yaml`:

```
iwf_json_request_check:
    default_max_content_length: 10240 # Default: 10KB
```

Alternatively, you can define the default value as an environment variable in your `.env` file:

```
# .env or .env.local
IWF_JSON_REQUEST_CHECK_DEFAULT_MAX_LENGTH=10240
```

and then use it in your configuration file:

```
# config/packages/iwf_json_request_check.yaml
iwf_json_request_check:
    default_max_content_length: '%env(int:IWF_JSON_REQUEST_CHECK_DEFAULT_MAX_LENGTH)%'
```

To have a clue about size you can find a file with a JSON of **4kb** in the examples: [example-payload-4kb.json](examples/files/example-payload-4kb.json)

### Usage

[](#usage)

#### Add the Attribute to Controller Methods

[](#add-the-attribute-to-controller-methods)

```
