Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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],
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/users/two_factor_authentication_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?,
Expand Down
34 changes: 17 additions & 17 deletions app/services/irs_attempts_api/tracker_events.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 login with the Backup Codes MFA method to their account
Comment thread
ThatSpaceGuy marked this conversation as resolved.
Outdated
# @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
Expand All @@ -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,
Expand All @@ -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 login with the TOTP MFA method to access their account
Comment thread
ThatSpaceGuy marked this conversation as resolved.
Outdated
# @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 login with the WebAuthn-Platform MFA method to their account
Comment thread
ThatSpaceGuy marked this conversation as resolved.
Outdated
# @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 login with the WebAuthn MFA method to their account
Comment thread
ThatSpaceGuy marked this conversation as resolved.
Outdated
# @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
Expand All @@ -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 login with the piv cac MFA method to their account
Comment thread
ThatSpaceGuy marked this conversation as resolved.
Outdated
# @param [String] subject_dn
# @param [Boolean] success
# @param [Hash<Symbol,Array<Symbol>>] failure_reason
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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')
Expand All @@ -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)
Expand All @@ -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')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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: {
Expand Down Expand Up @@ -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
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)

Expand All @@ -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,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down