parent
7720e275e4
commit
e49d4a79b4
@ -52,10 +52,8 @@ public class PublicClientAuthenticationConverter implements AuthenticationConver
|
|||||||
|
|
||||||
// client_id (REQUIRED for public clients)
|
// client_id (REQUIRED for public clients)
|
||||||
String clientId = parameters.getFirst(OAuth2ParameterNames.CLIENT_ID);
|
String clientId = parameters.getFirst(OAuth2ParameterNames.CLIENT_ID);
|
||||||
if (!StringUtils.hasText(clientId)) {
|
if (!StringUtils.hasText(clientId) ||
|
||||||
return null;
|
parameters.get(OAuth2ParameterNames.CLIENT_ID).size() != 1) {
|
||||||
}
|
|
||||||
if (parameters.get(OAuth2ParameterNames.CLIENT_ID).size() != 1) {
|
|
||||||
throw new OAuth2AuthenticationException(new OAuth2Error(OAuth2ErrorCodes.INVALID_REQUEST));
|
throw new OAuth2AuthenticationException(new OAuth2Error(OAuth2ErrorCodes.INVALID_REQUEST));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,11 +45,14 @@ public class PublicClientAuthenticationConverterTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void convertWhenMissingClientIdThenReturnNull() {
|
public void convertWhenMissingClientIdThenInvalidRequestError() {
|
||||||
MockHttpServletRequest request = createPkceTokenRequest();
|
MockHttpServletRequest request = createPkceTokenRequest();
|
||||||
request.removeParameter(OAuth2ParameterNames.CLIENT_ID);
|
request.removeParameter(OAuth2ParameterNames.CLIENT_ID);
|
||||||
Authentication authentication = this.converter.convert(request);
|
assertThatThrownBy(() -> this.converter.convert(request))
|
||||||
assertThat(authentication).isNull();
|
.isInstanceOf(OAuth2AuthenticationException.class)
|
||||||
|
.extracting(ex -> ((OAuth2AuthenticationException) ex).getError())
|
||||||
|
.extracting("errorCode")
|
||||||
|
.isEqualTo(OAuth2ErrorCodes.INVALID_REQUEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Loading…
Reference in New Issue
Block a user