Commit 894712c
committed
feat(url): add split_basic_auth() helper for URL-embedded HTTP basic auth
Extracts userinfo (user[:password]) from a URL like
https://alice:secret@host/path, returns the URL with the userinfo
stripped from the netloc plus a headers dict carrying the matching
Authorization: Basic header. Pass both into lib.url.fetch() or
lib.url.fetch_json() so apps can accept HTTP basic auth via the URL
itself instead of exposing separate --username / --password
arguments.
Keeps credentials out of ps listings, out of the request line and
out of any proxy access log. The php-fpm-status check plugin already
follows this pattern with its own local helper; this lib function
generalises it for reuse so the haproxy-status plugin (and any
future HTTP-basic-auth plugin) does not have to duplicate the
base64-and-strip dance.1 parent f815718 commit 894712c
2 files changed
Lines changed: 43 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
12 | 14 | | |
13 | 15 | | |
14 | 16 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
308 | 309 | | |
309 | 310 | | |
310 | 311 | | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
311 | 350 | | |
312 | 351 | | |
313 | 352 | | |
| |||
0 commit comments