From 6be43077124c5bc27125ae4be397d625b7e0a6c5 Mon Sep 17 00:00:00 2001 From: artsiom Date: Tue, 21 Aug 2018 12:24:41 +0300 Subject: [PATCH 1/2] OAuth2 client secret property should not be required --- .../security/oauth2/client/OAuth2ClientProperties.java | 4 +--- .../security/oauth2/client/OAuth2ClientPropertiesTests.java | 5 ++--- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/client/OAuth2ClientProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/client/OAuth2ClientProperties.java index f238643fd0..6db2153424 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/client/OAuth2ClientProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/client/OAuth2ClientProperties.java @@ -30,6 +30,7 @@ import org.springframework.util.StringUtils; * * @author Madhura Bhave * @author Phillip Webb + * @author Artsiom Yudovin */ @ConfigurationProperties(prefix = "spring.security.oauth2.client") public class OAuth2ClientProperties { @@ -61,9 +62,6 @@ public class OAuth2ClientProperties { if (!StringUtils.hasText(registration.getClientId())) { throw new IllegalStateException("Client id must not be empty."); } - if (!StringUtils.hasText(registration.getClientSecret())) { - throw new IllegalStateException("Client secret must not be empty."); - } } /** diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/client/OAuth2ClientPropertiesTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/client/OAuth2ClientPropertiesTests.java index cfd146c093..ff6cc6f836 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/client/OAuth2ClientPropertiesTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/client/OAuth2ClientPropertiesTests.java @@ -24,6 +24,7 @@ import org.junit.rules.ExpectedException; * Tests for {@link OAuth2ClientProperties}. * * @author Madhura Bhave + * @author Artsiom Yudovin */ public class OAuth2ClientPropertiesTests { @@ -44,13 +45,11 @@ public class OAuth2ClientPropertiesTests { } @Test - public void clientSecretAbsentThrowsException() { + public void clientSecretAbsentNotThrowsException() { OAuth2ClientProperties.Registration registration = new OAuth2ClientProperties.Registration(); registration.setClientId("foo"); registration.setProvider("google"); this.properties.getRegistration().put("foo", registration); - this.thrown.expect(IllegalStateException.class); - this.thrown.expectMessage("Client secret must not be empty."); this.properties.validate(); } From d07e2fa0b25d9c72f5fe440b73f39e3b6131a79d Mon Sep 17 00:00:00 2001 From: Madhura Bhave Date: Fri, 24 Aug 2018 12:23:41 -0700 Subject: [PATCH 2/2] Polish "OAuth2 client secret should not be required" Closes gh-14156 --- .../security/oauth2/client/OAuth2ClientPropertiesTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/client/OAuth2ClientPropertiesTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/client/OAuth2ClientPropertiesTests.java index ff6cc6f836..75960d497f 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/client/OAuth2ClientPropertiesTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/client/OAuth2ClientPropertiesTests.java @@ -45,7 +45,7 @@ public class OAuth2ClientPropertiesTests { } @Test - public void clientSecretAbsentNotThrowsException() { + public void clientSecretAbsentShouldNotThrowException() { OAuth2ClientProperties.Registration registration = new OAuth2ClientProperties.Registration(); registration.setClientId("foo"); registration.setProvider("google");