uaa icon indicating copy to clipboard operation
uaa copied to clipboard

fix: generate email if it is the empty string on external login

Open mikeroda opened this issue 1 year ago • 2 comments

If the email is the empty string, treat it as null and generate one.

mikeroda avatar May 03 '24 12:05 mikeroda

We have created an issue in Pivotal Tracker to manage this:

https://www.pivotaltracker.com/story/show/187543759

The labels on this github issue will be updated when the story is started.

cf-gitbot avatar May 03 '24 12:05 cf-gitbot

Without the change, the test case will throw an exception:

java.lang.IllegalArgumentException: Email is required at org.springframework.util.Assert.hasText(Assert.java:289) at org.cloudfoundry.identity.uaa.user.UaaUser.(UaaUser.java:152)

Because UaaUser has Assert.hasText(prototype.getEmail(), "Email is required") which is inconsistent with the null check in ExternalLoginAuthenticationManager.

mikeroda avatar May 03 '24 13:05 mikeroda

Also, what is the issue in real life? When logging in with an external IDP, the email value we get from the IDP would be an empty string & the user will fail to log in due to "Email is required" error? Why would the IDP has an empty string as the email (instead of just not having it)? Is the real issue here the operator didn't set up the attributeMappings config correctly for UAA API?

peterhaochen47 avatar May 23 '24 00:05 peterhaochen47

Also, what is the issue in real life? When logging in with an external IDP, the email value we get from the IDP would be an empty string & the user will fail to log in due to "Email is required" error? Why would the IDP has an empty string as the email (instead of just not having it)? Is the real issue here the operator didn't set up the attributeMappings config correctly for UAA API?

The issue is that it's treated inconsistently. A null email will result in one being generated. An empty string will throw an exception that email is required. In reality an attributeMapping for email is not required, that why we can generate one. So we should be consistent about how we do that.

mikeroda avatar May 23 '24 20:05 mikeroda

Hi @mikeroda, approved, please merge.

peterhaochen47 avatar May 29 '24 17:05 peterhaochen47

Hi @mikeroda, approved, please merge.

I don't have merge rights.

mikeroda avatar May 29 '24 17:05 mikeroda