OAuth2 ClientRegistrations NPE fix when userinfo missing
Fixes gh-8187
This commit is contained in:
parent
cb7786bf97
commit
a9a9c2c0fd
|
@ -146,9 +146,12 @@ public final class ClientRegistrations {
|
|||
RequestEntity<Void> request = RequestEntity.get(uri).build();
|
||||
Map<String, Object> configuration = rest.exchange(request, typeReference).getBody();
|
||||
OIDCProviderMetadata metadata = parse(configuration, OIDCProviderMetadata::parse);
|
||||
return withProviderConfiguration(metadata, issuer.toASCIIString())
|
||||
.jwkSetUri(metadata.getJWKSetURI().toASCIIString())
|
||||
.userInfoUri(metadata.getUserInfoEndpointURI().toASCIIString());
|
||||
ClientRegistration.Builder builder = withProviderConfiguration(metadata, issuer.toASCIIString())
|
||||
.jwkSetUri(metadata.getJWKSetURI().toASCIIString());
|
||||
if (metadata.getUserInfoEndpointURI() != null) {
|
||||
builder.userInfoUri(metadata.getUserInfoEndpointURI().toASCIIString());
|
||||
}
|
||||
return builder;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -195,6 +195,14 @@ public class ClientRegistrationsTest {
|
|||
assertThat(provider.getJwkSetUri()).isNull();
|
||||
}
|
||||
|
||||
// gh-8187
|
||||
@Test
|
||||
public void issuerWhenResponseMissingUserInfoUriThenSuccess() throws Exception {
|
||||
this.response.remove("userinfo_endpoint");
|
||||
ClientRegistration registration = registration("").build();
|
||||
assertThat(registration.getProviderDetails().getUserInfoEndpoint().getUri()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void issuerWhenContainsTrailingSlashThenSuccess() throws Exception {
|
||||
assertThat(registration("")).isNotNull();
|
||||
|
|
Loading…
Reference in New Issue