@@ -19,28 +19,37 @@ Always protect the API with [**Api Key**](#api-security) and deny access by usin
1919
2020## TLDR
2121
22- Set those or WAHA generates ** random secrets** on startup (check logs):
22+ {{< callout context="note" icon="outline/info-circle" >}}
23+ WAHA generates ** random secrets** on startup (check logs)!
24+
25+ - If you want to set ** your own secrets** - generate them and set as environment variables (see below).
26+ - If you want to ** disable security** (not recommended) - read the [ FAQ] ( #how-to-disable-security ) .
27+ {{< /callout >}}
2328
24- ``` bash {title="Setup Security Environment Variables"}
25- # Generate random long secrets using
29+ ``` bash {title="Generate Secrets"}
2630$ uuidgen | tr -d ' -'
2731> 6c35dcbf31914c65a90f29e2ca1840d2
32+ ```
33+
34+ Add those env variables to your ` .env ` or ` docker-compose.yaml ` :
2835
29- # Enable Api Key protection
30- # Send "X-Api-Key" in all HTTP requests
36+ ``` bash {title=".env"}
3137WAHA_API_KEY=yoursecretkey
3238WAHA_API_KEY_PLAIN=yoursecretkey
33-
34- # Enable Dashboard protection
3539WAHA_DASHBOARD_USERNAME=admin
3640WAHA_DASHBOARD_PASSWORD=yoursecretpassword
37-
38- # Enable Swagger protection
39- # Use the same as for Dashboard
4041WHATSAPP_SWAGGER_USERNAME=admin
4142WHATSAPP_SWAGGER_PASSWORD=yoursecretpassword
4243```
4344
45+ Send ` X-Api-Key: yoursecretkey ` header in all API requests (including file downloads).
46+
47+ ``` bash {title="cURL Example"}
48+ curl -H ' X-Api-Key: yoursecretkey' http://localhost:3000/api/sessions
49+
50+ wget --header=' X-Api-Key: yoursecretkey' http://localhost:3000/api/files/MESSAGEID.jpg
51+ ```
52+
4453## API security
4554
4655You can protect the API by requiring ` X-Api-Key ` header in HTTP request.
@@ -163,22 +172,16 @@ You can set up the following environment variables to enable HTTPS:
163172
164173## FAQ
165174### How To Disable Security?
166- By default, WAHA checks those variables and if it's not set - generates a random one (check your console/logs output):
167- - ` WAHA_API_KEY `
168- - ` WAHA_DASHBOARD_PASSWORD `
169- - ` WHATSAPP_SWAGGER_PASSWORD `
170-
171- Even if you set this to "" (empty string) or "admin/waha/123" - WAHA generates a new value.
172175
173176If you ** 100% know what you are doing** - you can disable this explicilty and set to ` .env ` file:
174177``` bash
175178# Api Key - Off
176179WAHA_API_KEY=
177180WAHA_NO_API_KEY=True
178- # Dashboard - Auth Off
181+ # Dashboard - Auth Off (_PASSWORD MUST be empty string)
179182WAHA_DASHBOARD_PASSWORD=
180183WAHA_DASHBOARD_NO_PASSWORD=True
181- # Swagger - Auth Off
184+ # Swagger - Auth Off (_PASSWORD MUST be empty string)
182185WHATSAPP_SWAGGER_PASSWORD=
183186WHATSAPP_SWAGGER_NO_PASSWORD=True
184187```
0 commit comments