feat: add initial API

This commit is contained in:
Morten Olsen
2025-10-16 20:54:31 +02:00
parent 5cf0a3612a
commit 11828da073
17 changed files with 647 additions and 89 deletions

View File

@@ -29,7 +29,6 @@ docker-compose up -d
- **WebSocket MQTT**: `ws://localhost:8883/ws`
- **HTTP API**: `http://localhost:8883/api`
3. Connect with an MQTT client:
> [!IMPORTANT]
@@ -48,24 +47,25 @@ const client = mqtt.connect('ws://localhost:8883/ws')
Backbone can be configured using environment variables:
| Variable | Description | Default |
|----------|-------------|---------|
| `ADMIN_TOKEN` | Admin token for API requests | `undefined` |
| `TOKEN_SECRET` | JWT signing secret for authentication | `undefined` |
| `K8S_ENABLED` | Enable Kubernetes operator mode | `false` |
| `HTTP_ENABLED` | Enable HTTP/WebSocket server | `true` |
| `HTTP_PORT` | HTTP server port | `8883` |
| `TCP_ENABLED` | Enable TCP MQTT server | `true` |
| `TCP_PORT` | TCP server port | `1883` |
| `OIDC_ENABLED` | OIDC discovery URL | `undefined` |
| `OIDC_DISCOVERY` | OIDC discovery URL | `undefined` |
| `OIDC_CLIENT_ID` | OIDC client ID | `undefined` |
| `OIDC_CLIENT_SECRET` | OIDC client secret | `undefined` |
| `OIDC_CLIENT_SECRET` | OIDC client secret | `undefined` |
| `OIDC_GROUP_FIELD` | JWT field for reading groups | `groups` |
| `OIDC_ADMIN_GROUP` | JWT group for admins | `undefined` |
| `OIDC_WRITER_GROUP` | JWT group with publish access to queue | `undefined` |
| `OIDC_READER_GROUP` | JWT group with read-only access to queue | `undefined` |
| Variable | Description | Default |
| -------------------- | ---------------------------------------- | ----------- |
| `ADMIN_TOKEN` | Admin token for API requests | `undefined` |
| `JWT_SECRET` | JWT signing secret for authentication | `undefined` |
| `K8S_ENABLED` | Enable Kubernetes operator mode | `false` |
| `WS_ENABLED` | Enable WebSocket MQTT server | `false` |
| `API_ENABLED` | Enable HTTP API | `false` |
| `HTTP_PORT` | HTTP server port | `8883` |
| `TCP_ENABLED` | Enable TCP MQTT server | `false` |
| `TCP_PORT` | TCP server port | `1883` |
| `OIDC_ENABLED` | OIDC discovery URL | `false` |
| `OIDC_DISCOVERY` | OIDC discovery URL | `undefined` |
| `OIDC_CLIENT_ID` | OIDC client ID | `undefined` |
| `OIDC_CLIENT_SECRET` | OIDC client secret | `undefined` |
| `OIDC_CLIENT_SECRET` | OIDC client secret | `undefined` |
| `OIDC_GROUP_FIELD` | JWT field for reading groups | `groups` |
| `OIDC_ADMIN_GROUP` | JWT group for admins | `undefined` |
| `OIDC_WRITER_GROUP` | JWT group with publish access to queue | `undefined` |
| `OIDC_READER_GROUP` | JWT group with read-only access to queue | `undefined` |
### Example Configuration
@@ -130,9 +130,9 @@ Access control is defined using statement-based policies similar to AWS IAM:
```yaml
statements:
- effect: allow # or "deny"
resources: ['*'] # MQTT topic patterns
actions: ['*'] # MQTT actions
- effect: allow # or "deny"
resources: ['*'] # MQTT topic patterns
actions: ['*'] # MQTT actions
```
#### MQTT Actions
@@ -159,6 +159,7 @@ statements:
### HTTP API
The HTTP API provides management endpoints for:
- Client management
- Topic configuration
- Broker statistics