-
Notifications
You must be signed in to change notification settings - Fork 171
Add OAuth handler infrastructure and discovery endpoints #3321
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
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.
Codecov Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
| } | ||
| } | ||
|
|
||
| // OIDCDiscoveryHandler handles GET /.well-known/openid-configuration requests. |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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?
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.