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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

LG-12873: Annotate reCAPTCHA assessments with MFA results #10522

Merged
merged 12 commits into from May 7, 2024

Conversation

aduth
Copy link
Member

@aduth aduth commented Apr 29, 2024

馃帿 Ticket

LG-12873

馃洜 Summary of changes

Updates phone setup flow to annotate a reCAPTCHA assessment after the user initiates and completes phone setup.

Related resources:

馃摐 Testing Plan

Verify that you see events for annotating an assessment upon initiating and completing phone setup:

  1. Have make run and make watch_events running in parallel in two separate terminal processes
  2. Visit http://localhost:3000
  3. Sign in or create an account
  4. When possible, add a phone to your account (clicking "Add phone number" at the account dashboard if signing in, or choosing "Text or voice message" at the MFA selection screen during account creation)
  5. Enter an international phone number, e.g. +610491570006
  6. Click "Send code"
  7. Observe an event recaptcha_assessment_annotated that the Telephony: OTP sent event includes an recaptcha_annotation with non-null assessment_id and a reason of 'INITIATED_TWO_FACTOR'
  8. Click "Submit" to submit the one-time code
  9. Observe an event recaptcha_assessment_annotated that the Multi-factor authentication: Phone added event includes an recaptcha_annotation with non-null assessment_id, a reason of 'PASSED_TWO_FACTOR', and a annotation of 'LEGITIMATE'

changelog: Internal, Spam Mitigation, Annotate reCAPTCHA assessments with MFA results
@aduth aduth force-pushed the aduth-lg-12873-recaptcha-annotate branch from 72aa333 to 2caded9 Compare May 3, 2024 12:40
@aduth aduth marked this pull request as ready for review May 3, 2024 17:20
@aduth aduth requested a review from a team May 3, 2024 17:20
@aduth
Copy link
Member Author

aduth commented May 3, 2024

This is ready for review now. I've also tested this against real reCAPTCHA Enterprise which revealed some necessary changes in c0ef243, but worked successfully afterward. Let me know if you'd like to test the real Enterprise and I can get you set up with it.

Comment on lines 4640 to 4641
# @param [String] reason Reason for annotating the assessment
# @param [String] annotation Type of annotation
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# @param [String] reason Reason for annotating the assessment
# @param [String] annotation Type of annotation
# @param ["INITIATED_TWO_FACTOR","PASSED_TWO_FACTOR"] reason Reason for annotating the assessment
# @param ["LEGITIMATE","FRAUDULENT"] annotation Type of annotation

Copy link
Member Author

Choose a reason for hiding this comment

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

I've only implemented a handful we're currently using, but technically there could be as many as 15 reasons and 5 annotations, unsure how scalable that is to repeat them out here? Would be nice if we could somehow reference an external type similar to what can be done with exporting / importing types in TypeScript.

Maybe I'll just add the specific strings and we can sort out later if/when we add more.

Copy link
Member Author

Choose a reason for hiding this comment

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

Indirectly addressed through dcc31d1, though maybe Hash could be a more specific type in the YARDoc with how it's embedded in existing events.

Copy link
Contributor

Choose a reason for hiding this comment

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

now this event is not logged at all (or referenced by the other events), should we remove it?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep, we should. Good catch..

app/services/recaptcha_annotator.rb Outdated Show resolved Hide resolved
Comment on lines +91 to +95
otp_delivery_preference: otp_delivery_method(
nil,
@new_phone_form.phone,
@new_phone_form.otp_delivery_preference,
),
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe it's time to refactor otp_delivery_method? It's only used in this file, and the first argument is completely dropped anyways? Seems like a good use case for keyword args too IMO

Could also be a good follow-up option

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah I did a light refactoring here since this method prompt_to_confirm_phone was strangely parameterized despite being unnecessary to do so, making it difficult to extend. Maybe this method and otp_delivery_method were reused previously, when there were separate controllers between account creation vs. dashboard phone creation.

There's a lot of this phone stuff I'd like to refactor (especially phone-specific stuff in TwoFactorAuthenticationController), so probably save for a follow-up.

See: #10522 (comment)

Co-authored-by: Zach Margolis <zachary.margolis@gsa.gov>
@aduth aduth marked this pull request as draft May 6, 2024 13:02
@aduth aduth marked this pull request as ready for review May 6, 2024 13:24
@aduth aduth requested a review from zachmargolis May 6, 2024 13:24
aduth added 2 commits May 6, 2024 13:04
As of dcc31d1, annotation details are now embedded in related event as property hash
@aduth aduth merged commit c2847c7 into main May 7, 2024
2 checks passed
@aduth aduth deleted the aduth-lg-12873-recaptcha-annotate branch May 7, 2024 13:15
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.

None yet

3 participants