Merge pull request #4316 from klieber/bugfix/oauth2-auth-server-autoconfig

* pr/4316:
  Polish contribution
  Add missing properties to OAuth2AutorizationServer
pull/4316/merge
Stephane Nicoll 9 years ago
commit c98d3208b2

@ -92,6 +92,16 @@ public class OAuth2AuthorizationServerConfiguration
AuthorityUtils.authorityListToSet(this.details.getAuthorities())
.toArray(new String[0]))
.scopes(this.details.getScope().toArray(new String[0]));
if (this.details.getAutoApproveScopes() != null) {
builder.autoApprove(this.details.getAutoApproveScopes().toArray(new String[0]));
}
if (this.details.getAccessTokenValiditySeconds() != null) {
builder.accessTokenValiditySeconds(this.details.getAccessTokenValiditySeconds());
}
if (this.details.getRefreshTokenValiditySeconds() != null) {
builder.refreshTokenValiditySeconds(this.details.getRefreshTokenValiditySeconds());
}
if (this.details.getRegisteredRedirectUri() != null) {
builder.redirectUris(
this.details.getRegisteredRedirectUri().toArray(new String[0]));

@ -143,13 +143,22 @@ public class OAuth2AutoConfigurationTests {
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context,
"security.oauth2.client.clientId:myclientid",
"security.oauth2.client.clientSecret:mysecret");
"security.oauth2.client.clientSecret:mysecret",
"security.oauth2.client.autoApproveScopes:read,write",
"security.oauth2.client.accessTokenValiditySeconds:40",
"security.oauth2.client.refreshTokenValiditySeconds:80"
);
this.context.register(AuthorizationAndResourceServerConfiguration.class,
MinimalSecureWebApplication.class);
this.context.refresh();
ClientDetails config = this.context.getBean(ClientDetails.class);
assertThat(config.getClientId(), equalTo("myclientid"));
assertThat(config.getClientSecret(), equalTo("mysecret"));
assertThat(config.isAutoApprove("read"), equalTo(true));
assertThat(config.isAutoApprove("write"), equalTo(true));
assertThat(config.isAutoApprove("foo"), equalTo(false));
assertThat(config.getAccessTokenValiditySeconds(), equalTo(40));
assertThat(config.getRefreshTokenValiditySeconds(), equalTo(80));
verifyAuthentication(config);
}

Loading…
Cancel
Save