Skip to content

feat: RFC 8707 resource indicators for OAuth 2.0 token endpoint - #244

Open
saucam wants to merge 4 commits into
mainfrom
fix/codeoid-audience-pipeline-scopes
Open

feat: RFC 8707 resource indicators for OAuth 2.0 token endpoint#244
saucam wants to merge 4 commits into
mainfrom
fix/codeoid-audience-pipeline-scopes

Conversation

@saucam

@saucam saucam commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds resource parameter support on POST /oauth2/token per RFC 8707 §2, stamping the supplied URI as aud on the issued access token
  • Adds allowed_resources and default_audience config fields; when allowed_resources is non-empty, any resource not in the list is rejected with invalid_target (fail-closed)
  • Propagates ResolvedAudience through all six OAuth grant types: client_credentials, jwt_bearer, NHI token exchange, API key, authorization code, refresh token, and CIBA redeem
  • Preserves audienceScopeProfiles (BR-7): named audience profile wins over resource on external-principal exchange
  • Backward-compatible: no resource + no default_audienceaud remains the issuer URL (existing behavior)

Test plan

  • go test ./internal/service/... -run TestValidateAllowedResources — 5 sub-tests pass
  • go test ./tests/integration/... -run TestResourceIndicator — 8 sub-tests pass (open-mode, restricted-mode, blocked, malformed, fragment, no-resource fallback, DefaultAudience, jwt_bearer)
  • go test ./tests/integration/... -run TestIssuedToken — existing + new TestIssuedTokenResourceOverridesAud pass
  • Full go build ./... clean

Fixes: #199

🤖 Generated with Claude Code

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

saucam and others added 3 commits July 23, 2026 06:35
…Audience)

Add AllowedResources []string and DefaultAudience string to the top-level
Config struct (koanf: allowed_resources / default_audience). Wire startup
validation via ValidateAllowedResources (mirrors ResolveAudienceScopeProfiles:
rejects blank entries, fail closed). Extend OAuthServiceConfig and OAuthService
with the two fields; wire them in NewOAuthService and server.go.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add Resource string to TokenInput.Body and TokenRequest. Resolve it once
in Token() before dispatch via resolveResourceAudience (URI validation +
allowlist check + DefaultAudience fallback). Store as ResolvedAudience and
pass Audience: req.ResolvedAudience into all six grant handlers
(client_credentials, jwt_bearer, token_exchange, api_key,
authorization_code, refresh_token) and ExternalPrincipalExchange (BR-7:
named audience profile wins). Wire Audience through RedeemInput for CIBA.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds tests/integration/resource_indicator_test.go covering the full
RFC 8707 end-to-end path (open-mode, restricted-mode, blocked, malformed,
DefaultAudience fallback, jwt_bearer grant). Adds
TestIssuedTokenResourceOverridesAud to jwt_svid_aud_test.go as a
regression pin for the resource→aud override on client_credentials.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@saucam
saucam force-pushed the fix/codeoid-audience-pipeline-scopes branch from 2fd2ef0 to abd78fb Compare July 23, 2026 04:36
@saucam

saucam commented Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

Auto-fixed by pr-shepherd (iteration 1 - branch hygiene):

  • Rebased on origin/main: 2 commits (the codeoid audience pipeline-scopes fixes) were already merged upstream and dropped by git during rebase. Branch now has 3 commits ahead of main: the RFC 8707 feature commits.
  • No commit subjects needed rewriting — all 3 match the required CI regex (feat: prefix, no scope parens).

Re-running CI. These are mechanical changes with no behavior impact.

Addresses HIGH severity xDS RBAC and HTTP/2 vulnerability.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OAuth access tokens: aud defaults to the issuer — adopt RFC 8707 resource indicators so it names the target resource server

2 participants