Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 0 additions & 6 deletions app/policies/service_provider_mfa_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,6 @@ def piv_cac_required?
piv_cac_requested?
end

def allow_user_to_switch_method?
return false if piv_cac_required?
return true unless phishing_resistant_required?
piv_cac_enabled? && webauthn_enabled?
end

def multiple_factors_enabled?
mfa_context.enabled_mfa_methods_count > 1
end
Expand Down
16 changes: 4 additions & 12 deletions app/presenters/two_factor_auth_code/generic_delivery_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class GenericDeliveryPresenter
include ActionView::Helpers::TranslationHelper
include Rails.application.routes.url_helpers

attr_reader :code_value, :reauthn
attr_reader :code_value, :reauthn, :service_provider

def initialize(data:, view:, service_provider:, remember_device_default: true)
data.each do |key, value|
Expand All @@ -19,26 +19,18 @@ def header
raise NotImplementedError
end

def link_text
t('two_factor_authentication.login_options_link_text')
end

def link_path
login_two_factor_options_path
end

def redirect_location_step; end

def troubleshooting_options
[
choose_another_method_troubleshooting_option,
learn_more_about_authentication_options_troubleshooting_option,
].select(&:present?)
]
end

def choose_another_method_troubleshooting_option
return if link_path.blank?
BlockLinkComponent.new(url: link_path).with_content(link_text)
BlockLinkComponent.new(url: login_two_factor_options_path).
with_content(t('two_factor_authentication.login_options_link_text'))
end

def learn_more_about_authentication_options_troubleshooting_option
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,55 +6,10 @@ def header
t('two_factor_authentication.piv_cac_header_text')
end

def piv_cac_help
if service_provider_mfa_policy.phishing_resistant_required? &&
service_provider_mfa_policy.allow_user_to_switch_method?
t('instructions.mfa.piv_cac.confirm_piv_cac_or_aal3')
elsif service_provider_mfa_policy.phishing_resistant_required? ||
service_provider_mfa_policy.piv_cac_required?
t('instructions.mfa.piv_cac.confirm_piv_cac_only')
else
t('instructions.mfa.piv_cac.confirm_piv_cac')
end
end

def piv_cac_capture_text
t('forms.piv_cac_mfa.submit')
end

def link_text
if service_provider_mfa_policy.phishing_resistant_required?
if service_provider_mfa_policy.allow_user_to_switch_method?
t('two_factor_authentication.piv_cac_webauthn_available')
else
''
end
else
super
end
end

def link_path
if service_provider_mfa_policy.phishing_resistant_required?
if service_provider_mfa_policy.allow_user_to_switch_method?
login_two_factor_webauthn_url
else
''
end
else
super
end
end

def troubleshooting_options
options = []
if service_provider_mfa_policy.allow_user_to_switch_method?
options << choose_another_method_troubleshooting_option
end
options << learn_more_about_authentication_options_troubleshooting_option
options
end

def cancel_link
if reauthn
account_path
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,7 @@ def initialize(data:, view:, service_provider:, remember_device_default: true,
end

def webauthn_help
if service_provider_mfa_policy.phishing_resistant_required? &&
service_provider_mfa_policy.allow_user_to_switch_method?
t('instructions.mfa.webauthn.confirm_webauthn_or_aal3')
elsif service_provider_mfa_policy.phishing_resistant_required?
t('instructions.mfa.webauthn.confirm_webauthn_only')
elsif platform_authenticator?
if platform_authenticator?
t('instructions.mfa.webauthn.confirm_webauthn_platform', app_name: APP_NAME)
else
t('instructions.mfa.webauthn.confirm_webauthn')
Expand All @@ -45,32 +40,8 @@ def header
end
end

def link_text
if service_provider_mfa_policy.phishing_resistant_required?
if service_provider_mfa_policy.allow_user_to_switch_method?
t('two_factor_authentication.webauthn_piv_available')
else
''
end
else
super
end
end

def link_path
if service_provider_mfa_policy.phishing_resistant_required?
if service_provider_mfa_policy.allow_user_to_switch_method?
login_two_factor_piv_cac_url
else
''
end
else
super
end
end

def troubleshooting_options
options = [choose_another_method_troubleshooting_option].select(&:present?)
options = [choose_another_method_troubleshooting_option]
if platform_authenticator?
options << BlockLinkComponent.new(
url: help_center_redirect_path(
Expand Down
21 changes: 20 additions & 1 deletion app/presenters/two_factor_login_options_presenter.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
class TwoFactorLoginOptionsPresenter < TwoFactorAuthCode::GenericDeliveryPresenter
include ActionView::Helpers::TranslationHelper

attr_reader :user
attr_reader :user, :phishing_resistant_required, :piv_cac_required

alias_method :phishing_resistant_required?, :phishing_resistant_required
alias_method :piv_cac_required?, :piv_cac_required

def initialize(
user:,
Expand Down Expand Up @@ -31,6 +34,14 @@ def info
t('two_factor_authentication.login_intro')
end

def restricted_options_warning_text
if piv_cac_required?
t('two_factor_authentication.aal2_request.piv_cac_only_html', sp_name:)
elsif phishing_resistant_required?
t('two_factor_authentication.aal2_request.phishing_resistant_html', sp_name:)
end
end

def options
mfa = MfaContext.new(user)

Expand Down Expand Up @@ -107,4 +118,12 @@ def account_reset_token
def account_reset_token_valid?
user&.account_reset_request&.granted_token_valid?
end

def sp_name
if service_provider
service_provider.friendly_name
else
APP_NAME
end
end
end
6 changes: 6 additions & 0 deletions app/views/two_factor_authentication/options/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
<%= @presenter.info %>
</p>

<% if @presenter.restricted_options_warning_text.present? %>
<%= render AlertComponent.new(type: :warning, class: 'margin-top-4') do %>
<%= @presenter.restricted_options_warning_text %>
<% end %>
<% end %>

<%= simple_form_for(
@two_factor_options_form,
html: { autocomplete: 'off' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<%= render PageHeadingComponent.new.with_content(@presenter.header) %>

<p>
<%= @presenter.piv_cac_help %>
<%= t('instructions.mfa.piv_cac.confirm_piv_cac') %>
</p>

<div class="margin-y-5">
Expand Down
12 changes: 0 additions & 12 deletions config/locales/instructions/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@ en:
you think this is an error, %{try_again_html}.
back_to_sign_in: Go back to sign in
confirm_piv_cac: Present the PIV/CAC that you associated with your account.
confirm_piv_cac_only: This app requires a higher level of security. You need to
verify your identity using a government employee ID that you
previously set up to access your information.
confirm_piv_cac_or_aal3: This app requires a higher level of security. You need
to verify your identity using a physical device such as a security key
or government employee ID (PIV or CAC) to access your information.
did_not_work_html: Please %{please_try_again_html}. If this problem continues,
contact your agency administrator.
http_failure: The server took too long to respond. Please try again.
Expand Down Expand Up @@ -72,12 +66,6 @@ en:
code will expire in %{expiration} minutes.
webauthn:
confirm_webauthn: Present the security key that you associated with your account.
confirm_webauthn_only: This app requires a higher level of security. You need to
verify your identity using a security key that you previously set up
to access your information.
confirm_webauthn_or_aal3: This app requires a higher level of security. You need
to verify your identity using a physical device such as a security key
or government employee ID (PIV or CAC) to access your information.
confirm_webauthn_platform: You have face or touch unlock enabled for your %{app_name} account.
webauthn_platform:
learn_more_help: Learn more about face or touch unlock
Expand Down
14 changes: 0 additions & 14 deletions config/locales/instructions/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,6 @@ es:
día. Si cree que se trata de un error, %{try_again_html}.
back_to_sign_in: Regrese para iniciar sesión
confirm_piv_cac: Presenta la PIV/CAC que asociaste con tu cuenta.
confirm_piv_cac_only: Esta aplicación requiere un mayor nivel de seguridad. Debe
verificar su identidad con una identificación de empleado del Gobierno
que haya configurado previamente para acceder a su información.
confirm_piv_cac_or_aal3: Esta aplicación requiere un mayor nivel de seguridad.
Debe verificar su identidad con un dispositivo físico, como una llave
de seguridad o una identificación de empleado del Gobierno (PIV o CAC)
para acceder a su información.
did_not_work_html: '%{please_try_again_html}. Comuníquese con el encargado de su
organismo si persiste este problema.'
http_failure: El servidor tardó demasiado en responder. Inténtalo de nuevo.
Expand Down Expand Up @@ -75,13 +68,6 @@ es:
%{number_html}. Este código expirará en %{expiration} minutos.
webauthn:
confirm_webauthn: Presente la clave de seguridad que asoció con su cuenta.
confirm_webauthn_only: Esta aplicación requiere un mayor nivel de seguridad.
Debe verificar su identidad con una llave de seguridad que haya
configurado previamente para acceder a su información.
confirm_webauthn_or_aal3: Esta aplicación requiere un mayor nivel de seguridad.
Debe verificar su identidad con un dispositivo físico, como una llave
de seguridad o una identificación de empleado del Gobierno (PIV o CAC)
para acceder a su información.
confirm_webauthn_platform: Tiene activado el desbloqueo facial o táctil para su
cuenta de %{app_name}.
webauthn_platform:
Expand Down
16 changes: 0 additions & 16 deletions config/locales/instructions/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,6 @@ fr:
back_to_sign_in: Retourner à vous connecter
confirm_piv_cac: Veuillez présenter la carte PIV/CAC que vous avez associée à
votre compte.
confirm_piv_cac_only: Cette application nécessite un niveau de sécurité plus
élevé. Vous devez vérifier votre identité à l’aide d’un badge
d’employé du gouvernement que vous avez précédemment configuré pour
accéder à vos informations.
confirm_piv_cac_or_aal3: Cette application nécessite un niveau de sécurité plus
élevé. Vous devez vérifier votre identité à l’aide d’un dispositif
physique tel qu’une clé de sécurité ou un badge d’employé du
gouvernement (PIV ou CAC) pour accéder à vos informations.
did_not_work_html: Veuillez %{please_try_again_html}. Si ce problème persiste,
contactez l’administrateur de votre agence.
http_failure: Le serveur a mis trop de temps à répondre. Veuillez réessayer.
Expand Down Expand Up @@ -85,14 +77,6 @@ fr:
%{number_html}. Ce code expirera dans %{expiration} minutes.
webauthn:
confirm_webauthn: Présentez la clé de sécurité associée à votre compte.
confirm_webauthn_only: Cette application nécessite un niveau de sécurité plus
élevé. Vous devez vérifier votre identité à l’aide d’une clé de
sécurité que vous avez précédemment configurée pour accéder à vos
informations.
confirm_webauthn_or_aal3: Cette application nécessite un niveau de sécurité plus
élevé. Vous devez vérifier votre identité à l’aide d’un dispositif
physique tel qu’une clé de sécurité ou un badge d’employé du
gouvernement (PIV ou CAC) pour accéder à vos informations.
confirm_webauthn_platform: Vous avez activé le déverrouillage facial ou tactile
pour votre compte %{app_name}.
webauthn_platform:
Expand Down
8 changes: 6 additions & 2 deletions config/locales/two_factor_authentication/en.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
---
en:
two_factor_authentication:
aal2_request:
phishing_resistant_html: '<strong>%{sp_name}</strong> requires a high-security
authentication method, such as face or touch unlock, a security key or a
government employee ID.'
piv_cac_only_html: '<strong>%{sp_name}</strong> requires your government
employee ID, a high-security authentication method.'
account_reset:
cancel_link: Cancel your request
link: deleting your account
Expand Down Expand Up @@ -124,7 +130,6 @@ en:
change_number: Use another phone number
code_not_received: I didn’t receive my one-time code
piv_cac_header_text: Present your PIV/CAC
piv_cac_webauthn_available: Use your security key
please_try_again_html: Please try again in <strong>%{countdown}</strong>.
read_about_two_factor_authentication: Read about two-factor authentication
recaptcha:
Expand Down Expand Up @@ -178,7 +183,6 @@ en:
additional_methods_link: choose another authentication method
try_again: Face or touch unlock was unsuccessful. Please try again or %{link}.
webauthn_header_text: Connect your security key
webauthn_piv_available: Use your PIV or CAC
webauthn_platform_header_text: Use face or touch unlock
webauthn_platform_use_key: Use face or touch unlock
webauthn_use_key: Use security key
8 changes: 6 additions & 2 deletions config/locales/two_factor_authentication/es.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
---
es:
two_factor_authentication:
aal2_request:
phishing_resistant_html: '<strong>%{sp_name}</strong> requiere un método de
autenticación de alta seguridad, como el desbloqueo facial o táctil, una
llave de seguridad o una identificación de empleado público.'
piv_cac_only_html: '<strong>%{sp_name}</strong> requiere su identificación de
empleado público, un método de autenticación de alta seguridad.'
account_reset:
cancel_link: Cancelar su solicitud
link: eliminando su cuenta
Expand Down Expand Up @@ -132,7 +138,6 @@ es:
change_number: Utilice otro número de teléfono.
code_not_received: No recibí mi código de un solo uso.
piv_cac_header_text: Presenta tu PIV/CAC
piv_cac_webauthn_available: Utilice su llave de seguridad
please_try_again_html: Inténtelo de nuevo en <strong>%{countdown}</strong>.
read_about_two_factor_authentication: Conozca la autenticación de dos factores
recaptcha:
Expand Down Expand Up @@ -193,7 +198,6 @@ es:
try_again: El desbloqueo facial o táctil no fue exitoso. Por favor, inténtelo de
nuevo o %{link}.
webauthn_header_text: Conecte su llave de seguridad
webauthn_piv_available: Utilice su PIV o CAC
webauthn_platform_header_text: Usar desbloqueo facial o táctil
webauthn_platform_use_key: Usar desbloqueo facial o táctil
webauthn_use_key: Usar llave de seguridad
10 changes: 8 additions & 2 deletions config/locales/two_factor_authentication/fr.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
---
fr:
two_factor_authentication:
aal2_request:
phishing_resistant_html: '<strong>%{sp_name}</strong> nécessite une méthode
d’authentification de haute sécurité, telle que le déverrouillage du
visage ou du tactile, une clé de sécurité ou un identifiant d’employé du
gouvernement.'
piv_cac_only_html: '<strong>%{sp_name}</strong> nécessite votre identifiant
d’employé du gouvernement, une méthode d’authentification de haute
sécurité.'
account_reset:
cancel_link: Annuler votre demande
link: supprimer votre compte
Expand Down Expand Up @@ -138,7 +146,6 @@ fr:
change_number: Utilisez un autre numéro de téléphone
code_not_received: Je n’ai pas reçu mon code à usage unique
piv_cac_header_text: Veuillez présenter votre carte PIV/CAC
piv_cac_webauthn_available: Utilisez votre clé de sécurité
please_try_again_html: Veuillez essayer de nouveau dans <strong>%{countdown}</strong>.
read_about_two_factor_authentication: En savoir plus sur l’authentification à deux facteurs
recaptcha:
Expand Down Expand Up @@ -199,7 +206,6 @@ fr:
try_again: Le déverrouillage facial ou tactile n’a pas fonctionné. Veuillez
réessayer ou %{link}.
webauthn_header_text: Connectez votre clé de sécurité
webauthn_piv_available: Utilisez votre PIV ou CAC
webauthn_platform_header_text: Utilisez le déverrouillage facial ou tactile
webauthn_platform_use_key: Utilisez le déverrouillage facial ou tactile
webauthn_use_key: Utiliser la clé de sécurité
Loading