Match ResourceServerCondition if JWK config present

Closes gh-8350
This commit is contained in:
Madhura Bhave 2017-02-21 12:02:49 -08:00
parent 98a2ae3b91
commit 67810abd9e
2 changed files with 14 additions and 0 deletions

View File

@ -161,6 +161,10 @@ public class OAuth2ResourceServerConfiguration {
return ConditionOutcome
.match(message.foundExactly("JWT resource configuration"));
}
if (!resolver.getSubProperties("jwk").isEmpty()) {
return ConditionOutcome
.match(message.foundExactly("JWK resource configuration"));
}
if (StringUtils.hasText(resolver.getProperty("user-info-uri"))) {
return ConditionOutcome
.match(message.foundExactly("user-info-uri property"));

View File

@ -389,6 +389,16 @@ public class OAuth2AutoConfigurationTests {
.isEqualTo(PrePostAnnotationSecurityMetadataSource.class.getName());
}
@Test
public void resourceServerConditionWhenJwkConfigurationPresentShouldMatch() throws Exception {
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context,
"security.oauth2.resource.jwk.key-set-uri:http://my-auth-server/token_keys");
this.context.register(ResourceServerConfiguration.class, MinimalSecureWebApplication.class);
this.context.refresh();
assertThat(countBeans(RESOURCE_SERVER_CONFIG)).isEqualTo(1);
}
/**
* Connect to the oauth service, get a token, and then attempt some operations using
* it.