Skip to content

Conversation

@jhrozek
Copy link
Contributor

@jhrozek jhrozek commented Jan 27, 2026

This PR introduces the Config type for the OAuth authorization server, providing a pure configuration interface with full validation. The config supports signing keys via a KeyProvider interface (with auto-generation for development), HMAC secrets for opaque tokens (authorization codes and refresh tokens), sensible token lifespan defaults (1h access, 7d refresh, 10m auth code), and pre-registered OAuth client definitions supporting both public and confidential client types. Issuer URL validation enforces HTTPS per OIDC Core Section 3.1.2.1 and RFC 8414, with a localhost exception for development workflows.

This configuration layer is consumed by the upcoming newServer() implementation which creates the fosite-based OAuth 2.0 authorization server. The server calls applyDefaults() to fill in missing values and Validate() to ensure correctness before constructing the AuthorizationServerParams that configure the OAuth2 provider, handlers, and endpoints. The "just works" philosophy enables quick development startup with ephemeral secrets while warning about their limitations, and the config cleanly separates concerns: this layer handles what the server needs, while the server implementation handles how it delivers OAuth/OIDC functionality.

This PR introduces the `Config` type for the OAuth authorization server, providing a pure configuration interface with full validation. The config supports signing keys via a `KeyProvider` interface (with auto-generation for development), HMAC secrets for opaque tokens (authorization codes and refresh tokens), sensible token lifespan defaults (1h access, 7d refresh, 10m auth code), and pre-registered OAuth client definitions supporting both public and confidential client types. Issuer URL validation enforces HTTPS per OIDC Core Section 3.1.2.1 and RFC 8414, with a localhost exception for development workflows.

This configuration layer is consumed by the core `newServer()` implementation in the `auth-proxy-pr-11-core-authserver` branch, which creates the fosite-based OAuth 2.0 authorization server. The server calls `applyDefaults()` to fill in missing values and `Validate()` to ensure correctness before constructing the `AuthorizationServerParams` that configure the OAuth2 provider, handlers, and endpoints. The "just works" philosophy enables quick development startup with ephemeral secrets while warning about their limitations, and the config cleanly separates concerns: this layer handles what the server needs, while the server implementation handles how it delivers OAuth/OIDC functionality.
@github-actions github-actions bot added the size/M Medium PR: 300-599 lines changed label Jan 27, 2026
@jhrozek jhrozek requested a review from tgrunnagle January 27, 2026 22:33
@codecov
Copy link

codecov bot commented Jan 27, 2026

Codecov Report

❌ Patch coverage is 90.80460% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 65.12%. Comparing base (2df1a15) to head (50564ee).
⚠️ Report is 14 commits behind head on main.

Files with missing lines Patch % Lines
pkg/authserver/config.go 90.80% 4 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3472      +/-   ##
==========================================
+ Coverage   64.88%   65.12%   +0.23%     
==========================================
  Files         396      400       +4     
  Lines       38512    39006     +494     
==========================================
+ Hits        24990    25403     +413     
- Misses      11572    11635      +63     
- Partials     1950     1968      +18     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

tgrunnagle
tgrunnagle previously approved these changes Jan 28, 2026
jhrozek and others added 3 commits January 28, 2026 16:46
The Clients field and ClientConfig type were validated but never
actually used to register OAuth clients with storage. The server
relies entirely on Dynamic Client Registration (DCR) for client
registration. Removing this dead code per PR review feedback.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Refactors the authserver Config to use a slice of UpstreamConfig
instead of a single Upstream pointer. This prepares for future
multi-upstream IDP support while currently validating that exactly
one upstream is configured.

Changes:
- Add UpstreamConfig type with Name and Config fields
- Change Upstream field to Upstreams slice
- Add GetUpstream() helper for current single-upstream code paths
- Add validateUpstreams() with uniqueness and count validation
- Update tests for new structure

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Adds two new fields for MCP specification compliance:

- ScopesSupported: OAuth 2.0 scopes advertised in discovery documents,
  defaults to ["openid", "offline_access"]
- AllowedAudiences: Valid resource URIs for RFC 8707 resource parameter
  validation, required for MCP compliance

AllowedAudiences is validated as non-empty since MCP clients MUST include
the resource parameter per specification.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@github-actions github-actions bot added size/M Medium PR: 300-599 lines changed and removed size/M Medium PR: 300-599 lines changed labels Jan 28, 2026
@tgrunnagle tgrunnagle merged commit 0ed98f8 into main Jan 28, 2026
66 checks passed
@tgrunnagle tgrunnagle deleted the auth-proxy-pr-11-config branch January 28, 2026 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Medium PR: 300-599 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants