Skip to content
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

LG-15166: Store doc auth vendor in Idv::Session #11742

Merged
merged 7 commits into from
Jan 17, 2025
Merged

Conversation

lmgeorge
Copy link
Contributor

@lmgeorge lmgeorge commented Jan 13, 2025

🎫 Ticket

Link to the relevant ticket:
LG-15166

🛠 Summary of changes

Why

  • Currently, we compute the vendor for remote document verification
      using DocAuthRouter, which requires downstream business logic to
      depend on context that may or may not be available. In order to
      eliminate calls to DocAuthRouter in places like Idv::ProofingComponents,
      we first need to start storing the vendor directly in Idv::Session.

How

  • Add a new key doc_auth_vendor to Idv::Session.
  • Set the new key after successful document capture. If the user opted
      for in person proofing, it will be usps (managed directly in Idv::InPerson::StateIdController), otherwise we use the
      existing Idv::DocAuthVendorConcern#doc_auth_vendor method.
  • Clear Idv::Session#doc_auth_vendor if the following steps are undone: link_sent,
      document_capture, and socure_document_capture, and ipp_state_id.

Additional notes

The doc_auth_vendor key is only being written to and not read in this PR. (LG-15168: Update ProofingComponents to only require Idv::Session will add code that reads this key from the session.

@lmgeorge lmgeorge requested review from n1zyy and a team January 13, 2025 22:00
@lmgeorge lmgeorge marked this pull request as ready for review January 13, 2025 23:08
@@ -355,6 +355,7 @@
end

it 'returns FOUND (302) and redirects to SSN' do
expect(subject.idv_session.doc_auth_vendor).to_not be_nil
Copy link
Member

Choose a reason for hiding this comment

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

Can you add similar checks to idv/document_capture_controller_spec.rb and idv/link_sent_controller_spec.rb?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmmm, I didn't include this check in the other specs since I thought the behavior was sufficiently covered in spec/policies/idv/flow_policy_spec.rb. Thoughts?

Copy link
Member

Choose a reason for hiding this comment

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

I think the flow policy spec updates do a good job of verifying that other steps don't mess with this value inappropriately. But I think what we want to test here is "after the user does the thing that we expect will set doc_auth_vendor, it is actually set".

extract_pii_from_doc is in the DocumentCaptureConcern, so you could add a test for that method, but I think that it makes sense to add a small assertion to each of the three paths (doc capture, link sent, and verify info for IPP) that the doc auth vendor is set as expected.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it, should be fairly straightforward to add those checks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added!

@@ -39,6 +39,7 @@ def error_hash(message)
def extract_pii_from_doc(user, store_in_session: false)
if defined?(idv_session) # hybrid mobile does not have idv_session
Copy link
Member

Choose a reason for hiding this comment

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

I definitely forgot about the hybrid flow, but I think this will work, since LinkSentController includes DocumentCaptureConcern and calls extract_pii_from_doc. However, I think we should have spec coverage for that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. Working on that now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added! (diff)

@@ -20,7 +21,7 @@ module Idv
# @attr phone_for_mobile_flow [String, nil]
# @attr previous_phone_step_params [Array]
# @attr previous_ssn [String, nil]
# @attr profile_id [String, nil]
# @attr profile_id [Integer, nil]
Copy link
Member

Choose a reason for hiding this comment

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

👍

@@ -76,6 +77,7 @@ class Session
skip_doc_auth_from_how_to_verify
skip_hybrid_handoff
socure_docv_wait_polling_started_at
source_check_vendor
Copy link
Member

Choose a reason for hiding this comment

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

HELLO FELLOW ALPHABETIZER

@@ -58,6 +59,14 @@ def selfie_requirement_met?
stored_result.selfie_check_performed?
end

def resolve_doc_auth_vendor(user)
if user.establishing_in_person_enrollment || user.pending_in_person_enrollment
Idp::Constants::Vendors::USPS
Copy link
Member

Choose a reason for hiding this comment

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

I think there are some edge cases that this will get mixed up on:

  1. User starts IPP, backs out, and goes down the remote doc auth path
  2. User starts IPP, abandons, then starts a new verification, selecting remote this time

In this case, we know the user has not chosen IPP for doc auth, so I don't think we should write it here. We likely want to set this to 'usps' somewhere else later on--perhaps on submission of the "Verify your info" screen?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a good point and I hadn't thought about that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Instead of doing this, converted to updating in Idv::InPerson::StateIdController#update. (Figuring this out was a bit of pain since it's a "hidden" step.)

@lmgeorge lmgeorge requested a review from a team January 15, 2025 17:22
Adds a new key, `doc_auth_vendor`, to Idv::Session.

This is part 1 to eliminate issues with 50/50 state handling.

[skip changelog]
**Why**
* Currently, we compute the vendor for remote document verification
  using DocAuthRouter, which requires downstream business logic to
  depend on context that may or may not be available. In order to
  eliminate calls to DocAuthRouter in places like Idv::ProofingComponents,
  we first need to start storing the vendor directly in Idv::Session.

**How**

* Add a new key `doc_auth_vendor` to Idv::Session.
* Set the new key after successful document capture. If the user opted
  for in person proofing, it will be `usps`, otherwise we use the
  existing `Idv::DocumentCaptureConcern#doc_auth_vendor` method.
* Clear `doc_auth_vendor` if the following steps are undone: link_sent,
  document_capture, and socure_document_capture.

changelog: Internal, IdV flow, Simplify creation of Idv::ProofingComponents
Copy link
Member

@n1zyy n1zyy left a comment

Choose a reason for hiding this comment

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

I don't think I have all of the historical context here that other reviewers do, so I wouldn't mind making sure they are onboard first, but having reviewed this it looks good to me. One small question where I think I'm just missing context.

@@ -81,7 +81,7 @@ def extra_attributes
liveness_checking_required: @biometric_comparison_required,
issue_year: state_id_issued&.year,
doc_auth_success: successful_result?,
vendor: 'Socure',
vendor: 'Socure', # TODO: Replace with Idp::Constants::Vendors::SOCURE
Copy link
Member

Choose a reason for hiding this comment

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

Can we not do this today due to the case difference?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah. If there are any queries that match on the case exactly then they would break. I'll write a ticket to follow up on this.

@@ -188,13 +193,7 @@

context 'socure is the default vendor but facial match is required' do
let(:idv_vendor) { Idp::Constants::Vendors::SOCURE }
let(:vot) { 'Pb' }
Copy link
Member

Choose a reason for hiding this comment

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

Off-topic, but I read this as the chemical substance for Lead 100% of the time, so good riddance to it.

@lmgeorge lmgeorge merged commit e149549 into main Jan 17, 2025
2 checks passed
@lmgeorge lmgeorge deleted the lmgeorge/LG-15166 branch January 17, 2025 17:29
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