diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/authserver/OAuth2AuthorizationServerConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/authserver/OAuth2AuthorizationServerConfiguration.java index f2038ea95c..848864341b 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/authserver/OAuth2AuthorizationServerConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/authserver/OAuth2AuthorizationServerConfiguration.java @@ -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])); diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/OAuth2AutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/OAuth2AutoConfigurationTests.java index f1a671cff1..5b70be1020 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/OAuth2AutoConfigurationTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/OAuth2AutoConfigurationTests.java @@ -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); }