Skip to content

Commit 83d4a92

Browse files
committed
rest api report uploads
1 parent 4afc05d commit 83d4a92

File tree

21 files changed

+1634
-144
lines changed

21 files changed

+1634
-144
lines changed

INSTALL.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,93 @@ is running
140140

141141

142142

143+
## Report Protocols
144+
145+
Patchman supports two report protocols:
146+
147+
### Protocol 1 (Text)
148+
The original form-based protocol. Uses multipart form data to upload package
149+
and repository information. No additional dependencies required on the client.
150+
151+
### Protocol 2 (JSON)
152+
A JSON-based REST API. Provides better error handling, structured validation,
153+
and easier debugging. Requires `jq` on the client.
154+
155+
To use Protocol 2, update your `patchman-client.conf`:
156+
157+
```shell
158+
protocol=2
159+
```
160+
161+
Or use the `-p 2` command line option:
162+
163+
```shell
164+
$ patchman-client -s http://patchman.example.org -p 2
165+
```
166+
167+
168+
## API Key Authentication
169+
170+
For Protocol 2, API key authentication is available using
171+
[djangorestframework-api-key](https://florimondmanca.github.io/djangorestframework-api-key/).
172+
Keys are hashed in the database and cannot be retrieved after creation.
173+
174+
### Server-side setup
175+
176+
1. Run migrations (first time only):
177+
178+
```shell
179+
$ patchman-manage migrate
180+
```
181+
182+
2. Create an API key:
183+
184+
```shell
185+
$ patchman-manage create_api_key "clients"
186+
Created API key: clients
187+
188+
Key: abc123...
189+
190+
Add this to your patchman-client.conf:
191+
api_key=abc123...
192+
193+
Save this key as it cannot be retrieved later.
194+
```
195+
196+
3. List existing keys:
197+
198+
```shell
199+
$ patchman-manage list_api_keys
200+
```
201+
202+
4. Revoke a key:
203+
204+
```shell
205+
$ patchman-manage revoke_api_key <prefix-or-name>
206+
```
207+
208+
5. To require API keys for all Protocol 2 uploads, set in `local_settings.py`:
209+
210+
```python
211+
REQUIRE_API_KEY = True
212+
```
213+
214+
API keys can also be managed via the Django admin interface.
215+
216+
### Client-side setup
217+
218+
Add the API key to `patchman-client.conf`:
219+
220+
```shell
221+
protocol=2
222+
api_key=abc123...
223+
```
224+
225+
Or use the `-k` command line option:
226+
227+
```shell
228+
$ patchman-client -s http://patchman.example.org -p 2 -k abc123...
229+
```
143230

144231

145232
## Configure Database

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@ required to report packages, `yum`, `dnf`, `zypper` and/or `apt` are required
120120
to report repositories. These packages are normally installed by default on
121121
most systems.
122122
123+
For Protocol 2 (JSON-based reports), `jq` is required. If `jq` is not available,
124+
the client will automatically fall back to Protocol 1 (text-based reports).
125+
123126
deb-based OS's do not always change the kernel version when a kernel update is
124127
installed, so the `update-notifier-common` package can optionally be installed
125128
to enable this functionality. rpm-based OS's can tell if a reboot is required

0 commit comments

Comments
 (0)