Skip to content

Kmas lg 9961 more mfa same type#8863

Merged
kevinsmaster5 merged 59 commits intomainfrom
kmas-lg-9961-more-mfa-same-type
Aug 17, 2023
Merged

Kmas lg 9961 more mfa same type#8863
kevinsmaster5 merged 59 commits intomainfrom
kmas-lg-9961-more-mfa-same-type

Conversation

@kevinsmaster5
Copy link
Contributor

🎫 Ticket

LG-9961

🛠 Summary of changes

Enables a user to select more than one of the same MFA type at account setup (except for Backup Codes and PIV). The confirmation view is removed and after the first option is set the user is redirected back to the secondary option view. When additional options are added they also return to the secondary option view until they click continue on to the account view.

Some style changes were added to give clearer feedback to the user about what options have been selected.

Figma

📜 Testing Plan

Steps to confirm the changes.

  • Create a new account, confirm email, set password
  • On the Two Factor Authentication view pick a MFA option and click Continue
  • You should return to the Two Factor Authentication Setup view but now it will display your first option above the checkbox fields as in the updated design. The selected checkbox from step 2 should still be selectable again unless it is Backup Codes or PIV/CAC
  • Clicking continue again after selecting another MFA option and completing its setup should return you to the Two Factor Authentication Setup view.

👀 Screenshots

Screenshot 2023-07-25 at 5 24 24 PM (2)

Screenshot 2023-07-25 at 5 25 22 PM (2)

@kevinsmaster5 kevinsmaster5 marked this pull request as draft July 26, 2023 11:30
@kevinsmaster5 kevinsmaster5 marked this pull request as ready for review July 31, 2023 18:04
Copy link
Contributor

@aduth aduth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking really good overall! Left a couple comments, but this is working well 👍

@kevinsmaster5 kevinsmaster5 marked this pull request as draft August 7, 2023 19:13
@kevinsmaster5 kevinsmaster5 marked this pull request as ready for review August 7, 2023 21:27
@aduth
Copy link
Contributor

aduth commented Aug 14, 2023

Before merging, can we also rebase or merge main, so we don't run any risk of issues with the branch being out-of-date? It looks like the merge base is pretty old (a5aa1bc).

@kevinsmaster5 kevinsmaster5 force-pushed the kmas-lg-9961-more-mfa-same-type branch from 40b6944 to dae132f Compare August 14, 2023 14:23
@kevinsmaster5 kevinsmaster5 force-pushed the kmas-lg-9961-more-mfa-same-type branch from e05e7f0 to 9cd8a69 Compare August 15, 2023 12:53
Copy link
Contributor

@aduth aduth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! And thanks for the patience with all the reviews 😅

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe for a follow-up, but it's rather unexpected to me that we need to be nil-tolerant on the users all of a sudden. It feels to me like maybe it's an issue with how we initialize the specs, but the setup presenters should ideally enforce that a user always exists.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm troubleshooting an error that seemed to indicate GitLab wasn't happy about something to do with webauthn_configurations
https://gitlab.login.gov/lg/identity-idp/-/jobs/659011

--- Caused by: ---

 # NoMethodError:
 #   undefined method `webauthn_configurations' for nil:NilClass
 #   ./app/presenters/two_factor_authentication/webauthn_platform_selection_presenter.rb:25:in `mfa_configuration_count'

I'll take a look from the spec angle and see if I can find the problem.

@kevinsmaster5 kevinsmaster5 force-pushed the kmas-lg-9961-more-mfa-same-type branch from da18522 to 7317bf6 Compare August 15, 2023 18:29
@aduth
Copy link
Contributor

aduth commented Aug 15, 2023

For posterity: @kevinsmaster5 and I paired on the last few commits, related to some build failures with user sometimes being nil. We discovered that since these presenter classes are used in both set-up as well as sign-in, the user would not always be present -- only during set-up.

We addressed this by:

  • Adding an additional condition to disabled? to only apply the default logic for set-up, to rely on short-circuit evaluation to prevent mfa_configuration_count being called during sign-in (981b926)
  • Making user a required argument of the presenter classes to avoid potential confusion around user being present or not, since it's reasonably available during sign-in as well as set-up (b76e7c7, f0c2147)

Separately, we want to propose a refactor which would split up the presenter classes between set-up and sign-in, since:

  1. There's almost no shared logic between the two flows, almost everything in the base class already branches based on the configuration.present? (i.e. between sign-in and set-up)
  2. A lot of the methods are only relevant for set-up (including those added and revised here), but it's not entirely clear this is the case

end

subject(:presenter) { described_class.new }
attr_reader :configuration, :user
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would not expect to see attr_reader in specs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

refactored that at cf44f91

Copy link
Contributor

@aduth aduth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple minor notes on spec changes, but otherwise still LGTM 👍

expect(presenter.disabled?).to eq(true)
end
end
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest adding test coverage for the new logic branch we added in 981b926

Suggested change
end
end
context 'with configuration' do
let(:single_configuration_only) { true }
let(:mfa_configuration_count) { 1 }
let(:configuration) { create(:phone_configuration, user: user) }
before do
allow(presenter).to receive(:configuration).and_return(configuration)
end
it { expect(presenter.disabled?).to eq(false) }
end

context 'when a user has a phone configuration' do
let(:phone) { build(:phone_configuration, phone: '+1 888 867-5309') }

let(:user) {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could probably move this up to the top scope so that we only have to define it once (after line 3).

I'd also suggest making it create an actual value, since this is effectively setting user to nil, which we're not expecting to happen in any real-world usage.

let(:user) { build(:user) }

Same note would apply to other changes where we define let(:user) {} this way.

@kevinsmaster5 kevinsmaster5 merged commit a12a321 into main Aug 17, 2023
@kevinsmaster5 kevinsmaster5 deleted the kmas-lg-9961-more-mfa-same-type branch August 17, 2023 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants