Commit 0dc7c05
Refactor OAuth token persistence and fix Resource/Audience conflation
Extract TokenPersistenceManager to pkg/auth/remote to eliminate the
repeated nil-check + fetch-cached-token + create-token-source pattern
shared by three callers. Generalize RegistryOAuthConfig to OAuthConfig
in pkg/config, adding a Resource field (RFC 8707) and an injectable
configUpdater callback so callers can supply their own persistence logic.
Fix a bug where Audience (provider-specific, e.g. Auth0) was passed
where Resource (RFC 8707 resource indicator) was expected: Resource now
flows to CreateOAuthConfigFromOIDC and Audience is routed into
OAuthParams["audience"] for authorization URL parameters.
Add field-level doc comments to OAuthConfig clarifying the distinction
between Audience and Resource. Fix %w error wrapping in tryRestoreFromCache
and tryRestoreFromCachedTokens. Convert configUpdaterFunc from a type alias
to a named type.
Add unit tests covering: FetchRefreshToken direct paths, the
Resource-vs-Audience split in buildOAuthFlowConfig (regression guard),
configUpdater callback invocation, endpoint-override logic,
wrapWithPersistence persistence callbacks, and resolveClientCredentials
priority logic.
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>1 parent 9824210 commit 0dc7c05
File tree
13 files changed
+989
-98
lines changed- pkg
- auth/remote
- config
- registry
- auth
13 files changed
+989
-98
lines changed| 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 | + | |
| 9 | + | |
| 10 | + | |
8 | 11 | | |
9 | 12 | | |
10 | 13 | | |
11 | 14 | | |
12 | 15 | | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
18 | 28 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
237 | 237 | | |
238 | 238 | | |
239 | 239 | | |
240 | | - | |
241 | | - | |
242 | | - | |
243 | | - | |
244 | | - | |
245 | | - | |
| 240 | + | |
246 | 241 | | |
247 | | - | |
| 242 | + | |
248 | 243 | | |
249 | 244 | | |
250 | 245 | | |
| |||
284 | 279 | | |
285 | 280 | | |
286 | 281 | | |
287 | | - | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
288 | 285 | | |
289 | | - | |
290 | 286 | | |
291 | 287 | | |
292 | 288 | | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
293 | 292 | | |
294 | 293 | | |
295 | 294 | | |
| |||
0 commit comments