Skip to content

OAuth2 ClientRegistrations NPE when UserInfo endpoint missing #8187

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
martinnemec3 opened this issue Mar 25, 2020 · 1 comment
Closed

OAuth2 ClientRegistrations NPE when UserInfo endpoint missing #8187

martinnemec3 opened this issue Mar 25, 2020 · 1 comment
Assignees
Labels
in: oauth2 An issue in OAuth2 modules (oauth2-core, oauth2-client, oauth2-resource-server, oauth2-jose) status: backported An issue that has been backported to maintenance branches type: bug A general bug
Milestone

Comments

@martinnemec3
Copy link

martinnemec3 commented Mar 25, 2020

Summary

When using spring-security-oauth2-client to authenticate via an OIDC provider and using OIDC discovery protocol to autoconfigure client registrations there can happen a NPE during the application startup if the userinfo_endpoint is not present in the OIDC configuration response.

Actual Behavior

Doing a call of ClientRegistrations.fromIssuerLocation(String) with an URI of OIDC provider that misses 'userinfo_endpoint' property in it's openid-configuration json causes the NPE on the following line (according to a stack trace from a Spring Boot app):

https://github.com/spring-projects/spring-security/blob/5.2.2.RELEASE/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/registration/ClientRegistrations.java#L151

The reason is that metadata.getUserInfoEndpointURI() returns null.

Expected Behavior

The ClientRegistrationBuilder is successfully returned from the fromIssuerLocation method.

Version

  • affected versions seem to be 5.2.2 and 5.3.0
  • there is no such issue in version 5.2.1
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Mar 25, 2020
@jgrandja
Copy link
Contributor

Thank you for reporting this @martinnemec3. This is indeed a bug. Would you be interested in submitting a PR for this fix?

@jgrandja jgrandja added in: oauth2 An issue in OAuth2 modules (oauth2-core, oauth2-client, oauth2-resource-server, oauth2-jose) status: ideal-for-contribution An issue that we actively are looking for someone to help us with type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Mar 26, 2020
@jgrandja jgrandja added this to the 5.4.0.M1 milestone Mar 26, 2020
martinnemec3 pushed a commit to martinnemec3/spring-security that referenced this issue Mar 26, 2020
@jgrandja jgrandja removed the status: ideal-for-contribution An issue that we actively are looking for someone to help us with label Mar 27, 2020
@jgrandja jgrandja changed the title OAuth2 Client Autoconfiguration NPE when UserInfo endpoint missing OAuth2 ClientRegistrations NPE when UserInfo endpoint missing Mar 27, 2020
@spring-projects-issues spring-projects-issues added status: backported An issue that has been backported to maintenance branches and removed for: backport-to-5.3.x labels Mar 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: oauth2 An issue in OAuth2 modules (oauth2-core, oauth2-client, oauth2-resource-server, oauth2-jose) status: backported An issue that has been backported to maintenance branches type: bug A general bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants