Commit 521630b
Validate CIMD scope, grant_types and response_types against AS policy (#5385)
* Validate CIMD scope, grant_types and response_types against AS policy
C3 - Thread ScopesSupported into NewCIMDStorageDecorator so CIMD scope
handling is consistent with DCR. Uses registration.ValidateScopes
(same function as the DCR handler) to validate declared scopes
against the AS allowlist and compute the effective scope list.
When ScopesSupported is unset, the document's declared scopes are
used directly; omitted scopes default to DefaultScopes.
C4 - Reject CIMD documents that declare grant_types or response_types
the embedded AS does not support for public clients
(authorization_code + refresh_token; code). Consistent with DCR
which returns invalid_client_metadata for the same cases.
buildFositeClient now receives pre-computed scopes from fetch() rather
than re-parsing doc.Scope, matching the DCR handler pattern where scope
computation and validation happen before client construction.
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
* Address tgrunnagle review feedback on CIMD validation
F1 Move TestUnionScopes to registration package where UnionScopes lives;
delete now-empty handlers/scopes.go and handlers/scopes_test.go
F2 Add assert.ErrorIs(ErrInvalidClient)/NotErrorIs(ErrNotFound) to
all CIMD policy rejection tests to pin the error type change
F4 Replace 6 positional NewCIMDStorageDecorator args with
CIMDDecoratorConfig struct — prevents silent swap of adjacent []string
F5 Omitted-scope now calls ValidateScopes(nil, scopesSupported) matching
DCR: returns DefaultScopes when DefaultScopes ⊆ ScopesSupported,
error otherwise (document must declare scope explicitly)
F6 Fix dcrErr.Error → dcrErr.ErrorDescription in scope validation hint
so the human-readable description reaches the fosite hint field
F7 slices.Clone scope slices in CIMDDecoratorConfig constructor
F8 Fix buildFositeClient doc: "when empty" not "when nil"
F9 Export ValidatePublicGrantTypes/ValidatePublicResponseTypes from
registration package; replace hand-rolled loops in cimd_decorator.go
with calls to these shared validators — grant_type/response_type
validation is now identical on both DCR and CIMD paths
F10 Rename AcceptsSupportedGrantTypes→AcceptsOmittedGrantTypes and
RejectsRefreshTokenOnly→RejectsGrantTypesMissingAuthorizationCode
F11 Remove redundant TestBuildFositeClient_ScopeDefaultsToScopesSupported
(real decision lives in fetch(), not buildFositeClient)
F12 Update slog.Warn message to name the security consequence when
CIMD+BaselineClientScopes are both configured
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 974aab5 commit 521630b
9 files changed
Lines changed: 398 additions & 204 deletions
File tree
- pkg/authserver
- server
- handlers
- registration
- storage
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
69 | | - | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
70 | 72 | | |
71 | 73 | | |
72 | 74 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
80 | | - | |
| 80 | + | |
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
| |||
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
327 | 327 | | |
328 | 328 | | |
329 | 329 | | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
694 | 694 | | |
695 | 695 | | |
696 | 696 | | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
177 | 177 | | |
178 | 178 | | |
179 | 179 | | |
180 | | - | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
181 | 193 | | |
182 | 194 | | |
183 | 195 | | |
| |||
0 commit comments