Commit 19a36cd
authored
fork distribution client v3 auth-challenge as an internal package (squashed) (#2248)
* fork distribution client v3 auth-challenge as an internal package
This forks the distribution's registry client auth-challenge code v3.0.0;
distribution/distribution@9ed95e7
The client code has moved to an internal package in the distribution project,
and is used to handle `WWW-Authenticate` headers. It was written a long time
ago, and only handles RFC 2617 (superseded by RFC 9110). Possibly there's more
current implementations for this, but this would introduce new dependencies, so
we can keep the status quo for now, and fork this code as an internal package.
Keeping it internal, due to the known limitations mentioned above, and to avoid
it being used by others assuming it's a general-purpose implementation.
This is the result of the following steps:
# install filter-repo (https://github.com/newren/git-filter-repo/blob/main/INSTALL.md)
brew install git-filter-repo
# create a temporary clone of docker
cd ~/Projects
git clone https://github.com/distribution/distribution.git distribution_auth
cd distribution_auth
# switch to v3.0.0 (git-filter doesn't like multiple branches, so reset)
git reset --hard v3.0.0
# commit taken from
git rev-parse --verify HEAD
9ed95e7365224025ee89365e12cf128e1f1bf965
git filter-repo --analyze
# remove all code, except for 'internal/client/auth/challenge'
# rename to 'pkg/v1/remote/internal/authchallenge'
# include history of old location ('registry/client/auth/challenge')
git filter-repo \
--force \
--path 'internal/client/auth/challenge' \
--path 'registry/client/auth/challenge' \
--path-rename internal/client/auth/challenge:pkg/v1/remote/internal/authchallenge
# go to the target github.com/docker/docker repository
cd ~/go/src/github.com/google/go-containerregistry
# create a branch to work with
git checkout -b fork_registryclient_authchallenge
# add the temporary repository as an upstream and make sure it's up-to-date
git remote add distribution_auth ~/Projects/distribution_auth
git fetch distribution_auth
# merge the upstream code
git merge --allow-unrelated-histories --signoff -S distribution_auth/main
History was squashed:
- Refactor authorization challenges to its own package
Split challenges into its own package. Avoids possible
import cycle with challenges from client.
- Fix minor "Challanges" typo
- Fix gometalint errors
- Fix typo in NewSimpleManager() documentation
- Initial repo commit
- init
- format code with gofumpt
Move registry client internal
Our registry client is not currently in a good place to be used as the
reference OCI Distribution client implementation. But the registry proxy
currently depends on it. Make the registry client internal to the
distribution application to remove it from the API surface area (and any
implied compatibility promises) of distribution/v3@v3.0.0 without
breaking the proxy.
cleanup: move init funcs to the top of the source
We make sure they're not hiding at the bottom or in the middle
which makes debugging an utter nightmare!
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* authchallenge: rename package and update imports
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* pkg/v1/remote/internal/authchallenge: make manager-code a test-util
The Manager code is only used as part of tests; move it to _test files
to have a clearer separation between "production" code and test-code.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* pkg/v1/remote/internal/authchallenge: cleanup manager code
As this code is now only used as a test-utility;
- Make the zero-value of simpleManager usable
- Remove the constructor and interface definition
- Un-export fields and mutex.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* pkg/v1/remote/internal/authchallenge: cleanup URL-normalization
- change normalizeURL to not mutate the input URL.
- move lowercasing into canonicalAddr.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* pkg/v1/remote/internal/authchallenge: modernize and linting
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* pkg/v1/remote/internal/authchallenge: add boilerplating
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
---------
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>1 parent c612a9b commit 19a36cd
14 files changed
Lines changed: 257 additions & 327 deletions
File tree
- cmd/krane
- pkg
- authn/k8schain
- v1/remote
- internal/authchallenge
- transport
- vendor
- github.com/docker/distribution
- registry/client/auth/challenge
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | | - | |
49 | 48 | | |
50 | 49 | | |
51 | 50 | | |
| |||
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 | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
14 | 13 | | |
15 | 14 | | |
16 | 15 | | |
| |||
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 | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | | - | |
56 | 55 | | |
57 | 56 | | |
58 | 57 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 28 additions & 83 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
2 | 18 | | |
3 | 19 | | |
4 | | - | |
5 | 20 | | |
6 | | - | |
7 | 21 | | |
8 | | - | |
9 | 22 | | |
10 | 23 | | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | 24 | | |
90 | 25 | | |
91 | 26 | | |
| |||
113 | 48 | | |
114 | 49 | | |
115 | 50 | | |
116 | | - | |
| 51 | + | |
117 | 52 | | |
118 | 53 | | |
119 | 54 | | |
| |||
128 | 63 | | |
129 | 64 | | |
130 | 65 | | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
131 | 76 | | |
132 | 77 | | |
133 | 78 | | |
| |||
Lines changed: 139 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
0 commit comments