diff --git a/app/controllers/two_factor_authentication/backup_code_verification_controller.rb b/app/controllers/two_factor_authentication/backup_code_verification_controller.rb index 94bcbd38a26..883b4ef474d 100644 --- a/app/controllers/two_factor_authentication/backup_code_verification_controller.rb +++ b/app/controllers/two_factor_authentication/backup_code_verification_controller.rb @@ -20,7 +20,7 @@ def create @backup_code_form = BackupCodeVerificationForm.new(current_user) result = @backup_code_form.submit(backup_code_params) analytics.track_mfa_submit_event(result.to_h) - irs_attempts_api_tracker.mfa_verify_backup_code(success: result.success?) + irs_attempts_api_tracker.mfa_login_backup_code(success: result.success?) handle_result(result) end diff --git a/app/controllers/two_factor_authentication/otp_verification_controller.rb b/app/controllers/two_factor_authentication/otp_verification_controller.rb index 23949c74778..d794b94ef13 100644 --- a/app/controllers/two_factor_authentication/otp_verification_controller.rb +++ b/app/controllers/two_factor_authentication/otp_verification_controller.rb @@ -86,12 +86,12 @@ def post_analytics(result) analytics.track_mfa_submit_event(properties) if UserSessionContext.authentication_context?(context) - irs_attempts_api_tracker.mfa_verify_phone_otp_submitted( + irs_attempts_api_tracker.mfa_login_phone_otp_submitted( reauthentication: false, success: properties[:success], ) elsif UserSessionContext.reauthentication_context?(context) - irs_attempts_api_tracker.mfa_verify_phone_otp_submitted( + irs_attempts_api_tracker.mfa_login_phone_otp_submitted( reauthentication: true, success: properties[:success], ) diff --git a/app/controllers/two_factor_authentication/totp_verification_controller.rb b/app/controllers/two_factor_authentication/totp_verification_controller.rb index a0c65f755ab..4b2dae910d3 100644 --- a/app/controllers/two_factor_authentication/totp_verification_controller.rb +++ b/app/controllers/two_factor_authentication/totp_verification_controller.rb @@ -19,7 +19,7 @@ def create result = TotpVerificationForm.new(current_user, params.require(:code).strip).submit analytics.track_mfa_submit_event(result.to_h) - irs_attempts_api_tracker.mfa_verify_totp(success: result.success?) + irs_attempts_api_tracker.mfa_login_totp(success: result.success?) if result.success? handle_valid_otp diff --git a/app/controllers/two_factor_authentication/webauthn_verification_controller.rb b/app/controllers/two_factor_authentication/webauthn_verification_controller.rb index 35997a12907..7b0116743b3 100644 --- a/app/controllers/two_factor_authentication/webauthn_verification_controller.rb +++ b/app/controllers/two_factor_authentication/webauthn_verification_controller.rb @@ -19,9 +19,9 @@ def confirm ) if analytics_properties[:multi_factor_auth_method] == 'webauthn_platform' - irs_attempts_api_tracker.mfa_verify_webauthn_platform(success: result.success?) + irs_attempts_api_tracker.mfa_login_webauthn_platform(success: result.success?) elsif analytics_properties[:multi_factor_auth_method] == 'webauthn' - irs_attempts_api_tracker.mfa_verify_webauthn_roaming(success: result.success?) + irs_attempts_api_tracker.mfa_login_webauthn_roaming(success: result.success?) end handle_webauthn_result(result) diff --git a/app/controllers/users/two_factor_authentication_controller.rb b/app/controllers/users/two_factor_authentication_controller.rb index 352be381081..590be94cd19 100644 --- a/app/controllers/users/two_factor_authentication_controller.rb +++ b/app/controllers/users/two_factor_authentication_controller.rb @@ -212,13 +212,13 @@ def track_events(otp_delivery_preference:) ) if UserSessionContext.authentication_context?(context) - irs_attempts_api_tracker.mfa_verify_phone_otp_sent( + irs_attempts_api_tracker.mfa_login_phone_otp_sent( reauthentication: false, phone_number: parsed_phone.e164, success: @telephony_result.success?, ) elsif UserSessionContext.reauthentication_context?(context) - irs_attempts_api_tracker.mfa_verify_phone_otp_sent( + irs_attempts_api_tracker.mfa_login_phone_otp_sent( reauthentication: true, phone_number: parsed_phone.e164, success: @telephony_result.success?, diff --git a/app/services/irs_attempts_api/tracker_events.rb b/app/services/irs_attempts_api/tracker_events.rb index dce54d675bb..61180291ee4 100644 --- a/app/services/irs_attempts_api/tracker_events.rb +++ b/app/services/irs_attempts_api/tracker_events.rb @@ -98,11 +98,11 @@ def mfa_enroll_webauthn_roaming(success:) ) end - # Tracks when the user has attempted to verify the Backup Codes MFA method to their account + # Tracks when the user has attempted to log in with the Backup Codes MFA method to their account # @param [Boolean] success - def mfa_verify_backup_code(success:) + def mfa_login_backup_code(success:) track_event( - :mfa_verify_backup_code, + :mfa_login_backup_code, success: success, ) end @@ -111,9 +111,9 @@ def mfa_verify_backup_code(success:) # @param [String] phone_number - The user's phone_number used for multi-factor authentication # @param [Boolean] success - True if the OTP Verification was sent # During a login attempt, an OTP code has been sent via SMS. - def mfa_verify_phone_otp_sent(reauthentication:, phone_number:, success:) + def mfa_login_phone_otp_sent(reauthentication:, phone_number:, success:) track_event( - :mfa_verify_phone_otp_sent, + :mfa_login_phone_otp_sent, reauthentication: reauthentication, phone_number: phone_number, success: success, @@ -123,37 +123,37 @@ def mfa_verify_phone_otp_sent(reauthentication:, phone_number:, success:) # @param [Boolean] success - True if the sms otp submitted matched what was sent # During a login attempt, the user, having previously been sent an OTP code via SMS # has entered an OTP code. - def mfa_verify_phone_otp_submitted(reauthentication:, success:) + def mfa_login_phone_otp_submitted(reauthentication:, success:) track_event( - :mfa_verify_phone_otp_submitted, + :mfa_login_phone_otp_submitted, reauthentication: reauthentication, success: success, ) end - # Tracks when the user has attempted to verify via the TOTP MFA method to access their account + # Tracks when the user has attempted to log in with the TOTP MFA method to access their account # @param [Boolean] success - def mfa_verify_totp(success:) + def mfa_login_totp(success:) track_event( - :mfa_verify_totp, + :mfa_login_totp, success: success, ) end - # Tracks when user has attempted to verify via the WebAuthn-Platform MFA method to their account + # Tracks when user has attempted to log in with WebAuthn-Platform MFA method to their account # @param [Boolean] success - def mfa_verify_webauthn_platform(success:) + def mfa_login_webauthn_platform(success:) track_event( - :mfa_verify_webauthn_platform, + :mfa_login_webauthn_platform, success: success, ) end - # Tracks when the user has attempted to verify via the WebAuthn MFA method to their account + # Tracks when the user has attempted to log in with the WebAuthn MFA method to their account # @param [Boolean] success - def mfa_verify_webauthn_roaming(success:) + def mfa_login_webauthn_roaming(success:) track_event( - :mfa_verify_webauthn_roaming, + :mfa_login_webauthn_roaming, success: success, ) end @@ -175,7 +175,7 @@ def mfa_enroll_piv_cac( ) end - # Tracks when the user has attempted to verify the piv cac MFA method to their account + # Tracks when the user has attempted to log in with the piv cac MFA method to their account # @param [String] subject_dn # @param [Boolean] success # @param [Hash>] failure_reason diff --git a/spec/controllers/two_factor_authentication/backup_code_verification_controller_spec.rb b/spec/controllers/two_factor_authentication/backup_code_verification_controller_spec.rb index 8054127baaf..bf0c728934d 100644 --- a/spec/controllers/two_factor_authentication/backup_code_verification_controller_spec.rb +++ b/spec/controllers/two_factor_authentication/backup_code_verification_controller_spec.rb @@ -38,7 +38,7 @@ with(analytics_hash) expect(@irs_attempts_api_tracker).to receive(:track_event). - with(:mfa_verify_backup_code, success: true) + with(:mfa_login_backup_code, success: true) post :create, params: payload end @@ -64,7 +64,7 @@ with(analytics_hash) expect(@irs_attempts_api_tracker).to receive(:track_event). - with(:mfa_verify_backup_code, success: true) + with(:mfa_login_backup_code, success: true) expect(@analytics).to receive(:track_event). with('User marked authenticated', authentication_type: :valid_2fa) @@ -91,7 +91,7 @@ it 'renders the show page' do stub_attempts_tracker expect(@irs_attempts_api_tracker).to receive(:track_event). - with(:mfa_verify_backup_code, success: false) + with(:mfa_login_backup_code, success: false) post :create, params: payload expect(response).to render_template(:show) expect(flash[:error]).to eq t('two_factor_authentication.invalid_backup_code') @@ -115,7 +115,7 @@ it 're-renders the backup code entry screen' do stub_attempts_tracker expect(@irs_attempts_api_tracker).to receive(:track_event). - with(:mfa_verify_backup_code, success: false) + with(:mfa_login_backup_code, success: false) post :create, params: payload expect(response).to render_template(:show) @@ -137,7 +137,7 @@ with(properties) expect(@irs_attempts_api_tracker).to receive(:track_event). - with(:mfa_verify_backup_code, success: false) + with(:mfa_login_backup_code, success: false) expect(@analytics).to receive(:track_event). with('Multi-Factor Authentication: max attempts reached') diff --git a/spec/controllers/two_factor_authentication/otp_verification_controller_spec.rb b/spec/controllers/two_factor_authentication/otp_verification_controller_spec.rb index 1d57c389222..a33a207b234 100644 --- a/spec/controllers/two_factor_authentication/otp_verification_controller_spec.rb +++ b/spec/controllers/two_factor_authentication/otp_verification_controller_spec.rb @@ -114,7 +114,7 @@ expect(@analytics).to receive(:track_mfa_submit_event). with(properties) - expect(@irs_attempts_api_tracker).to receive(:mfa_verify_phone_otp_submitted). + expect(@irs_attempts_api_tracker).to receive(:mfa_login_phone_otp_submitted). with({ reauthentication: false, success: false }) post :create, params: @@ -176,7 +176,7 @@ expect(PushNotification::HttpPush).to receive(:deliver). with(PushNotification::MfaLimitAccountLockedEvent.new(user: subject.current_user)) - expect(@irs_attempts_api_tracker).to receive(:mfa_verify_phone_otp_submitted). + expect(@irs_attempts_api_tracker).to receive(:mfa_login_phone_otp_submitted). with({ reauthentication: false, success: false }) post :create, params: @@ -234,7 +234,7 @@ expect(@analytics).to receive(:track_event). with('User marked authenticated', authentication_type: :valid_2fa) - expect(@irs_attempts_api_tracker).to receive(:mfa_verify_phone_otp_submitted). + expect(@irs_attempts_api_tracker).to receive(:mfa_login_phone_otp_submitted). with({ reauthentication: false, success: true }) post :create, params: { @@ -291,7 +291,7 @@ before do stub_attempts_tracker - expect(@irs_attempts_api_tracker).to receive(:mfa_verify_phone_otp_submitted). + expect(@irs_attempts_api_tracker).to receive(:mfa_login_phone_otp_submitted). with({ reauthentication: false, success: false }) post :create, params: { code: '12345', otp_delivery_preference: 'sms' } end @@ -309,7 +309,7 @@ before do stub_attempts_tracker - expect(@irs_attempts_api_tracker).to receive(:mfa_verify_phone_otp_submitted). + expect(@irs_attempts_api_tracker).to receive(:mfa_login_phone_otp_submitted). with({ reauthentication: false, success: true }) post :create, params: { code: subject.current_user.direct_otp, diff --git a/spec/controllers/two_factor_authentication/totp_verification_controller_spec.rb b/spec/controllers/two_factor_authentication/totp_verification_controller_spec.rb index 08f7ee46fdb..78d6a68b3e9 100644 --- a/spec/controllers/two_factor_authentication/totp_verification_controller_spec.rb +++ b/spec/controllers/two_factor_authentication/totp_verification_controller_spec.rb @@ -48,7 +48,7 @@ expect(@analytics).to receive(:track_event). with('User marked authenticated', authentication_type: :valid_2fa) expect(@irs_attempts_api_tracker).to receive(:track_event). - with(:mfa_verify_totp, success: true) + with(:mfa_login_totp, success: true) post :create, params: { code: generate_totp_code(@secret) } end @@ -96,7 +96,7 @@ expect(@analytics).to receive(:track_event). with('Multi-Factor Authentication: max attempts reached') expect(@irs_attempts_api_tracker).to receive(:track_event). - with(:mfa_verify_totp, success: false) + with(:mfa_login_totp, success: false) expect(PushNotification::HttpPush).to receive(:deliver). with(PushNotification::MfaLimitAccountLockedEvent.new(user: subject.current_user)) diff --git a/spec/controllers/two_factor_authentication/webauthn_verification_controller_spec.rb b/spec/controllers/two_factor_authentication/webauthn_verification_controller_spec.rb index 46dfd664b05..abf127d8994 100644 --- a/spec/controllers/two_factor_authentication/webauthn_verification_controller_spec.rb +++ b/spec/controllers/two_factor_authentication/webauthn_verification_controller_spec.rb @@ -83,7 +83,7 @@ with('User marked authenticated', authentication_type: :valid_2fa) expect(@irs_attempts_api_tracker).to receive(:track_event).with( - :mfa_verify_webauthn_roaming, + :mfa_login_webauthn_roaming, success: true, ) @@ -108,7 +108,7 @@ with('User marked authenticated', authentication_type: :valid_2fa) expect(@irs_attempts_api_tracker).to receive(:track_event).with( - :mfa_verify_webauthn_platform, + :mfa_login_webauthn_platform, success: true, ) diff --git a/spec/controllers/users/two_factor_authentication_controller_spec.rb b/spec/controllers/users/two_factor_authentication_controller_spec.rb index dfeac6aa2f3..c0f13c527eb 100644 --- a/spec/controllers/users/two_factor_authentication_controller_spec.rb +++ b/spec/controllers/users/two_factor_authentication_controller_spec.rb @@ -326,7 +326,7 @@ def index it 'tracks the verification attempt event' do stub_attempts_tracker - expect(@irs_attempts_api_tracker).to receive(:mfa_verify_phone_otp_sent). + expect(@irs_attempts_api_tracker).to receive(:mfa_login_phone_otp_sent). with(phone_number: '+12025551212', reauthentication: false, success: true) get :send_code, params: { otp_delivery_selection_form: diff --git a/spec/features/irs_attempts_api/event_tracking_spec.rb b/spec/features/irs_attempts_api/event_tracking_spec.rb index f867a3cc4d3..fa4354b2a87 100644 --- a/spec/features/irs_attempts_api/event_tracking_spec.rb +++ b/spec/features/irs_attempts_api/event_tracking_spec.rb @@ -31,7 +31,7 @@ sign_in_user(user) events = irs_attempts_api_tracked_events(timestamp: Time.zone.now) - expected_event_types = %w[email-and-password-auth mfa-verify-phone-otp-sent] + expected_event_types = %w[email-and-password-auth mfa-login-phone-otp-sent] received_event_types = events.map(&:event_type)