Skip to content

Commit 517b30a

Browse files
committed
Merge branch '1.5.x'
2 parents 8743148 + 8deb72b commit 517b30a

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/resource/ResourceServerProperties.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,9 @@ public void validate(Object target, Errors errors) {
207207
}
208208

209209
private void validate(ResourceServerProperties target, Errors errors) {
210+
if (!StringUtils.hasText(this.clientId)) {
211+
return;
212+
}
210213
boolean jwtConfigPresent = StringUtils.hasText(this.jwt.getKeyUri())
211214
|| StringUtils.hasText(this.jwt.getKeyValue());
212215
boolean jwkConfigPresent = StringUtils.hasText(this.jwk.getKeySetUri());
@@ -228,8 +231,7 @@ private void validate(ResourceServerProperties target, Errors errors) {
228231
+ "JWT verifier key");
229232
}
230233
if (StringUtils.hasText(target.getTokenInfoUri()) && isPreferTokenInfo()) {
231-
if (StringUtils.hasText(this.clientId)
232-
&& !StringUtils.hasText(this.clientSecret)) {
234+
if (!StringUtils.hasText(this.clientSecret)) {
233235
errors.rejectValue("clientSecret", "missing.clientSecret",
234236
"Missing client secret");
235237
}

spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/resource/ResourceServerPropertiesTests.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@ public void json() throws Exception {
5555
assertThat(jwt.get("keyUri")).isNotNull();
5656
}
5757

58+
@Test
59+
public void validateWhenClientIdNullShouldNotFail() throws Exception {
60+
this.properties = new ResourceServerProperties(null, "secret");
61+
setListableBeanFactory();
62+
this.properties.validate(this.properties, this.errors);
63+
verifyZeroInteractions(this.errors);
64+
}
65+
5866
@Test
5967
public void validateWhenBothJwtAndJwkKeyUrisPresentShouldFail() throws Exception {
6068
this.properties.getJwk().setKeySetUri("http://my-auth-server/token_keys");

0 commit comments

Comments
 (0)