-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LG-14655: A/B test to recommend platform authenticator to SMS users (#…
…11402) * LG-14655: A/B test to recommend platform authenticator to SMS users changelog: Internal, Upcoming Features, Create A/B test to recommend platform authenticator to SMS users * Restore test case Mistakenly removed in rebase * Convert "should" to "expect" syntax * Update experiment name Standardize on "recommend" terminology, also broaden to cover account creation flow * Sort analytics methods * Check in multi-MFA setup flow for suggesting second MFA * Remove redundant, inaccurate test case * Add specs for RECOMMEND_WEBAUTHN_PLATFORM_FOR_SMS_USER AbTest * Split configuration for authentication vs. account creation
- Loading branch information
Showing
30 changed files
with
709 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
app/controllers/concerns/recommend_webauthn_platform_concern.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# frozen_string_literal: true | ||
|
||
module RecommendWebauthnPlatformConcern | ||
def recommend_webauthn_platform_for_sms_user?(bucket) | ||
# Only consider for A/B test if: | ||
# 1. Option would be offered for setup | ||
# 2. User is viewing content in English | ||
# 3. Other recommendations have not already been offered (e.g. PIV/CAC for federal emails) | ||
# 4. User selected to setup phone or authenticated with phone | ||
# 5. User has not already set up a platform authenticator | ||
return false if !device_supports_platform_authenticator_setup? | ||
return false if I18n.locale != :en | ||
return false if current_user.webauthn_platform_recommended_dismissed_at? | ||
return false if !user_set_up_or_authenticated_with_phone? | ||
return false if current_user.webauthn_configurations.platform_authenticators.present? | ||
ab_test_bucket(:RECOMMEND_WEBAUTHN_PLATFORM_FOR_SMS_USER) == bucket | ||
end | ||
|
||
private | ||
|
||
def device_supports_platform_authenticator_setup? | ||
user_session[:platform_authenticator_available] == true | ||
end | ||
|
||
def in_account_creation_flow? | ||
user_session[:in_account_creation_flow] == true | ||
end | ||
|
||
def user_set_up_or_authenticated_with_phone? | ||
if in_account_creation_flow? | ||
current_user.phone_configurations.any? do |phone_configuration| | ||
phone_configuration.mfa_enabled? && phone_configuration.delivery_preference == 'sms' | ||
end | ||
else | ||
auth_methods_session.auth_events.pluck(:auth_method). | ||
include?(TwoFactorAuthenticatable::AuthMethod::SMS) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
app/controllers/users/webauthn_platform_recommended_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# frozen_string_literal: true | ||
|
||
module Users | ||
class WebauthnPlatformRecommendedController < ApplicationController | ||
include SecureHeadersConcern | ||
include MfaSetupConcern | ||
|
||
before_action :confirm_two_factor_authenticated | ||
before_action :apply_secure_headers_override | ||
|
||
def new | ||
@sign_in_flow = session[:sign_in_flow] | ||
analytics.webauthn_platform_recommended_visited | ||
end | ||
|
||
def create | ||
analytics.webauthn_platform_recommended_submitted(opted_to_add: opted_to_add?) | ||
current_user.update(webauthn_platform_recommended_dismissed_at: Time.zone.now) | ||
redirect_to dismiss_redirect_path | ||
end | ||
|
||
private | ||
|
||
def opted_to_add? | ||
params[:add_method].present? | ||
end | ||
|
||
def dismiss_redirect_path | ||
if opted_to_add? | ||
webauthn_setup_path(platform: true) | ||
elsif in_account_creation_flow? | ||
next_setup_path | ||
else | ||
after_sign_in_path_for(current_user) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
app/views/users/webauthn_platform_recommended/new.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<% self.title = t('webauthn_platform_recommended.heading') %> | ||
|
||
<%= render StatusPageComponent.new(status: :info, icon: :question) do |c| %> | ||
<% c.with_header { t('webauthn_platform_recommended.heading') } %> | ||
|
||
<p><%= t('webauthn_platform_recommended.description_secure_account') %></p> | ||
|
||
<p> | ||
<%= t( | ||
'webauthn_platform_recommended.description_private_html', | ||
phishing_resistant_link_html: new_tab_link_to( | ||
t('webauthn_platform_recommended.phishing_resistant'), | ||
help_center_redirect_path( | ||
category: 'get-started', | ||
article: 'authentication-methods', | ||
anchor: 'face-or-touch-unlock', | ||
flow: @sign_in_flow, | ||
step: :webauthn_platform_recommended, | ||
), | ||
), | ||
) %> | ||
</p> | ||
|
||
<div class="grid-row margin-top-5"> | ||
<div class="tablet:grid-col-9"> | ||
<%= render ButtonComponent.new( | ||
url: webauthn_platform_recommended_url, | ||
method: :post, | ||
params: { add_method: true }, | ||
big: true, | ||
full_width: true, | ||
class: 'margin-bottom-2', | ||
).with_content(t('webauthn_platform_recommended.cta')) %> | ||
<%= render ButtonComponent.new( | ||
url: webauthn_platform_recommended_url, | ||
method: :post, | ||
unstyled: true, | ||
).with_content(t('webauthn_platform_recommended.skip')) %> | ||
</div> | ||
</div> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
db/primary_migrate/20241023195101_add_webauthn_platform_recommended_dismissed_at_to_user.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddWebauthnPlatformRecommendedDismissedAtToUser < ActiveRecord::Migration[7.2] | ||
def change | ||
add_column :users, :webauthn_platform_recommended_dismissed_at, :datetime, default: nil, comment: 'sensitive=false' | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.