Skip to content

Implement OAuth 2.0 Server Metadata (RFC 8414) #167

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

Merged
merged 1 commit into from
Apr 30, 2021

Conversation

Kehrlann
Copy link
Contributor

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Nov 26, 2020
@Kehrlann
Copy link
Contributor Author

Kehrlann commented Nov 26, 2020

This is still a draft. Remaining todos are:

  • Make the default values common for OIDC Provider Config + OAuth 2.0 Server Metadata
  • Integration tests
  • Cleanup TODOs
  • General polishing
  • Make sure test coverage is appropriate
  • A pass on Javadoc
  • Ensuring consistency with ab591d (polish commit for OIDC Provider Configuration)

@jgrandja jgrandja self-assigned this Nov 26, 2020
@jgrandja jgrandja added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Nov 26, 2020
@jgrandja jgrandja added this to the 0.1.0 milestone Nov 26, 2020
@Kehrlann Kehrlann force-pushed the oauth2-server-metadata branch 3 times, most recently from 41420bd to 6a62ff9 Compare November 27, 2020 10:28
@Kehrlann Kehrlann force-pushed the oauth2-server-metadata branch from 17cc870 to 5d5ccf4 Compare November 27, 2020 16:35
@Kehrlann Kehrlann marked this pull request as ready for review November 27, 2020 16:35
@Kehrlann Kehrlann force-pushed the oauth2-server-metadata branch 4 times, most recently from 1a41b5b to 086fe63 Compare November 30, 2020 13:51
@Kehrlann Kehrlann force-pushed the oauth2-server-metadata branch 3 times, most recently from f803509 to c90e199 Compare December 15, 2020 09:48
@Kehrlann Kehrlann force-pushed the oauth2-server-metadata branch 2 times, most recently from 00e604a to 8405211 Compare December 15, 2020 11:09
@jgrandja jgrandja modified the milestones: 0.1.0, 0.1.1 Jan 6, 2021
@Kehrlann Kehrlann force-pushed the oauth2-server-metadata branch 2 times, most recently from 26be6d5 to 6de1c6e Compare January 19, 2021 14:02
@Kehrlann Kehrlann force-pushed the oauth2-server-metadata branch from ce76847 to e017f8f Compare February 2, 2021 10:05
@Kehrlann Kehrlann force-pushed the oauth2-server-metadata branch 5 times, most recently from 555f4e2 to d6c090f Compare February 13, 2021 13:26
Copy link
Collaborator

@jgrandja jgrandja left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @Kehrlann ! Please see review comments.

In addition to the comments, please ensure copyright year is 2020-2021 and @since is 0.1.1 for all files.

* @see <a target="_blank" href="https://tools.ietf.org/html/rfc8414#section-2">2. Authorization Server Metadata</a>
* @see <a target="_blank" href="https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata">3. OpenID Provider Metadata</a>
*/
public interface AuthorizationServerMetadataClaimAccessor extends ClaimAccessor {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I feel like we should merge this into OAuth2AuthorizationServerMetadataClaimAccessor. Then we can remove AuthorizationServerMetadataClaimAccessor, AuthorizationServerMetadataClaimNames and AbstractAuthorizationServerMetadata. This change will simplify the hierarchy.

Although revocation_endpoint, revocation_endpoint_auth_methods_supported and code_challenge_methods_supported are not defined in OIDC Provider Metadata, I believe an OIDC provider will support these configurations either way.

What are your thoughts on this proposed change?

Copy link
Contributor Author

@Kehrlann Kehrlann Mar 19, 2021

Choose a reason for hiding this comment

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

👍 definitely agree with the proposed change.

Do we also the OidcProdiverConfigurationHttpMessageConverter to be a subclass of the OAuth2AuthorizationServerConfigurationHttpMessageConverter ?

Quick research notes:

  • Okta supports those three claims in their OIDC configuration
  • Google supports revocation_endpoint and code_challenge_methods_supported
  • Microsoft supports none of them

Copy link
Contributor Author

Choose a reason for hiding this comment

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

One caveat, removing AbstractAuthorizationServerMetadata, using OAuth2AuthorizationServerConfiguration instead in OidcProviderConfiguration extends OAuth2AuthorizationServerConfiguration

Is only possible if we make OAuth2AuthorizationServerConfiguration not final. And I believe we want our model classes to be final?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Our typical design process is to make things final (or restrict access) at the start. However, if there is need to open things up than we do only if it makes sense. This is one of those instances so it's ok to make OAuth2AuthorizationServerConfiguration non-final BUT make the constructor protected.

Copy link
Contributor Author

@Kehrlann Kehrlann Mar 22, 2021

Choose a reason for hiding this comment

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

So I've tried this, unfortunately the type hierarchy with generic builders does not allow to have this kind of hierarchy:

- OAuth2AuthorizationServerConfiguration
  - Builder (inner class)
  - static builder() method, returning a Builder
  - OidcProviderConfiguration extends OAuth2AuthorizationServerConfiguration
    - OidcBuilder (inner class, extends Builder) 
    - static builder() method, returning an OidcBuilder

Problems are:

  • If OidcBuilder extends the concrete class OAuth2AuthorizationServerConfiguration.Builder, the builder pattern won't work as, for example, builder.issuer("some string") would always return the parent Builder type. I don't think we can get away without a base abstract builder, see this Stackoverflow thread for reference for reference.
  • If both Builder and OidcBuilder inherit a common, generic, AbstractBuilder, then OidcProviderConfiguration.builder() return type becomes incompatible with that of OAuth2AuthorizationServerConfiguration.builder().

If we really want to get rid of the AbstractAuthorizationServerConfiguration, we could have the abstract builder and default claims in the AuthorizationServerMetadataClaimAccessor interface. But that feels a bit far-fetched, this is an Accessor interface, sounds very read-only to me.

For now I have just pulled all behavior from OAuth2AuthorizationServerConfiguration and associated builder into AbstractAuthorizationServerConfiguration.

@Kehrlann Kehrlann force-pushed the oauth2-server-metadata branch 5 times, most recently from c74c743 to 6842a2d Compare March 25, 2021 18:00
@Kehrlann Kehrlann force-pushed the oauth2-server-metadata branch 2 times, most recently from 42b4e57 to 1e0f006 Compare March 31, 2021 09:29
@Kehrlann Kehrlann force-pushed the oauth2-server-metadata branch from 1e0f006 to 5230ce6 Compare April 13, 2021 15:05
@Kehrlann Kehrlann force-pushed the oauth2-server-metadata branch from 5230ce6 to 43036cc Compare April 27, 2021 07:33
@Kehrlann Kehrlann force-pushed the oauth2-server-metadata branch from 43036cc to 0a47754 Compare April 28, 2021 08:14
jgrandja added a commit that referenced this pull request Apr 30, 2021
@jgrandja jgrandja merged commit 0a47754 into spring-projects:main Apr 30, 2021
jgrandja pushed a commit that referenced this pull request Apr 30, 2021
@jgrandja
Copy link
Collaborator

Thanks for all the work @Kehrlann ! This is now merged.

I decided to rename OAuth2AuthorizationServerConfiguration back to the original OAuth2AuthorizationServerMetadata. It made more sense.

I also made a few other changes in a follow-up polish commit. Please let me know if you have any questions in regards to the changes. Thanks!

@jgrandja jgrandja added the status: duplicate A duplicate of another issue label Apr 30, 2021
doba16 pushed a commit to doba16/spring-authorization-server that referenced this pull request Apr 21, 2023
doba16 pushed a commit to doba16/spring-authorization-server that referenced this pull request Apr 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate A duplicate of another issue type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement OAuth 2.0 Authorization Server Metadata
3 participants