Commit a6f60bf
authored
Closes #187. Stacked on #188.
## What
Replaces the strict-equality check between the JSON request's `rp.id`
and the origin's effective domain with the spec-correct "registrable
domain suffix of or equal to" relation from HTML §6.5 (referenced by
WebAuthn L3 §5.1.3 step 7 and §5.1.7 step 9).
Net effect: `rp.id = "example.org"` now works against an origin of
`https://login.example.org`, while `rp.id = "co.uk"` against
`https://example.co.uk` is still correctly rejected because `co.uk` is a
public suffix.
## PSL strategy
Per the design discussion in #173 (libwebauthn should not bundle and
manage its own PSL):
- Adds a `PublicSuffixList` trait with sync `registrable_domain` /
`public_suffix` methods.
- Provides a `DatFilePublicSuffixList` impl that reads a Public Suffix
List `.dat` file at construction time. `from_system_file()` reads the
standard `/usr/share/publicsuffix/public_suffix_list.dat`, kept current
by the system package manager.
- No PSL data is bundled in the libwebauthn crate.
- `publicsuffix = "1.5"`. Same crate as #173, just used offline.
## Plumbing into the parsing API
`WebAuthnIDL::from_json` and `FromIdlModel::from_idl_model` now take an
additional `psl: &dyn PublicSuffixList` parameter. This is the simplest
shape we discussed - explicit, no hidden state on `RequestOrigin`. Yes,
it's another breaking signature change on top of #188; the 0.4.0 release
is already breaking, so we eat the cost once.
Origin parsing (`Origin::from_str`, `RequestOrigin::try_from`) stays
purely syntactic. PSL is only consulted at validation time.
## Commits
1. Add `PublicSuffixList` trait and `DatFilePublicSuffixList` impl.
2. Use `PublicSuffixList` for the registrable-suffix check in
`from_idl_model`.
## Tests
- Unit tests on the suffix-check helper using a small
`MockPublicSuffixList` (recognises `com`, `co.uk`, `org`, `net`).
- Unit tests on the mock itself.
- 2 new positive integration tests on `from_json` for both
`MakeCredentialRequest` and `GetAssertionRequest`:
rp.id-as-parent-registrable-suffix accepted, rp.id-as-eTLD rejected.
## Test plan
- [x] `cargo build --workspace --all-targets --all-features`
- [x] `cargo fmt --all -- --check`
- [x] `cargo clippy --workspace --all-targets --all-features -- -D
warnings`
- [x] `cargo test --workspace` (151 tests)
- [x] `cargo publish --dry-run -p libwebauthn`
1 parent 17e91f6 commit a6f60bf
10 files changed
Lines changed: 565 additions & 36 deletions
File tree
- libwebauthn
- examples
- src/ops/webauthn
- idl
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
41 | 45 | | |
42 | 46 | | |
43 | 47 | | |
| |||
79 | 83 | | |
80 | 84 | | |
81 | 85 | | |
| 86 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
35 | 36 | | |
36 | 37 | | |
37 | 38 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | | - | |
| 11 | + | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
84 | 87 | | |
85 | 88 | | |
86 | 89 | | |
| |||
106 | 109 | | |
107 | 110 | | |
108 | 111 | | |
109 | | - | |
| 112 | + | |
110 | 113 | | |
111 | 114 | | |
112 | 115 | | |
| |||
158 | 161 | | |
159 | 162 | | |
160 | 163 | | |
161 | | - | |
| 164 | + | |
162 | 165 | | |
163 | 166 | | |
164 | 167 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| 24 | + | |
23 | 25 | | |
24 | 26 | | |
25 | 27 | | |
| |||
115 | 117 | | |
116 | 118 | | |
117 | 119 | | |
| 120 | + | |
118 | 121 | | |
119 | 122 | | |
120 | 123 | | |
121 | | - | |
| 124 | + | |
122 | 125 | | |
123 | 126 | | |
124 | 127 | | |
125 | | - | |
126 | | - | |
| 128 | + | |
| 129 | + | |
127 | 130 | | |
128 | 131 | | |
129 | 132 | | |
130 | 133 | | |
131 | 134 | | |
132 | | - | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
133 | 139 | | |
134 | 140 | | |
135 | 141 | | |
| |||
158 | 164 | | |
159 | 165 | | |
160 | 166 | | |
161 | | - | |
| 167 | + | |
162 | 168 | | |
163 | 169 | | |
164 | 170 | | |
| |||
575 | 581 | | |
576 | 582 | | |
577 | 583 | | |
| 584 | + | |
578 | 585 | | |
579 | 586 | | |
580 | 587 | | |
| |||
629 | 636 | | |
630 | 637 | | |
631 | 638 | | |
632 | | - | |
633 | | - | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
634 | 645 | | |
635 | 646 | | |
636 | 647 | | |
| |||
640 | 651 | | |
641 | 652 | | |
642 | 653 | | |
643 | | - | |
| 654 | + | |
| 655 | + | |
644 | 656 | | |
645 | 657 | | |
646 | 658 | | |
| |||
649 | 661 | | |
650 | 662 | | |
651 | 663 | | |
652 | | - | |
| 664 | + | |
| 665 | + | |
653 | 666 | | |
654 | 667 | | |
655 | 668 | | |
| |||
661 | 674 | | |
662 | 675 | | |
663 | 676 | | |
664 | | - | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
665 | 708 | | |
666 | 709 | | |
667 | 710 | | |
| |||
677 | 720 | | |
678 | 721 | | |
679 | 722 | | |
680 | | - | |
| 723 | + | |
| 724 | + | |
681 | 725 | | |
682 | 726 | | |
683 | 727 | | |
| |||
693 | 737 | | |
694 | 738 | | |
695 | 739 | | |
696 | | - | |
| 740 | + | |
| 741 | + | |
697 | 742 | | |
698 | 743 | | |
699 | 744 | | |
| |||
706 | 751 | | |
707 | 752 | | |
708 | 753 | | |
709 | | - | |
| 754 | + | |
| 755 | + | |
710 | 756 | | |
711 | 757 | | |
712 | 758 | | |
| |||
724 | 770 | | |
725 | 771 | | |
726 | 772 | | |
727 | | - | |
| 773 | + | |
| 774 | + | |
728 | 775 | | |
729 | 776 | | |
730 | 777 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
| 20 | + | |
19 | 21 | | |
20 | 22 | | |
21 | 23 | | |
| |||
33 | 35 | | |
34 | 36 | | |
35 | 37 | | |
36 | | - | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
37 | 43 | | |
38 | | - | |
| 44 | + | |
39 | 45 | | |
40 | 46 | | |
41 | 47 | | |
| |||
44 | 50 | | |
45 | 51 | | |
46 | 52 | | |
47 | | - | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
48 | 58 | | |
0 commit comments