Commit 81b9e02
committed
Extract DCR resolver into pkg/auth/dcr
Sub-issue 4a of #5145. Creates the shared pkg/auth/dcr package and
migrates the embedded authserver to consume it. The CLI flow
migration (pkg/auth/discovery::PerformOAuthFlow) is left to
sub-issue 4b (#5219) so this slice stays under the project's
PR-size limit.
Files moved (renamed via git mv so the diff shows as renames, not
deletions + additions):
pkg/authserver/runner/dcr.go -> pkg/auth/dcr/resolver.go
pkg/authserver/runner/dcr_store.go -> pkg/auth/dcr/store.go
pkg/authserver/runner/dcr_test.go -> pkg/auth/dcr/resolver_test.go
pkg/authserver/runner/dcr_store_test.go -> pkg/auth/dcr/store_test.go
pkg/authserver/runner/dcr_testhelpers_test.go -> pkg/auth/dcr/testhelpers_test.go
Public API surface (renamed from runner-package internals because
they now cross a package boundary):
Resolution (was DCRResolution)
Key (was DCRKey, alias to storage.DCRKey unchanged)
CredentialStore (was the package-private dcrResolutionCache)
ResolveCredentials (was resolveDCRCredentials)
NeedsDCR (was needsDCR)
ConsumeResolution (was consumeResolution)
ApplyResolutionToOAuth2Config (was applyResolutionToOAuth2Config)
LogStepError (was logDCRStepError)
NewInMemoryStore (new convenience constructor wrapping
storage.NewMemoryStorage; mirrors the pattern
the per-test newMemoryDCRStore helpers use)
NewStorageBackedStore (was the package-private newStorageBackedStore)
SanitizeErrorForLog (was sanitizeErrorForLog; promoted to
exported because the deferred-cleanup log
path in pkg/authserver/runner needs it)
Names follow the pkg/auth/dcr.* form so the linter's stuttering
check (revive: dcr.DCRResolution would stutter) passes and the
surface reads as ordinary package API.
resolveSecret was duplicated into the dcr package because
pkg/auth/dcr must stay profile-agnostic and cannot reach back into
pkg/authserver/runner. The duplication is intentional and called
out in a comment; future consolidation can move it into a shared
helper if a third caller appears. A parallel TestResolveSecret /
TestResolveSecretWithEnvVar suite in pkg/auth/dcr/secret_test.go
mirrors the runner-package twin's observable contract so any
future drift between the two copies fails CI on at least one side.
Review-feedback bits applied alongside the move:
- Package doc comment in pkg/auth/dcr/resolver.go now documents the
process-global singleflight in a Concurrency section, and labels
the profile-agnostic framing as a target state for sub-issue 4b
rather than as a description of the current API shape (the
package's public API still takes embedded-authserver types).
- dcrFlight var doc gains a cross-consumer caveat naming the
"third consumer with colliding redirect URI" failure mode.
- Flight-key construction extracted into flightKeyOf(Key) string so
the canonical key shape is inspectable rather than buried in a
string-concatenation literal.
- endpointsFromMetadata gains a defensive nil check; the function's
doc comment names the oauthproto contract being defended.
- newMemoryDCRStore test helper is duplicated across the two
packages because Go test helpers cannot be shared without
exporting them; the duplication is documented at both sites.
Acceptance criteria status (#5145):
AC#1 (pkg/auth/dcr exists, exports a stateful resolver, consumed
by both call sites): partially met — package exists and is
consumed by EmbeddedAuthServer. CLI flow migration is
sub-issue 4b (#5219).
AC#2 (stateless RFC 7591 helpers in pkg/oauthproto): met
(already satisfied before this PR).
AC#3 (no direct oauthproto.RegisterClientDynamically calls
outside pkg/auth/dcr): not yet met — pkg/auth/discovery
still calls it. Resolved by sub-issue 4b (#5219).
AC#4 (review-property behaviours apply to CLI flow): not yet
met — same dependency on 4b (#5219).
Closes #5220.
Verified via task lint-fix (0 issues), task license-check (clean),
and go test -count=1 -race ./pkg/auth/dcr/... ./pkg/authserver/...
(all pass).1 parent 9211a36 commit 81b9e02
9 files changed
Lines changed: 491 additions & 216 deletions
Lines changed: 172 additions & 64 deletions
Large diffs are not rendered by default.
Lines changed: 62 additions & 62 deletions
Large diffs are not rendered by default.
| 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 | + | |
Lines changed: 45 additions & 31 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
28 | 29 | | |
29 | | - | |
| 30 | + | |
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
35 | | - | |
| 36 | + | |
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
41 | | - | |
| 42 | + | |
42 | 43 | | |
43 | | - | |
| 44 | + | |
44 | 45 | | |
45 | | - | |
| 46 | + | |
46 | 47 | | |
47 | 48 | | |
48 | | - | |
| 49 | + | |
49 | 50 | | |
50 | 51 | | |
51 | 52 | | |
52 | 53 | | |
53 | 54 | | |
54 | | - | |
| 55 | + | |
55 | 56 | | |
56 | 57 | | |
57 | | - | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
58 | 72 | | |
59 | | - | |
| 73 | + | |
60 | 74 | | |
61 | 75 | | |
62 | | - | |
| 76 | + | |
63 | 77 | | |
64 | 78 | | |
65 | 79 | | |
66 | | - | |
| 80 | + | |
67 | 81 | | |
68 | | - | |
| 82 | + | |
69 | 83 | | |
70 | 84 | | |
71 | 85 | | |
72 | 86 | | |
73 | 87 | | |
74 | | - | |
| 88 | + | |
75 | 89 | | |
76 | 90 | | |
77 | 91 | | |
78 | | - | |
| 92 | + | |
79 | 93 | | |
80 | 94 | | |
81 | 95 | | |
| |||
86 | 100 | | |
87 | 101 | | |
88 | 102 | | |
89 | | - | |
| 103 | + | |
90 | 104 | | |
91 | 105 | | |
92 | 106 | | |
93 | 107 | | |
94 | 108 | | |
95 | | - | |
| 109 | + | |
96 | 110 | | |
97 | 111 | | |
98 | 112 | | |
99 | 113 | | |
100 | 114 | | |
101 | 115 | | |
102 | 116 | | |
103 | | - | |
104 | | - | |
| 117 | + | |
| 118 | + | |
105 | 119 | | |
106 | 120 | | |
107 | 121 | | |
108 | 122 | | |
109 | | - | |
| 123 | + | |
110 | 124 | | |
111 | 125 | | |
112 | 126 | | |
| |||
116 | 130 | | |
117 | 131 | | |
118 | 132 | | |
119 | | - | |
| 133 | + | |
120 | 134 | | |
121 | 135 | | |
122 | 136 | | |
| |||
136 | 150 | | |
137 | 151 | | |
138 | 152 | | |
139 | | - | |
| 153 | + | |
140 | 154 | | |
141 | 155 | | |
142 | 156 | | |
143 | 157 | | |
144 | 158 | | |
145 | | - | |
| 159 | + | |
146 | 160 | | |
147 | 161 | | |
148 | 162 | | |
149 | | - | |
| 163 | + | |
150 | 164 | | |
151 | 165 | | |
152 | 166 | | |
| |||
0 commit comments