Skip to content
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

auto-configuration for spring-security-oauth2-resource-server by oidc issuer location #14190

Conversation

ayudovin
Copy link
Contributor

adding auto-configuration for spring-security-oauth2-resource-server by oidc issuer location
this enhancement

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Aug 23, 2018
return new NimbusJwtDecoderJwkSupport(
this.properties.getJwt().getJwk().getSetUri());
}

@Bean
@ConditionalOnProperty(name = "spring.security.oauth2.resource.jwt.jwk.oidc-issuer-location")
Copy link
Contributor

Choose a reason for hiding this comment

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

The property should not use the jwk group as this configuration isn't related to it. The property should be more like:

spring.security.oauth2.resource.jwt.oidc-issuer-location

Copy link
Contributor Author

@ayudovin ayudovin Aug 23, 2018

Choose a reason for hiding this comment

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

yeah, it's my mistake, I've fixed it

.withClassLoader(new FilteredClassLoader(JwtAuthenticationToken.class))
.run((context) -> assertThat(getBearerTokenFilter(context)).isNull());
}

Copy link
Contributor

Choose a reason for hiding this comment

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

@ayudovin We should probably add a test for what happens when both oidc-issuer-location and jwk-set-uri are present. My guess is jwk-set-uri should win but let's see if @jzheaux thinks otherwise.

Copy link
Contributor

Choose a reason for hiding this comment

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

The other option is to fail hard if both are specified.

Copy link
Contributor Author

@ayudovin ayudovin Aug 24, 2018

Choose a reason for hiding this comment

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

From my point of view the second option will be better but now jwk-set-uri wins.
I have added test for checking it.

Copy link
Member

Choose a reason for hiding this comment

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

I think that jwk-set-uri should win because it is more specific.

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed that jwk-set-uri is more specific and should take precedence because of that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, now jwk-set-uri has precedence.

… into auto-configuration-for-spring-security-oauth2-resource-server-by-oidc-issuer-location

# Conflicts:
#	spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/resource/OAuth2ResourceServerProperties.java
#	spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/resource/servlet/OAuth2ResourceServerJwkConfiguration.java
#	spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc
@@ -44,4 +47,12 @@ public JwtDecoder jwtDecoder() {
return new NimbusJwtDecoderJwkSupport(this.properties.getJwt().getJwkSetUri());
}

@Bean
@ConditionalOnProperty(name = "spring.security.oauth2.resourceserver.jwt.oidc-issuer-location")
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should make it explicit that jwk-set-uri should take precedence by adding a custom condition that checks that spring.security.oauth2.resourceserver.jwt.oidc-issuer-location is present and spring.security.oauth2.resourceserver.jwt.jwk-set-uri is not present.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, I'll add custom condition

@@ -44,4 +49,12 @@ public JwtDecoder jwtDecoder() {
return new NimbusJwtDecoderJwkSupport(this.properties.getJwt().getJwkSetUri());
}

@Bean
@Conditional(OidcIssuerLocationCondition.class)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mbhave I've added custom condition.

@mbhave mbhave added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Aug 24, 2018
@mbhave mbhave added this to the Backlog milestone Aug 24, 2018
@mbhave mbhave closed this in cf31325 Aug 24, 2018
mbhave added a commit that referenced this pull request Aug 24, 2018
* gh-14190:
  Polish "OIDC issuer uri in OAuth resource server config"
  Support OIDC issuer uri in OAuth resource server config
@mbhave
Copy link
Contributor

mbhave commented Aug 24, 2018

Thanks again, @ayudovin! This change is now on master along with this polish commit. I changed oidcIssuerLocation to issuerUri to make it consistent with the other properties in OAuth2ClientProperties and OAuth2ResourceServerProperties.

@mbhave mbhave modified the milestones: Backlog, 2.1.0.M3 Aug 24, 2018
@ayudovin
Copy link
Contributor Author

@mbhave , it makes sense. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants