Skip to content

Commit

Permalink
Merge pull request #135 from AikidoSec/AIK-3528
Browse files Browse the repository at this point in the history
Add documentation for Quart web framework
  • Loading branch information
willem-delbare authored Sep 2, 2024
2 parents 9a30a79 + 1041ed0 commit e38ede2
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Aikido Firewall for Python 3 is compatible with:

*[Django](docs/django.md)
*[Flask](docs/flask.md)
*[Quart](docs/quart.md)

### WSGI servers
*[Gunicorn](docs/gunicorn.md)
Expand Down
60 changes: 60 additions & 0 deletions docs/quart.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Quart

1. Install `aikido_firewall` package with pip :
```sh
pip install aikido_firewall
```

2. Add the following snippet to the top of your `app.py` file :
```python
import aikido_firewall
aikido_firewall.protect()
```
Make sure this is above any other import, including above builtin package imports.

3. Setting your environment variables :
Make sure to set your token in order to communicate with Aikido's servers
```env
AIKIDO_TOKEN="AIK_RUNTIME_YOUR_TOKEN_HERE"
```


## Warning: Installing middleware
When installing middleware make sure to install it like this :

```python
from quart import Quart
app = Quart(__name__)
...
app.asgi_app = my_middleware(app.asgi_app)
```

and not like this :

```python
app.asgi_app = my_middleware
```

Since this removes all other middleware.

## Blocking mode

By default, the firewall will run in non-blocking mode. When it detects an attack, the attack will be reported to Aikido and continue executing the call.

You can enable blocking mode by setting the environment variable `AIKIDO_BLOCKING` to `true`:

```sh
AIKIDO_BLOCKING=true
```

It's recommended to enable this on your staging environment for a considerable amount of time before enabling it on your production environment (e.g. one week).

## Debug mode

If you need to debug the firewall, you can run your code with the environment variable `AIKIDO_DEBUG` set to `true`:

```sh
AIKIDO_DEBUG=true
```

This will output debug information to the console (e.g. no token was found, unsupported packages, extra information, ...).

0 comments on commit e38ede2

Please sign in to comment.