Skip to content

feat: Add RFC 8414 OAuth 2.0 Authorization Server Metadata endpoint#1665

Open
zacharypodbela wants to merge 2 commits intodjango-oauth:masterfrom
ForaTravel:rfc-8414-oauth-server-metadata
Open

feat: Add RFC 8414 OAuth 2.0 Authorization Server Metadata endpoint#1665
zacharypodbela wants to merge 2 commits intodjango-oauth:masterfrom
ForaTravel:rfc-8414-oauth-server-metadata

Conversation

@zacharypodbela
Copy link

Summary

Implements the /.well-known/oauth-authorization-server discovery endpoint per RFC 8414 — OAuth 2.0 Authorization Server Metadata.

Closes #1099

Changes

  • New oauth2_provider/views/metadata.py — contains ServerMetadataViewMixin (shared URL-building logic for discovery views) and OAuthServerMetadataView (the RFC 8414 endpoint). The view is available regardless of whether OIDC is enabled and has no OIDCOnlyMixin dependency.
  • Refactored ConnectDiscoveryInfoView — now inherits ServerMetadataViewMixin, eliminating the duplicated if/else URL-building logic that previously existed for the request-relative vs OIDC_ISS_ENDPOINT-anchored cases.
  • New settings with sensible defaults:
    • OAUTH2_RESPONSE_TYPES_SUPPORTED
    • OAUTH2_GRANT_TYPES_SUPPORTED
    • OAUTH2_TOKEN_ENDPOINT_AUTH_METHODS_SUPPORTED
  • New oauth2_metadata_issuer() helper on OAuth2ProviderSettings, mirroring the existing oidc_issuer().
  • New URL oauth-server-metadata registered in base_urlpatterns.
  • Tests covering: full response structure, request-derived issuer (no OIDC_ISS_ENDPOINT), jwks_uri conditional on RSA key presence, CORS header, and availability when OIDC is disabled.

Relationship to OIDC discovery

RFC 8414 is the OAuth 2.0 equivalent of OpenID Connect discovery. The key differences from ConnectDiscoveryInfoView:

/.well-known/openid-configuration /.well-known/oauth-authorization-server
Spec OpenID Connect Discovery 1.0 RFC 8414
Requires OIDC Yes No
userinfo_endpoint Yes No
jwks_uri Always Only if RSA key configured
grant_types_supported No Yes
revocation_endpoint No Yes
introspection_endpoint No Yes

Implements the /.well-known/oauth-authorization-server discovery endpoint
per RFC 8414. Unlike the existing OIDC discovery endpoint, this is available
regardless of whether OIDC is enabled.

- Add OAuthServerMetadataView and ServerMetadataViewMixin in new metadata.py
- Refactor ConnectDiscoveryInfoView to use ServerMetadataViewMixin, removing
  duplicated URL-building logic
- Add OAUTH2_RESPONSE_TYPES_SUPPORTED, OAUTH2_GRANT_TYPES_SUPPORTED, and
  OAUTH2_TOKEN_ENDPOINT_AUTH_METHODS_SUPPORTED settings with defaults
- Add oauth2_metadata_issuer() helper to OAuth2ProviderSettings
- Register endpoint in base_urlpatterns as oauth-server-metadata

Closes django-oauth#1099

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
- Add oauth2_server_metadata.rst with endpoint description and example response
- Link from index.rst toctree after oidc
- Document OAUTH2_RESPONSE_TYPES_SUPPORTED, OAUTH2_GRANT_TYPES_SUPPORTED,
  and OAUTH2_TOKEN_ENDPOINT_AUTH_METHODS_SUPPORTED in settings.rst

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@zacharypodbela
Copy link
Author

@dopry could I get a review on this?

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.

RFC 8414 .well-known/oauth-authorization-server metadata

1 participant