Skip to content

Me/dpc 5484 flag primary csp email#3017

Open
MEspositoE14s wants to merge 11 commits into
mainfrom
me/dpc-5484-flag-primary-csp-email
Open

Me/dpc 5484 flag primary csp email#3017
MEspositoE14s wants to merge 11 commits into
mainfrom
me/dpc-5484-flag-primary-csp-email

Conversation

@MEspositoE14s
Copy link
Copy Markdown
Contributor

🎫 Ticket

https://jira.cms.gov/browse/DPC-5484

🛠 Changes

  • Adds a "primary" column to the user_emails table.
  • Successful login sets the primary flag based on the users most recent primary email as verified by their CSP.

ℹ️ Context

Eventually, if a user logs in with a new CSP we want to be able to tell them that they previously signed up under a previous CSP along with the email attached to it. To do this, we need to know what their primary, verified email is with each CSP.

🧪 Validation

  • Deployed to dev here.
  • Ran locally, logged in and verified primary column was populated correctly.

@MEspositoE14s MEspositoE14s requested a review from a team as a code owner May 28, 2026 14:15
def post_signin_actions(user, csp_user, auth)
ial_2_actions(user, auth)
update_email(csp_user, auth.extra.raw_info.all_emails)
update_email(csp_user, auth.extra.raw_info.all_emails, auth.info.email)
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.

This will probably have to be different for each CSP. Login.gov just happens to send the primary email in auth.info.email.

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.

could you make this a method so it can be easily changed by controller? like

def user_email(auth)
    auth.info.email
end

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.

No problem! This is probably the more "Railsy" way of doing it.

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.

🙌

Jose-verdance
Jose-verdance previously approved these changes May 29, 2026
Copy link
Copy Markdown
Contributor

@Jose-verdance Jose-verdance left a comment

Choose a reason for hiding this comment

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

LGTM!

@MEspositoE14s MEspositoE14s requested a review from a team May 29, 2026 17:02
ashley-weaver
ashley-weaver previously approved these changes Jun 1, 2026
Copy link
Copy Markdown
Contributor

@ashley-weaver ashley-weaver left a comment

Choose a reason for hiding this comment

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

👍

@MEspositoE14s MEspositoE14s requested review from a team, Jose-verdance and ashley-weaver June 1, 2026 15:51
@@ -0,0 +1,11 @@
class AddPrimaryToUserEmails < ActiveRecord::Migration[8.0]
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.

nitpicky, but do you want to change this column to 'verified' too?

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.

Maybe nitpicky, but still a good idea.

@manojwadhwa81
Copy link
Copy Markdown

I see some confusion around the usage of primary vs verified terms for an email. Here is a quick summary of the differences:
a) For all assurance levels, CSPs will only be returning verified emails.
b) Of all the verified emails, one will be marked a primary. So a primary email is always a verified email and a verified email may or may not be primary
c) In order to make the distinction, the primary email is returned in the email claim and all emails are returned in 'emails_confirmed' or 'all_emails' claims in user_info endpoint.
d) The reason we see variation in the naming of the key used for confirmed emails is because this isn't standardized in OIDC specs, so it's left to the provider. However email and email_verified are standard OIDC claims, with the later being a boolean field.
e) The definition of Primary for an email for a CSP is again dependent on CSP. For id.me, it would be just a flag set by the user to mark an email of all the verified emails as primary. For others, it could be the id used to log into CSP's portal.

For all purposes, DPC will borrow the primary flag and utilize it to provide it a hint to the user to use the right CSP and email.

@MEspositoE14s
Copy link
Copy Markdown
Contributor Author

I see some confusion around the usage of primary vs verified terms for an email. Here is a quick summary of the differences: a) For all assurance levels, CSPs will only be returning verified emails. b) Of all the verified emails, one will be marked a primary. So a primary email is always a verified email and a verified email may or may not be primary c) In order to make the distinction, the primary email is returned in the email claim and all emails are returned in 'emails_confirmed' or 'all_emails' claims in user_info endpoint. d) The reason we see variation in the naming of the key used for confirmed emails is because this isn't standardized in OIDC specs, so it's left to the provider. However email and email_verified are standard OIDC claims, with the later being a boolean field. e) The definition of Primary for an email for a CSP is again dependent on CSP. For id.me, it would be just a flag set by the user to mark an email of all the verified emails as primary. For others, it could be the id used to log into CSP's portal.

For all purposes, DPC will borrow the primary flag and utilize it to provide it a hint to the user to use the right CSP and email.

Ok 👍 , renaming verified back to primary.

Copy link
Copy Markdown
Contributor

@Jose-verdance Jose-verdance left a comment

Choose a reason for hiding this comment

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

LG!

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.

4 participants