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
Incorporate feedback from 2nd review of SE-0292 (#1319)
* Fix regular expression for package scopes
* Package names are compared using NFKC + CaseFolding
* The default, unscoped registry is denoted by [default]
* Mention .netrc file as mitigation for hardcoded credentials
* Add link to draft registry proposal in @apple/swift-package-manager
* Update Information disclosure section
* Add section discussing authentication
@@ -342,7 +335,7 @@ a package's contents may have changed at some point.
342
335
Swift Package Manager will refuse to download dependencies
343
336
if there's a mismatch in integrity checksums.
344
337
345
-
```terminal
338
+
```console
346
339
$ swift build
347
340
error: checksum of downloaded source archive of dependency 'mona.LinkedList' (c2b934fe66e55747d912f1cfd03150883c4f037370c40ca2ad4203805db79457) does not match checksum specified by the manifest (ed008d5af44c1d0ea0e3668033cae9b695235f18b1a99240b7cf0f3d9559a30d)
348
341
```
@@ -376,7 +369,7 @@ in the root directory of a package
376
369
to generate a source archive for the current working tree.
377
370
For example:
378
371
379
-
```terminal
372
+
```console
380
373
$ tree -a -L 1
381
374
LinkedList
382
375
├── .git
@@ -402,7 +395,7 @@ the name of the package with a `.zip` extension
402
395
(for example, "LinkedList.zip").
403
396
You can override this behavior with the `--output` option:
404
397
405
-
```terminal
398
+
```console
406
399
$ git checkout 1.2.0
407
400
$ swift package archive-source --output="LinkedList-1.2.0.zip"
408
401
# Created LinkedList-1.2.0.zip
@@ -413,7 +406,7 @@ The `archive-source` subcommand has the equivalent behavior of
413
406
Therefore, the following command produces
414
407
equivalent output to the previous example:
415
408
416
-
```terminal
409
+
```console
417
410
$ git archive --format zip --output LinkedList-1.2.0.zip 1.2.0
418
411
```
419
412
@@ -453,29 +446,33 @@ SYNOPSIS
453
446
OPTIONS:
454
447
--global Apply settings to all projects for this user
455
448
--scope Associate the registry with a given scope
449
+
--login Specify a user name for the remote machine
450
+
--password Supply a password for the remote machine
456
451
```
457
452
458
453
Running the `package-registry set` subcommand
459
454
in the root directory of a package
460
455
creates or updates the `.swiftpm/config/registries.json` file
461
456
with a new top-level `registries` key
462
457
that's associated with an object containing the specified registry URLs.
458
+
The default, unscoped registry is associated with the key `[default]`.
459
+
Any scoped registries are keyed by their case-folded name.
463
460
464
461
For example,
465
462
a build server that doesn't allow external network connections
466
463
may configure a registry URL to resolve dependencies
467
464
using an internal registry service.
468
465
469
-
```terminal
466
+
```console
470
467
$ swift package-registry set https://internal.example.com/
471
468
$ cat .swiftpm/config/registries.json
472
469
```
473
470
474
471
```json
475
472
{
476
473
"registries": {
477
-
"default": {
478
-
"url": "https://internal.example.com"
474
+
"[default]": {
475
+
"url": "https://internal.example.com"
479
476
}
480
477
},
481
478
"version": 1
@@ -488,7 +485,7 @@ Swift Package Manager commands like
488
485
`swift package resolve` and `swift package update`
489
486
fail with an error.
490
487
491
-
```terminal
488
+
```console
492
489
$ swift package resolve
493
490
error: cannot resolve dependency 'mona.LinkedList' without a configured registry
494
491
```
@@ -503,14 +500,14 @@ a user might resolve all packages with the package scope `example`
503
500
(such as `example.PriorityQueue`)
504
501
to a private registry.
505
502
506
-
```terminal
503
+
```console
507
504
$ swift package-registry set https://internal.example.com/ --scope example
508
505
$ cat .swiftpm/config/registries.json
509
506
```
510
507
511
508
```json
512
509
{
513
-
"registries": {
510
+
"registries": {
514
511
"example": {
515
512
"url": "https://internal.example.com"
516
513
}
@@ -560,8 +557,8 @@ consider the following global and local registry configuration files:
560
557
```jsonc
561
558
// Global configuration (~/.swiftpm/config/registries.json)
562
559
{
563
-
"registries": {
564
-
"default": {
560
+
"registries": {
561
+
"[default]": {
565
562
"url":"https://global.example.com"
566
563
},
567
564
"foo": {
@@ -573,7 +570,7 @@ consider the following global and local registry configuration files:
573
570
574
571
// Local configuration (.swiftpm/config/registries.json)
575
572
{
576
-
"registries": {
573
+
"registries": {
577
574
"foo": {
578
575
"url":"https://local.example.com"
579
576
}
@@ -599,14 +596,65 @@ in descending order of precedence:
599
596
* Any local configuration (`./.swiftpm/config/registries.json`)
600
597
* Any global configuration file (`~/.swiftpm/config/registries.json`)
601
598
599
+
#### Specifying credentials for a custom registry
600
+
601
+
Some servers may require a username and password.
602
+
The user can provide credentials when setting a custom registry
603
+
by passing the `--login` and `--password` options.
604
+
605
+
When credentials are provided,
606
+
the corresponding object in the `registries.json` file
607
+
includes a `login` key with the passed value.
608
+
If the project's `.netrc` file has an existing entry
609
+
for a given machine and login,
610
+
it's updated with the new password;
611
+
otherwise, a new entry is added.
612
+
If no `.netrc` file exists,
613
+
a new one is created and populated with the new entry.
614
+
615
+
```console
616
+
$ swift package-registry set https://internal.example.com/ \
617
+
--login jappleseed --password alpine
618
+
619
+
$ cat .netrc
620
+
machine internal.example.com
621
+
login jappleseed
622
+
password alpine
623
+
624
+
$ cat .swiftpm/config/registries.json
625
+
626
+
{
627
+
"registries": {
628
+
"[default]": {
629
+
"url": "https://internal.example.com"
630
+
"login": "jappleseed"
631
+
}
632
+
},
633
+
"version": 1
634
+
}
635
+
```
636
+
637
+
If the user passes the `--login` and `--password` options
638
+
to the `set` subcommand along with the `--global` option,
639
+
the user-level `.netrc` file is updated instead.
640
+
When Swift Package Manager connects to a custom registry,
641
+
it first consults the project's `.netrc` file, if one exists.
642
+
If no entry is found for the custom registry,
643
+
Swift Package Manager then consults the user-level `.netrc` file, if one exists.
644
+
645
+
If the provided credentials are missing or invalid,
646
+
Swift Package Manager commands like
647
+
`swift package resolve` and `swift package update`
648
+
fail with an error.
649
+
602
650
### Changes to config subcommand
603
651
604
652
#### Set-mirror option for package identifiers
605
653
606
654
A user can currently specify an alternate location for a package
607
655
by setting a [dependency mirror][SE-0219] for that package's URL.
0 commit comments