Commit 8fbc935
Wire CIMD config through embedded AS and enable storage decorator (#5348)
* Wire CIMD config through embedded AS and enable storage decorator
Phase 2 PR 3 — config threading and server wiring.
Config chain: RunConfig.CIMD → Config.CIMD* → AuthorizationServerParams
→ AuthorizationServerConfig → discovery handler.
Changes:
- config.go: add CIMDRunConfig struct and CIMD* fields to Config;
defaults (256 entries, 5 min fallback TTL) applied in applyDefaults();
validation (cacheMaxSize >= 1 when enabled) in Validate()
- runner/embeddedauthserver.go: add resolveCIMDConfig helper to unpack
nullable *CIMDRunConfig; populate Config.CIMD* from RunConfig.CIMD
- server/provider.go: add CIMDEnabled to AuthorizationServerParams and
AuthorizationServerConfig; wire through NewAuthorizationServerConfig
- server_impl.go: wrap storage with CIMDStorageDecorator when enabled
(after legacy migration, before createProvider — decorator must be in
place before fosite holds a reference to the storage instance);
pass CIMDEnabled to AuthorizationServerParams
- server/handlers/discovery.go: set ClientIDMetadataDocumentSupported
in buildOAuthMetadata() — both OAuth AS and OIDC discovery endpoints
advertise CIMD support when enabled
CIMD is opt-in (disabled by default) to avoid introducing outbound
HTTPS fetching in existing deployments without explicit operator action.
Relates to #4825
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
* Address PR review feedback on CIMD wiring and add missing tests
- Fix CacheFallbackTTL comment to say it is a fixed TTL (not fallback);
matches the fix already applied in PR #5343
- Add TODO(cimd) comment above CIMDRunConfig noting the CRD exposure gap
- Add discovery handler tests: CIMDEnabled=true advertises the flag,
CIMDEnabled=false omits it, for both AS metadata and OIDC endpoints
- Add config defaults tests: CIMDEnabled=true fills in cache size/TTL
defaults; CIMDEnabled=false leaves zero fields unchanged
- Add resolveCIMDConfig nil-guard test: nil input returns zero values,
non-nil passes all fields through
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
* Extend IsClientIDMetadataDocumentURL to accept http://localhost URLs
The embedded AS must resolve CIMD client_ids for local development and
testing the same way FetchClientMetadataDocument does — accepting
http://localhost and http://127.x.x.x in addition to https://. This
brings IsClientIDMetadataDocumentURL in line with validateCIMDClientURL
in pkg/oauthproto/cimd/fetch.go which already permits these schemes.
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
* Regenerate swagger docs to include CIMDRunConfig
Run task docs to pick up the new CIMDRunConfig struct added in this PR.
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
* Default to registration.DefaultScopes when CIMD doc omits scope field
When a CIMD document does not include a scope field, buildFositeClient
was producing a client with no allowed scopes. Any authorization request
specifying openid, profile, or offline_access would then fail with
"scope not allowed". DCR registration applies DefaultScopes in the same
situation, so CIMD clients should behave identically.
Found during manual testing with VS Code as a CIMD client.
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
* Trigger CI re-run
* Address PR review feedback on CIMD wiring
- Fix IsClientIDMetadataDocumentURL comment: accepted loopbacks are
localhost/127.0.0.1/[::1], not the full 127.x.x.x range
- Fix hostFromURL doc: returns host+port, not host without port
- Add loopback and subdomain-bypass test cases to
TestIsClientIDMetadataDocumentURL (Claude blocking issue)
- Fix Config.CIMDCacheFallbackTTL comment: Cache-Control is not parsed
- Add validation: CIMDCacheFallbackTTL must be non-negative when enabled
- Clone registration.DefaultScopes in buildFositeClient to prevent
aliasing the package-level slice
- Fix CIMDDisabled discovery test to decode to map[string]interface{}
so it verifies the field is truly absent (omitempty) not just false
The DefaultScopes change in cimd_decorator.go was introduced here
(rather than in PR #5343) because the gap was discovered during manual
testing of the wiring: VS Code's CIMD document omits scope and the nil
scopes caused an auth failure.
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
* Use net/url to extract host in IsClientIDMetadataDocumentURL
net/url is already imported by four other files in pkg/oauthproto, so
the previous comment about keeping the package "import-free" was
incorrect. url.Parse handles IPv6 brackets and other edge cases
correctly without manual string manipulation.
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
* Address tgrunnagle feedback on CIMD wiring
C1 - Fix CacheFallbackTTL to string in CIMDRunConfig so YAML/JSON
operators can write "5m" instead of nanoseconds. resolveCIMDConfig
parses it with time.ParseDuration at runtime.
C6 - Add slog.Debug when applyDefaults substitutes CIMD defaults,
matching the pattern used by the sibling token-lifespan defaults.
C7 - Add CIMDRunConfig.Validate() and call it from RunConfig.Validate()
so CIMD misconfiguration fails at the wire-format boundary before
the runner resolves secrets.
C10 - Add test cases to TestConfigValidate and TestRunConfigValidate
covering all new CIMD validation paths.
C11 - Add TestNewServer_CIMDEnabled_WrapsStorage: verifies the CIMD
decorator is actually installed in the storage chain when
CIMDEnabled=true.
C12 - Add comment in discovery.go explaining why
client_id_metadata_document_supported is in OIDC discovery.
C13 - Add doc comment on server.storage noting it may be decorated.
C14 - Add note to IsClientIDMetadataDocumentURL about pkg/auth/remote
callers and why the loopback widening is safe there.
Regenerate swagger docs: CacheFallbackTTL now serialises as string.
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>1 parent 394b2e7 commit 8fbc935
16 files changed
Lines changed: 439 additions & 13 deletions
File tree
- docs/server
- pkg
- authserver
- runner
- server
- handlers
- storage
- oauthproto
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
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 | |
|---|---|---|---|
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
93 | 98 | | |
94 | 99 | | |
95 | 100 | | |
96 | 101 | | |
97 | 102 | | |
98 | 103 | | |
99 | 104 | | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
100 | 110 | | |
101 | 111 | | |
102 | 112 | | |
| |||
118 | 128 | | |
119 | 129 | | |
120 | 130 | | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
121 | 171 | | |
122 | 172 | | |
123 | 173 | | |
| |||
537 | 587 | | |
538 | 588 | | |
539 | 589 | | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
540 | 604 | | |
541 | 605 | | |
542 | 606 | | |
| |||
589 | 653 | | |
590 | 654 | | |
591 | 655 | | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
592 | 663 | | |
593 | 664 | | |
594 | 665 | | |
| |||
819 | 890 | | |
820 | 891 | | |
821 | 892 | | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
822 | 901 | | |
823 | 902 | | |
824 | 903 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
117 | 124 | | |
118 | 125 | | |
119 | 126 | | |
| |||
431 | 438 | | |
432 | 439 | | |
433 | 440 | | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
434 | 449 | | |
435 | 450 | | |
436 | 451 | | |
| |||
589 | 604 | | |
590 | 605 | | |
591 | 606 | | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
176 | 176 | | |
177 | 177 | | |
178 | 178 | | |
| 179 | + | |
| 180 | + | |
179 | 181 | | |
180 | 182 | | |
181 | 183 | | |
| |||
188 | 190 | | |
189 | 191 | | |
190 | 192 | | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
191 | 196 | | |
192 | 197 | | |
193 | 198 | | |
| |||
782 | 787 | | |
783 | 788 | | |
784 | 789 | | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
785 | 811 | | |
786 | 812 | | |
787 | 813 | | |
| |||
0 commit comments