added multi-key support for optional auth logic

This commit is contained in:
Luxferre
2026-07-11 10:02:48 +03:00
parent 2439257729
commit 1c25a98208
4 changed files with 144 additions and 33 deletions
+5 -4
View File
@@ -76,9 +76,10 @@ ollama-llama3,-,http://localhost:11434/v1,
```
### 3. Setup gateway key (optional)
To restrict access to your gateway, write a single plaintext key to a file (e.g. `gatekey.txt`):
To restrict access to your gateway, write one or more plaintext keys (one per line) to a file (e.g. `gatekey.txt`):
```text
my-secure-gateway-token
my-secure-gateway-token-1
my-secure-gateway-token-2
```
### 4. Run the server
@@ -94,7 +95,7 @@ my-secure-gateway-token
| ---- | ---- | ------- | ----------- |
| `-port` | int | `8080` | Port the gateway listens on. |
| `-csv` | string | `models.csv` | Path to the model configuration CSV. |
| `-key` | string | `""` | Path to a file containing the gateway's access token. If blank, authentication is disabled. |
| `-key` | string | `""` | Path to a file containing the gateway's access tokens (one per line). If blank, authentication is disabled. |
| `-csv-updater` | string | `""` | Command/script to run periodically to update `models.csv`. |
| `-csv-update-interval`| int | `10` | Frequency in minutes to invoke `-csv-updater`. |
@@ -152,7 +153,7 @@ curl -i -X POST http://localhost:8080/v1/chat/completions \
### 401 Unauthorized errors
- **Symptom**: Requests return `{"error": {"code": "invalid_api_key", ...}}`.
- **Solution**: Check that you are passing the correct Bearer token configured in the `-key` token file. Trim any whitespace, and verify it starts with `Bearer `.
- **Solution**: Check that you are passing one of the correct Bearer tokens configured in the `-key` token file. Trim any whitespace, and verify it starts with `Bearer `.
## FAQ