-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Implement OAuth 2.0 Server Metadata (RFC 8414) #167
Conversation
This is still a draft. Remaining todos are:
|
41420bd
to
6a62ff9
Compare
.../main/java/org/springframework/security/oauth2/core/AbstractAuthorizationServerMetadata.java
Outdated
Show resolved
Hide resolved
...tion/web/configurers/oauth2/server/authorization/OAuth2AuthorizationServerMetadataTests.java
Outdated
Show resolved
Hide resolved
...tion/web/configurers/oauth2/server/authorization/OAuth2AuthorizationServerMetadataTests.java
Outdated
Show resolved
Hide resolved
17cc870
to
5d5ccf4
Compare
1a41b5b
to
086fe63
Compare
f803509
to
c90e199
Compare
.../main/java/org/springframework/security/oauth2/core/AbstractAuthorizationServerMetadata.java
Outdated
Show resolved
Hide resolved
.../main/java/org/springframework/security/oauth2/core/AbstractAuthorizationServerMetadata.java
Outdated
Show resolved
Hide resolved
00e604a
to
8405211
Compare
26be6d5
to
6de1c6e
Compare
ce76847
to
e017f8f
Compare
555f4e2
to
d6c090f
Compare
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.
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.
...ava/org/springframework/security/oauth2/core/endpoint/OAuth2AuthorizationServerMetadata.java
Outdated
Show resolved
Hide resolved
.../main/java/org/springframework/security/oauth2/core/AbstractAuthorizationServerMetadata.java
Outdated
Show resolved
Hide resolved
...curity/oauth2/core/http/converter/OAuth2AuthorizationServerMetadataHttpMessageConverter.java
Outdated
Show resolved
Hide resolved
...ecurity/oauth2/server/authorization/web/OAuth2AuthorizationServerMetadataEndpointFilter.java
Outdated
Show resolved
Hide resolved
* @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 { |
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.
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?
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.
👍 definitely agree with the proposed change.
Do we also the OidcProdiverConfigurationHttpMessageConverter
to be a subclass of the OAuth2AuthorizationServerConfigurationHttpMessageConverter
?
Quick research notes:
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.
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?
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.
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
.
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.
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 classOAuth2AuthorizationServerConfiguration.Builder
, the builder pattern won't work as, for example,builder.issuer("some string")
would always return the parentBuilder
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
.
c74c743
to
6842a2d
Compare
42b4e57
to
1e0f006
Compare
1e0f006
to
5230ce6
Compare
5230ce6
to
43036cc
Compare
43036cc
to
0a47754
Compare
Thanks for all the work @Kehrlann ! This is now merged. I decided to rename 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! |
See https://tools.ietf.org/html/rfc8414
Closes #54