|
2 | 2 |
|
3 | 3 | # What is API Firewall?
|
4 | 4 |
|
5 |
| -Light-weighted Wallarm API Firewall protects your API endpoints in cloud-native environments with API schema validation. Wallarm API Firewall relies on a positive security model allowing calls that match a predefined API specification, while rejecting everything else. |
| 5 | +Wallarm API Firewall is an open-source light-weighted proxy designed to protect REST API endpoints in cloud-native environments by hardening based on a strict OpenAPI/Swagger schema validation. Wallarm API Firewall relies on a positive security model allowing calls that match a predefined API specification for requests and responses, while rejecting everything else. |
6 | 6 |
|
7 |
| -## API schema validation and positive security model |
| 7 | +The **key features** of API Firewall are: |
8 | 8 |
|
9 |
| -When starting API Firewall, you should provide the [OpenAPI 3.0 specification](https://swagger.io/specification/) of the application to be protected with API Firewall. The started API Firewall will operate as a reverse proxy and validate whether requests and responses match the schema defined in the specification. |
10 |
| - |
11 |
| -The traffic that does not match the schema will be logged using the [`STDOUT` and `STDERR` Docker services](https://docs.docker.com/config/containers/logging/) or blocked (depending on the configured API Firewall operation mode). If operating in the logging mode and detecting the traffic on endpoints that are not included in the specification, API Firewall also logs these endpoints as the shadow ones (except for endpoints returning the code `404`). |
12 |
| - |
13 |
| -Provided API schema should be described using the [OpenAPI 3.0 specification](https://swagger.io/specification/) in the YAML or JSON file (`.yaml`, `.yml`, `.json` file extensions). |
14 |
| - |
15 |
| -By allowing you to set the traffic requirements with the OpenAPI 3.0 specification, Wallarm API Firewall relies on a positive security model. |
16 |
| - |
17 |
| -## Technical characteristics |
18 |
| - |
19 |
| -API Firewall works as a reverse proxy with a built-in OpenAPI 3.0 request and response validator. The validator is written in Go and optimized for extreme performance and near-zero added latency. |
20 |
| - |
21 |
| -# How to use this image |
| 9 | +- Protect REST API endpoints by blocking requests and responses that do not match the OAS/Swagger schema |
| 10 | +- Discover Shadow API endpoints |
| 11 | +- If using OAuth 2.0 protocol-based authentication, validate access tokens |
| 12 | +- Quick and easy deployment and configuration |
| 13 | +- Customization of request and response processing modes, response codes and log format |
22 | 14 |
|
23 |
| -## Quick start with Docker |
| 15 | +# Use cases |
24 | 16 |
|
25 |
| -This quick start guide walks through downloading and starting Wallarm API Firewall with minimal configuration on Docker. |
| 17 | +- Block abnormal requests and responses that do not match the OpenAPI 3.0 specification (if running API Firewall in the blocking mode) |
| 18 | +- Discover Shadow APIs and undocumented endpoints (if running API Firewall in the logging mode) |
| 19 | +- Log abnormal requests and responses that do not match the OpenAPI 3.0 specification (if running API Firewall in the logging mode) |
26 | 20 |
|
27 |
| -### Requirements |
| 21 | +# API schema validation and positive security model |
28 | 22 |
|
29 |
| -- [Installed and configured Docker](https://docs.docker.com/get-docker/) |
30 |
| -- [OpenAPI 3.0 specification](https://swagger.io/specification/) developed for the REST API of the application that should be protected with Wallarm API Firewall |
31 |
| - |
32 |
| -### Up and running |
33 |
| - |
34 |
| -To run Wallarm API Firewall with minimal configuration on Docker: |
35 |
| - |
36 |
| -1. Create the Docker network to connect your application and Wallarm API Firewall (e.g. `api-firewall-network`): |
37 |
| - |
38 |
| - ```bash |
39 |
| - docker network create api-firewall-network |
40 |
| - ``` |
| 23 | +When starting API Firewall, you should provide the [OpenAPI 3.0 specification](https://swagger.io/specification/) of the application to be protected with API Firewall. The started API Firewall will operate as a reverse proxy and validate whether requests and responses match the schema defined in the specification. |
41 | 24 |
|
42 |
| -2. Start the containerized application to be protected with API Firewall (e.g. [kennethreitz/httpbin](https://hub.docker.com/r/kennethreitz/httpbin/)): |
| 25 | +The traffic that does not match the schema will be logged using the [`STDOUT` and `STDERR` Docker services](https://docs.docker.com/config/containers/logging/) or blocked (depending on the configured API Firewall operation mode). If operating in the logging mode and detecting the traffic on endpoints that are not included in the specification, API Firewall also logs these endpoints as the shadow ones (except for endpoints returning the code `404`). |
43 | 26 |
|
44 |
| - ```bash |
45 |
| - docker run --rm -it --network api-firewall-network \ |
46 |
| - --network-alias backend -p 8090:8090 kennethreitz/httpbin |
47 |
| - ``` |
| 27 | + |
48 | 28 |
|
49 |
| -3. Start the API Firewall image: |
| 29 | +Provided API schema should be described using the [OpenAPI 3.0 specification](https://swagger.io/specification/) in the YAML or JSON file (`.yaml`, `.yml`, `.json` file extensions). |
50 | 30 |
|
51 |
| - ```bash |
52 |
| - docker run --rm -it --network api-firewall-network --network-alias api-firewall \ |
53 |
| - -v <HOST_PATH_TO_SPEC>:<CONTAINER_PATH_TO_SPEC> -e APIFW_API_SPECS=<PATH_TO_MOUNTED_SPEC> \ |
54 |
| - -e APIFW_URL=<API_FIREWALL_URL> -e APIFW_SERVER_URL=<PROTECTED_APP_URL> \ |
55 |
| - -e APIFW_REQUEST_VALIDATION=<REQUEST_VALIDATION_MODE> -e APIFW_RESPONSE_VALIDATION=<RESPONSE_VALIDATION_MODE> \ |
56 |
| - -p 8088:8088 %%IMAGE%%:v0.6.5 |
57 |
| - ``` |
| 31 | +By allowing you to set the traffic requirements with the OpenAPI 3.0 specification, Wallarm API Firewall relies on a positive security model. |
58 | 32 |
|
59 |
| - | Variables | Description | |
60 |
| - |-----------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| |
61 |
| - | **For the `-v` option** | | |
62 |
| - | `<HOST_PATH_TO_SPEC>` | The path to the OpenAPI 3.0 specification for your application REST API located on the host machine. The accepted file formats are YAML and JSON (`.yaml`, `.yml`, `.json` file extensions). For example: `/opt/my-api/openapi3/swagger.json`. | |
63 |
| - | `<CONTAINER_PATH_TO_SPEC>` | The path to the container directory to mount the OpenAPI 3.0 specification to. For example: `/api-firewall/resources/swagger.json`. | |
64 |
| - | **For the `-e` option** | | |
65 |
| - | `APIFW_API_SPECS` | Path to the OpenAPI 3.0 specification mounted to the container. For example: `/api-firewall/resources/swagger.json`. | |
66 |
| - | `APIFW_URL` | URL for API Firewall. For example: `http://0.0.0.0:8088/`. The port value should correspond to the container port published to the host. | |
67 |
| - | `APIFW_SERVER_URL` | URL of the application described in the mounted OpenAPI specification that should be protected with API Firewall. For example: `http://backend:80`. | |
68 |
| - | `APIFW_REQUEST_VALIDATION` | API Firewall mode when validating requests sent to the application URL:<ul><li>`BLOCK` to block and log the requests that do not match the schema provided in the mounted OpenAPI 3.0 specification (the `403 Forbidden` response will be returned to the blocked requests). Logs are sent to the [`STDOUT` and `STDERR` Docker services](https://docs.docker.com/config/containers/logging/).</li><li>`LOG_ONLY` to log but not block the requests that do not match the schema provided in the mounted OpenAPI 3.0 specification. Logs are sent to the [`STDOUT` and `STDERR` Docker services](https://docs.docker.com/config/containers/logging/).</li><li>`DISABLE` to disable request validation.</li></ul> | |
69 |
| - | `APIFW_RESPONSE_VALIDATION` | API Firewall mode when validating application responses to incoming requests:<ul><li>`BLOCK` to block and log the request if the application response to this request does not match the schema provided in the mounted OpenAPI 3.0 specification. This request will be proxied to the application URL but the client will receive the `403 Forbidden` response. Logs are sent to the [`STDOUT` and `STDERR` Docker services](https://docs.docker.com/config/containers/logging/).</li><li>`LOG_ONLY` to log but not block the request if the application response to this request does not match the schema provided in the mounted OpenAPI 3.0 specification. Logs are sent to the [`STDOUT` and `STDERR` Docker services](https://docs.docker.com/config/containers/logging/).</li><li>`DISABLE` to disable request validation.</li></ul> | |
| 33 | +# Technical characteristics |
70 | 34 |
|
71 |
| -4. Test API Firewall operation by sending the request that does not match the mounted Open API 3.0 specification to the API Firewall Docker container address. For example, you can pass the string value in the parameter that requires the integer value. |
| 35 | +API Firewall works as a reverse proxy with a built-in OpenAPI 3.0 request and response validator. The validator is written in Go and optimized for extreme performance and near-zero added latency. |
72 | 36 |
|
73 |
| - If the request does not match the provided API schema, the appropriate ERROR message will be added to the API Firewall Docker container logs. |
| 37 | +# Starting API Firewall |
74 | 38 |
|
75 |
| -You have successfully started Wallarm API Firewall with minimal configuration. To learn advanced configuration options, please use the [separate instructions on running Wallarm API Firewall with Docker](https://docs.wallarm.com/api-firewall/installation-guides/docker-container/). |
| 39 | +To download, install, and start Wallarm API Firewall on Docker, see the [instructions](https://docs.wallarm.com/api-firewall/installation-guides/docker-container/). |
76 | 40 |
|
77 |
| -## Demos |
| 41 | +# Demos |
78 | 42 |
|
79 | 43 | You can try API Firewall by running the demo environment that deploys an example application protected with Wallarm API Firewall. There are two available demo environments:
|
80 | 44 |
|
81 | 45 | - [Wallarm API Firewall demo with Docker Compose](https://github.com/wallarm/api-firewall/tree/main/demo/docker-compose)
|
82 | 46 | - [Wallarm API Firewall demo with Kubernetes](https://github.com/wallarm/api-firewall/tree/main/demo/kubernetes)
|
| 47 | + |
| 48 | +# Wallarm's blog articles related to API Firewall |
| 49 | + |
| 50 | +- [Discovering Shadow APIs with API Firewall](https://lab.wallarm.com/discovering-shadow-apis-with-a-api-firewall/) |
| 51 | +- [Wallarm API Firewall outperforms NGINX in a production environment](https://lab.wallarm.com/wallarm-api-firewall-outperforms-nginx-in-a-production-environment/) |
| 52 | + |
| 53 | +# Performance |
| 54 | + |
| 55 | +When creating API Firewall, we prioritized speed and efficiency to ensure that our customers would have the fastest APIs possible. Our latest tests demonstrate that the average time required for API Firewall to process one request is 1.339 ms: |
| 56 | + |
| 57 | +```console |
| 58 | +$ ab -c 200 -n 10000 -p ./large.json -T application/json http://127.0.0.1:8282/test/signup |
| 59 | + |
| 60 | +Document Path: /test/signup |
| 61 | +Document Length: 20 bytes |
| 62 | + |
| 63 | +Concurrency Level: 200 |
| 64 | +Time taken for tests: 0.769 seconds |
| 65 | +Complete requests: 10000 |
| 66 | +Failed requests: 0 |
| 67 | +Total transferred: 2150000 bytes |
| 68 | +Total body sent: 283770000 |
| 69 | +HTML transferred: 200000 bytes |
| 70 | +Requests per second: 13005.81 [#/sec] (mean) |
| 71 | +Time per request: 15.378 [ms] (mean) |
| 72 | +Time per request: 0.077 [ms] (mean, across all concurrent requests) |
| 73 | +Transfer rate: 2730.71 [Kbytes/sec] received |
| 74 | + 360415.95 kb/s sent |
| 75 | + 363146.67 kb/s total |
| 76 | + |
| 77 | +Connection Times (ms) |
| 78 | + min mean[+/-sd] median max |
| 79 | +Connect: 0 5 1.6 5 12 |
| 80 | +Processing: 2 10 5.4 9 59 |
| 81 | +Waiting: 2 8 5.2 7 56 |
| 82 | +Total: 3 15 5.7 14 68 |
| 83 | + |
| 84 | +Percentage of the requests served within a certain time (ms) |
| 85 | + 50% 14 |
| 86 | + 66% 15 |
| 87 | + 75% 16 |
| 88 | + 80% 17 |
| 89 | + 90% 18 |
| 90 | + 95% 23 |
| 91 | + 98% 36 |
| 92 | + 99% 44 |
| 93 | + 100% 68 (longest request) |
| 94 | +``` |
| 95 | + |
| 96 | +These performance results are not the only ones we have got during API Firewall testing. Other results along with the methods used to improve API Firewall performance are described in this [Wallarm's blog article](https://lab.wallarm.com/wallarm-api-firewall-outperforms-nginx-in-a-production-environment/). |
0 commit comments