You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/api/README.md
+6-1Lines changed: 6 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,11 @@ The Osmedeus API provides a RESTful interface for managing security automation w
10
10
11
11
## Authentication
12
12
13
-
Most API endpoints require JWT authentication. First, obtain a token via the login endpoint, then include it in subsequent requests using the `Authorization: Bearer <token>` header.
13
+
Most API endpoints require authentication. Two methods are supported:
14
+
15
+
1.**JWT Token**: Obtain a token via the login endpoint, then include it in requests using the `Authorization: Bearer <token>` header.
16
+
17
+
2.**API Key**: Use a static API key via the `x-osm-api-key` header. Configure in `~/osmedeus-base/osm-settings.yaml` under `server.auth_api_key`.
14
18
15
19
See [Authentication](authentication.md) for details.
16
20
@@ -28,6 +32,7 @@ See [Authentication](authentication.md) for details.
28
32
|[Assets](assets.md)| View discovered assets |
29
33
|[Vulnerabilities](vulnerabilities.md)| View and manage vulnerabilities |
As an alternative to JWT tokens, you can authenticate using a static API key via the `x-osm-api-key` header. This is useful for scripts, CI/CD pipelines, or integrations where managing JWT token refresh is impractical.
103
+
104
+
### Configuration
105
+
106
+
API key authentication is configured in `~/osmedeus-base/osm-settings.yaml`:
107
+
108
+
```yaml
109
+
server:
110
+
# Enable API key authentication (default: true)
111
+
enabled_auth_api: true
112
+
# API key for x-osm-api-key header authentication
113
+
# A random 32-character key is generated on first run
114
+
auth_api_key: "your-api-key-here"
115
+
```
116
+
117
+
### Using the API Key
118
+
119
+
Include the API key in requests using the `x-osm-api-key` header:
120
+
121
+
```bash
122
+
# Store API key in environment variable
123
+
export OSM_API_KEY="your-api-key-here"
124
+
125
+
# Use in API requests
126
+
curl http://localhost:8002/osm/api/workflows \
127
+
-H "x-osm-api-key: $OSM_API_KEY"
128
+
```
129
+
130
+
### Error Response
131
+
132
+
**401 Unauthorized** - Invalid or missing API key:
133
+
```json
134
+
{
135
+
"error": true,
136
+
"message": "Invalid or missing API key"
137
+
}
138
+
```
139
+
140
+
### Notes
141
+
142
+
- API key authentication takes priority over JWT when enabled
143
+
- A random 32-character API key is automatically generated on first server start
144
+
- The API key is stored in plain text in the settings file; ensure appropriate file permissions
145
+
- Empty, whitespace-only, or placeholder values (`null`, `undefined`, `nil`) are rejected
146
+
100
147
## Disabling Authentication
101
148
102
149
Authentication can be disabled by starting the server with the `--no-auth` flag:
0 commit comments