Skip to content

Lg 15251 avoid linking email address#11717

Merged
mdiarra3 merged 33 commits intomainfrom
LG-15251-avoid-linking-email-address
Jan 30, 2025
Merged

Lg 15251 avoid linking email address#11717
mdiarra3 merged 33 commits intomainfrom
LG-15251-avoid-linking-email-address

Conversation

@mdiarra3
Copy link
Copy Markdown
Contributor

@mdiarra3 mdiarra3 commented Jan 8, 2025

🎫 Ticket

Link to the relevant ticket:
LG-15251

🛠 Summary of changes

This allows Service providers with both 'all_emails' and 'email' attribute bundle to receive the last email sued for sign in instead of the email selected by the user.

@mdiarra3 mdiarra3 marked this pull request as ready for review January 8, 2025 18:17
Copy link
Copy Markdown
Contributor

@kevinsmaster5 kevinsmaster5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍
Tried it out locally and behaved as described in AC

@mdiarra3 mdiarra3 requested a review from aduth January 17, 2025 20:48
@@ -94,7 +94,9 @@ def email_address_id
return user_session[:selected_email_id_for_linked_identity]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still seeing ways that email_address_id is going to be assigned regardless of what attributes are requested by the service provider. This session value is assigned when the user grants consent, and will be returned here before we get a chance to evaluate sp_only_single_email_requested?.

if user_session[:selected_email_id_for_linked_identity].nil?
user_session[:selected_email_id_for_linked_identity] = current_user
.last_sign_in_email_address.id
end

I think we should do an audit of User#last_sign_in_email_address and Identity#email_address_for_sharing to make sure that they won't be used to assign email_address_id of an Identity unless valid for the requested / verified attributes.

It could also be a good idea to have an integration test that has the user walk through a consent flow for different requested attributes and check the resulting behavior / email_address_id value.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the test. above. But looking at the calls it looks like this location is the only place that the identity linker is being updated with email address id. the authorization controller and saml_auth_concern. @aduth

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok in that case I think it makes sense the change to change order to ensure we abort as early as possible in this method if the identity doesn't have the correct requested_attributes. 👍

Copy link
Copy Markdown
Contributor

@aduth aduth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 👍

end

def last_email
def last_email_id
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice clarifying rename 👍

@mdiarra3 mdiarra3 merged commit f19e387 into main Jan 30, 2025
@mdiarra3 mdiarra3 deleted the LG-15251-avoid-linking-email-address branch January 30, 2025 19:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants