Skip to content

Commit e03e9ef

Browse files
committed
Add Securing API section to README
1 parent ec59655 commit e03e9ef

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,22 @@ You can set your own default Wi-Fi SSID and a Wi-Fi password for your hotspot us
1313

1414
Enjoy and please do feel free to feedback experiences and issues.
1515

16+
## Securing the API
17+
18+
By default, the API is exposed so your interface can interact directly. In other words, anyone can go to `http://your-device:9090/v1/connect` to send commands to your device. If you would prefer to only allow access from your backend, change the following line in run.py:
19+
20+
```diff
21+
- app.run(port=9090, host='0.0.0.0')
22+
+ app.run(port=9090, host='127.0.0.1')
23+
```
24+
25+
Then ensure your backend container is connected to the host network so it matches the API docker-compose.yml file in this repo:
26+
27+
`network_mode: "host"`
28+
29+
Users will then be unable to access the API `http://your-device:9090/v1/connect`. Your backend container on the device, however, can reach the API using `http://127.0.0.1:9090/v1/connect`. This is useful if your interface has a login process, and you only want users to be able to interact with Wi-Fi after logging in.
30+
31+
1632

1733
## Endpoints
1834

0 commit comments

Comments
 (0)