Commit 4d5c036
committed
Auto merge of #10592 - arlosi:auth, r=ehuss
Implement RFC 3139: alternative registry authentication support
Allows registries to request Cargo to send the authentication token for all requests, rather than just publish/yank, implementing [RFC 3139](#10474).
### Items from the [tracking issue](#10474)
> Do registries need a more fine-grained switch for which API commands require authentication?
This PR uses the `auth_required` boolean as described in the RFC.
> The RFC mentions adding --token to additional commands like install and search
These flags are not added by this PR.
> Consider changing the name and form of the X- header
Changed to the `www-authenticate` header as suggested by the comments.
> Will there be any concerns with the interaction with rust-lang/rfcs#3231
Not that I know of.
-------------
Adds a new field `"auth-required": true` to `config.json` that indicates Cargo should include the token in all requests to a registry.
For HTTP registries, Cargo first attempts an un-authenticated request, then if that fails with HTTP 401, an authenticated request is attempted. The registry server may include a `www-authenticate` header with the HTTP 401 to instruct Cargo with URL the user can visit to acquire a token (crates.io/me).
Since the API URL is not known (because it's stored in the index), the unstable credential provider feature is modified to key off the index url, and the registry name is no longer provided.
To handle the case where an alternative registry's name is not known (such as coming from a lock file, or via `--index`), Cargo can now look up the token in the configuration by matching on the index URL. This introduces a new error if two alternative registries are configured with the same index URL.
Several operations, such as `cargo install` could have had a `--token` argument added, however it appears that Cargo would like to move away from passing the token on the command line for security reasons. In this case, users would need to configure the registry via the config file (or environment variables) when using `cargo install --index ...` or similar.File tree
42 files changed
+1468
-661
lines changed- crates
- cargo-test-support/src
- crates-io
- credential
- cargo-credential-1password
- src
- cargo-credential-gnome-secret
- src
- cargo-credential-macos-keychain
- src
- cargo-credential-wincred
- src
- cargo-credential
- src
- src
- bin/cargo/commands
- cargo
- core
- source
- ops
- registry
- sources/registry
- util
- config
- doc/src/reference
- tests/testsuite
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
42 files changed
+1468
-661
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
326 | 326 | | |
327 | 327 | | |
328 | 328 | | |
329 | | - | |
| 329 | + | |
330 | 330 | | |
331 | 331 | | |
332 | 332 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| 64 | + | |
| 65 | + | |
64 | 66 | | |
65 | 67 | | |
66 | 68 | | |
| |||
76 | 78 | | |
77 | 79 | | |
78 | 80 | | |
79 | | - | |
| 81 | + | |
80 | 82 | | |
81 | 83 | | |
82 | 84 | | |
| |||
98 | 100 | | |
99 | 101 | | |
100 | 102 | | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
101 | 114 | | |
102 | 115 | | |
103 | 116 | | |
| |||
106 | 119 | | |
107 | 120 | | |
108 | 121 | | |
| 122 | + | |
109 | 123 | | |
110 | 124 | | |
111 | 125 | | |
| |||
160 | 174 | | |
161 | 175 | | |
162 | 176 | | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
163 | 185 | | |
164 | 186 | | |
165 | 187 | | |
| |||
207 | 229 | | |
208 | 230 | | |
209 | 231 | | |
| 232 | + | |
210 | 233 | | |
211 | 234 | | |
212 | 235 | | |
| |||
226 | 249 | | |
227 | 250 | | |
228 | 251 | | |
229 | | - | |
| 252 | + | |
230 | 253 | | |
231 | 254 | | |
232 | 255 | | |
| |||
293 | 316 | | |
294 | 317 | | |
295 | 318 | | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
296 | 324 | | |
297 | 325 | | |
298 | 326 | | |
| |||
302 | 330 | | |
303 | 331 | | |
304 | 332 | | |
305 | | - | |
| 333 | + | |
306 | 334 | | |
307 | 335 | | |
308 | 336 | | |
| |||
442 | 470 | | |
443 | 471 | | |
444 | 472 | | |
| 473 | + | |
445 | 474 | | |
446 | 475 | | |
447 | 476 | | |
| |||
456 | 485 | | |
457 | 486 | | |
458 | 487 | | |
459 | | - | |
460 | 488 | | |
461 | | - | |
462 | | - | |
| 489 | + | |
463 | 490 | | |
464 | 491 | | |
465 | 492 | | |
| |||
468 | 495 | | |
469 | 496 | | |
470 | 497 | | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
471 | 504 | | |
472 | 505 | | |
473 | 506 | | |
| |||
504 | 537 | | |
505 | 538 | | |
506 | 539 | | |
| 540 | + | |
507 | 541 | | |
508 | 542 | | |
509 | 543 | | |
| |||
512 | 546 | | |
513 | 547 | | |
514 | 548 | | |
| 549 | + | |
515 | 550 | | |
516 | 551 | | |
517 | 552 | | |
| |||
524 | 559 | | |
525 | 560 | | |
526 | 561 | | |
| 562 | + | |
527 | 563 | | |
528 | 564 | | |
529 | | - | |
530 | | - | |
| 565 | + | |
| 566 | + | |
531 | 567 | | |
532 | 568 | | |
533 | 569 | | |
| |||
615 | 651 | | |
616 | 652 | | |
617 | 653 | | |
618 | | - | |
| 654 | + | |
619 | 655 | | |
620 | 656 | | |
621 | 657 | | |
| |||
676 | 712 | | |
677 | 713 | | |
678 | 714 | | |
679 | | - | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
680 | 718 | | |
681 | 719 | | |
682 | 720 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
| 25 | + | |
24 | 26 | | |
25 | 27 | | |
26 | 28 | | |
| |||
199 | 201 | | |
200 | 202 | | |
201 | 203 | | |
202 | | - | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
203 | 210 | | |
204 | 211 | | |
205 | 212 | | |
206 | 213 | | |
| 214 | + | |
207 | 215 | | |
208 | 216 | | |
209 | 217 | | |
| |||
377 | 385 | | |
378 | 386 | | |
379 | 387 | | |
380 | | - | |
| 388 | + | |
381 | 389 | | |
382 | 390 | | |
383 | 391 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
Lines changed: 30 additions & 24 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
| 44 | + | |
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| |||
175 | 175 | | |
176 | 176 | | |
177 | 177 | | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
| 178 | + | |
183 | 179 | | |
184 | 180 | | |
185 | 181 | | |
| |||
196 | 192 | | |
197 | 193 | | |
198 | 194 | | |
199 | | - | |
| 195 | + | |
200 | 196 | | |
201 | 197 | | |
202 | 198 | | |
203 | 199 | | |
204 | 200 | | |
205 | | - | |
| 201 | + | |
206 | 202 | | |
207 | | - | |
| 203 | + | |
208 | 204 | | |
209 | 205 | | |
210 | 206 | | |
| |||
214 | 210 | | |
215 | 211 | | |
216 | 212 | | |
217 | | - | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
218 | 220 | | |
219 | 221 | | |
220 | 222 | | |
| |||
226 | 228 | | |
227 | 229 | | |
228 | 230 | | |
229 | | - | |
230 | | - | |
| 231 | + | |
231 | 232 | | |
| 233 | + | |
232 | 234 | | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
233 | 239 | | |
234 | 240 | | |
235 | 241 | | |
236 | 242 | | |
237 | 243 | | |
238 | 244 | | |
239 | 245 | | |
240 | | - | |
| 246 | + | |
241 | 247 | | |
242 | | - | |
| 248 | + | |
243 | 249 | | |
244 | 250 | | |
245 | 251 | | |
| |||
276 | 282 | | |
277 | 283 | | |
278 | 284 | | |
279 | | - | |
| 285 | + | |
280 | 286 | | |
281 | | - | |
| 287 | + | |
282 | 288 | | |
283 | 289 | | |
284 | 290 | | |
285 | 291 | | |
286 | | - | |
| 292 | + | |
287 | 293 | | |
288 | 294 | | |
289 | 295 | | |
290 | 296 | | |
291 | 297 | | |
292 | | - | |
| 298 | + | |
293 | 299 | | |
294 | 300 | | |
295 | | - | |
296 | | - | |
| 301 | + | |
| 302 | + | |
297 | 303 | | |
298 | | - | |
| 304 | + | |
299 | 305 | | |
300 | 306 | | |
301 | 307 | | |
302 | | - | |
| 308 | + | |
303 | 309 | | |
304 | 310 | | |
305 | | - | |
| 311 | + | |
306 | 312 | | |
307 | 313 | | |
308 | | - | |
| 314 | + | |
309 | 315 | | |
310 | 316 | | |
311 | 317 | | |
| |||
0 commit comments