Skip to content

Conversation

@jhrozek
Copy link
Contributor

@jhrozek jhrozek commented Jan 16, 2026

This patch introduces the HTTP handler layer for the OAuth 2.0 authorization server. The Handler struct coordinates all OAuth/OIDC endpoints and provides route registration via chi router (consistent with ToolHive's API patterns). The discovery endpoints (/.well-known/openid-configuration and jwks.json) are fully implemented and OIDC Discovery 1.0 compliant, including the REQUIRED fields subject_types_supported and id_token_signing_alg_values_supported. The signing algorithms are dynamically extracted from the JWKS keys. OAuth endpoints (authorize, token, callback, register) are stubbed for future implementation.

In the full authserver, the Handler is instantiated by server_impl.go with four dependencies: a fosite.OAuth2Provider (the OAuth protocol engine), AuthorizationServerConfig (issuer, token lifespans, signing keys), Storage (where OAuth state is persisted), and an upstream.Provider (for relaying tokens to/from the upstream IDP). The Server.Handler() method returns the chi router as http.Handler, which can be mounted into any HTTP server. This design keeps the handler layer focused on HTTP concerns while delegating OAuth logic to fosite and state management to the storage layer.

This patch introduces the HTTP handler layer for the OAuth 2.0 authorization
server. The Handler struct coordinates all OAuth/OIDC endpoints and provides
route registration via chi router (consistent with ToolHive's API patterns).
The discovery endpoints (/.well-known/openid-configuration and jwks.json) are
fully implemented and OIDC Discovery 1.0 compliant, including the REQUIRED
fields subject_types_supported and id_token_signing_alg_values_supported. The
signing algorithms are dynamically extracted from the JWKS keys. OAuth endpoints
(authorize, token, callback, register) are stubbed for future implementation.

In the full authserver, the Handler is instantiated by server_impl.go
with four dependencies: a fosite.OAuth2Provider (the OAuth protocol engine),
AuthorizationServerConfig (issuer, token lifespans, signing keys), Storage
(where OAuth state is persisted), and an upstream.Provider (for relaying tokens
to/from the upstream IDP). The Server.Handler() method returns the chi router
as http.Handler, which can be mounted into any HTTP server. This design keeps
the handler layer focused on HTTP concerns while delegating OAuth logic to
fosite and state management to the storage layer.
@github-actions github-actions bot added the size/M Medium PR: 300-599 lines changed label Jan 16, 2026
@jhrozek jhrozek requested a review from tgrunnagle January 16, 2026 15:38
@codecov
Copy link

codecov bot commented Jan 16, 2026

Codecov Report

❌ Patch coverage is 76.47059% with 16 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.68%. Comparing base (e773160) to head (e415214).

Files with missing lines Patch % Lines
pkg/authserver/server/handlers/discovery.go 69.81% 12 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3321      +/-   ##
==========================================
+ Coverage   64.63%   64.68%   +0.05%     
==========================================
  Files         369      371       +2     
  Lines       35953    36021      +68     
==========================================
+ Hits        23238    23300      +62     
+ Misses      10889    10887       -2     
- Partials     1826     1834       +8     

☔ 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.

}
}

// OIDCDiscoveryHandler handles GET /.well-known/openid-configuration requests.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: Do we also want to support /.well-known/oauth-authorization-server in case the client is not using OIDC discovery?


// OIDCDiscoveryDocument represents the OIDC discovery document structure.
// Implements OpenID Connect Discovery 1.0 specification.
type OIDCDiscoveryDocument struct {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we have this in another package?

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.

4 participants