Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
dfb2a34
changelog: Bug Fixes, Account information, Show non obfuscated view w…
mdiarra3 May 31, 2023
8c66673
LG-9869: allow authenticate to view work
mdiarra3 Jun 5, 2023
1d60347
remove unneeded methods
mdiarra3 Jun 5, 2023
5334f57
reauthn fix
mdiarra3 Jun 5, 2023
56cca83
add rspec to check that functionality is working
mdiarra3 Jun 7, 2023
c13b4e4
just do reauthntication context
mdiarra3 Jun 8, 2023
a8c1c34
Merge remote-tracking branch 'origin/main' into LG-9869-allow-authent…
mdiarra3 Jun 12, 2023
6225542
user profile spec updates
mdiarra3 Jun 12, 2023
ad8a1a7
Merge remote-tracking branch 'origin/main' into LG-9869-allow-authent…
mdiarra3 Jun 12, 2023
b635772
failing tests fix
mdiarra3 Jun 12, 2023
cd50691
email preference
mdiarra3 Jun 12, 2023
6cd2726
reauthn redirects to two_factor_login_path
mdiarra3 Jun 12, 2023
f7ab497
user profile spec dob
mdiarra3 Jun 12, 2023
efb81b4
fix profile
mdiarra3 Jun 12, 2023
a3f564c
Merge remote-tracking branch 'origin/main' into LG-9869-allow-authent…
mdiarra3 Jun 13, 2023
4ff535f
fix email language spec
mdiarra3 Jun 13, 2023
7b062d3
fix rubocop
mdiarra3 Jun 13, 2023
4f65504
use a reverity to show controller to reauthenticate
mdiarra3 Jun 15, 2023
828ec60
revert back mfa confirmation controller
mdiarra3 Jun 15, 2023
38c29d6
pii confirmation
mdiarra3 Jun 15, 2023
e9f5285
Add reauthenticate option that works for verifying profile
mdiarra3 Jun 20, 2023
643bf4e
update pii routes
mdiarra3 Jun 20, 2023
67047a5
add feature toggle
mdiarra3 Jun 21, 2023
7dac893
remove dev and test prod stuff
mdiarra3 Jun 22, 2023
a361fcc
Merge remote-tracking branch 'origin/main' into LG-9869-allow-authent…
mdiarra3 Jun 22, 2023
9e88184
Merge remote-tracking branch 'origin/main' into LG-9869-allow-authent…
mdiarra3 Jun 22, 2023
301e1da
change to put method in accounts controller
mdiarra3 Jun 22, 2023
c3384f8
remove reauthentication spec
mdiarra3 Jun 23, 2023
b8e7e7d
added additional comment
mdiarra3 Jun 26, 2023
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
11 changes: 11 additions & 0 deletions app/controllers/accounts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,16 @@ def show
user: current_user,
locked_for_session: pii_locked_for_session?(current_user),
)
@use_reauthentication_route = FeatureManagement.use_reauthentication_route?
end

# This action is used to re-authenticate when PII on the account page is locked on `show` action
# This allows users to view their PII after reauthenticating their MFA.

def reauthentication
user_session[:stored_location] = account_url
user_session[:context] = 'reauthentication'

redirect_to login_two_factor_options_path(reauthn: true)
end
end
13 changes: 11 additions & 2 deletions app/views/accounts/_pii.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,17 @@
<div class="usa-alert__body">
<div class="usa-alert__text">
<%= t('account.re_verify.banner') %>

<%= link_to(t('account.re_verify.footer'), user_password_confirm_path) %>
<% if use_reauthentication_route %>
<%= render ButtonComponent.new(
action: ->(**tag_options, &block) do
button_to(account_reauthentication_path, **tag_options, &block)
end,
method: :post,
class: 'usa-button usa-button--unstyled',
).with_content(t('account.re_verify.footer')) %>
<% else %>
<%= link_to(t('account.re_verify.footer'), user_password_confirm_path) %>
<% end %>
</div>
</div>
</div>
Expand Down
3 changes: 2 additions & 1 deletion app/views/accounts/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -96,5 +96,6 @@

<% if @presenter.show_pii_partial? %>
<%= render 'accounts/pii', pii: @presenter.pii,
locked_for_session: @presenter.locked_for_session %>
locked_for_session: @presenter.locked_for_session,
use_reauthentication_route: @use_reauthentication_route %>
<% end %>
2 changes: 2 additions & 0 deletions config/application.yml.default
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ verify_personal_key_max_attempts: 5
version_headers_enabled: false
use_dashboard_service_providers: false
use_kms: false
use_reauthentication_route: true
usps_confirmation_max_days: 10
usps_ipp_password: ''
usps_ipp_client_id: ''
Expand Down Expand Up @@ -508,6 +509,7 @@ production:
skip_encryption_allowed_list: '["urn:gov:gsa:SAML:2.0.profiles:sp:sso:dev", "urn:gov:gsa:SAML:2.0.profiles:sp:sso:int"]'
state_tracking_enabled: false
telephony_adapter: pinpoint
use_reauthentication_route: false
use_kms: true
usps_confirmation_max_days: 30
usps_upload_sftp_directory: ''
Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@

get '/account' => 'accounts#show'
get '/account/connected_accounts' => 'accounts/connected_accounts#show'
post '/account/reauthentication' => 'accounts#reauthentication'
get '/account/devices/:id/events' => 'events#show', as: :account_events
get '/account/delete' => 'users/delete#show', as: :account_delete
post '/account/delete' => 'users/delete#delete'
Expand Down
4 changes: 4 additions & 0 deletions lib/feature_management.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ def self.show_no_pii_banner?
Identity::Hostdata.in_datacenter? && Identity::Hostdata.domain != 'login.gov'
end

def self.use_reauthentication_route?
IdentityConfig.store.use_reauthentication_route
end

def self.enable_saml_cert_rotation?
IdentityConfig.store.saml_secret_rotation_enabled
end
Expand Down
1 change: 1 addition & 0 deletions lib/identity_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,7 @@ def self.build_store(config_map)
config.add(:get_usps_proofing_results_job_cron, type: :string)
config.add(:get_usps_proofing_results_job_reprocess_delay_minutes, type: :integer)
config.add(:get_usps_proofing_results_job_request_delay_milliseconds, type: :integer)
config.add(:use_reauthentication_route, type: :boolean)
config.add(:usps_upload_sftp_directory, type: :string)
config.add(:usps_upload_sftp_host, type: :string)
config.add(:usps_upload_sftp_password, type: :string)
Expand Down
24 changes: 24 additions & 0 deletions spec/controllers/accounts_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,28 @@
end
end
end

describe '#reauthentication' do
let(:user) { create(:user, :fully_registered) }
before(:each) do
stub_sign_in(user)
end
it 'redirects to 2FA options' do
post :reauthentication

expect(response).to redirect_to login_two_factor_options_url(reauthn: true)
end

it 'sets context to authentication' do
post :reauthentication

expect(controller.user_session[:context]).to eq 'reauthentication'
end

it 'sets stored location for redirecting' do
post :reauthentication

expect(controller.user_session[:stored_location]).to eq account_url
end
end
end
53 changes: 53 additions & 0 deletions spec/features/users/user_profile_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -181,4 +181,57 @@
expect(current_path).to eq(account_history_path)
end
end

context 'allows verified user to see their information' do
context 'time between sign in and remember device' do
it 'shows PII when timeout hasnt expired' do
profile = create(
:profile, :active, :verified,
pii: Idp::Constants::MOCK_IDV_APPLICANT_WITH_PHONE
)
sign_in_user(profile.user)
check t('forms.messages.remember_device')
fill_in_code_with_last_phone_otp
click_submit_default
visit account_path
expect(page).to_not have_button(t('account.re_verify.footer'))

dob = Idp::Constants::MOCK_IDV_APPLICANT[:dob]
parsed_date = DateParser.parse_legacy(dob).to_formatted_s(:long)
expect(page).to have_content(parsed_date)
end
end

context 'when time expired' do
it 'has a prompt to authenticate device and pii isnt visible until reauthenticate' do
profile = create(
:profile, :active, :verified,
pii: Idp::Constants::MOCK_IDV_APPLICANT_WITH_PHONE
)
user = profile.user
sign_in_user(user)
dob = Idp::Constants::MOCK_IDV_APPLICANT[:dob]
parsed_date = DateParser.parse_legacy(dob).to_formatted_s(:long)

check t('forms.messages.remember_device')
fill_in_code_with_last_phone_otp
click_submit_default

timeout_in_minutes = IdentityConfig.store.pii_lock_timeout_in_minutes.to_i
travel_to((timeout_in_minutes + 1).minutes.from_now) do
sign_in_user(user)
visit account_path
expect(page).to have_button(t('account.re_verify.footer'))
expect(page).to_not have_content(parsed_date)
click_button t('account.re_verify.footer')
expect(page).
to have_content t('two_factor_authentication.login_options.sms')
click_button t('forms.buttons.continue')
fill_in_code_with_last_phone_otp
click_submit_default
expect(page).to have_content(parsed_date)
end
end
end
end
end