LG-10022: Avoid second MFA prompt for strict MFA requirement#9263
Merged
Conversation
changelog: User-Facing Improvements, MFA Setup, Add second MFA reminder screen for single-MFA accounts
jmdembe
reviewed
Sep 25, 2023
| def user_needs_second_mfa_reminder? | ||
| return false unless IdentityConfig.store.second_mfa_reminder_enabled | ||
| return false if user_has_dismissed_second_mfa_reminder? || user_has_multiple_mfa_methods? | ||
| return false if user_has_dismissed_second_mfa_reminder? |
Contributor
There was a problem hiding this comment.
if each conditional returns false, why not || operator instead of multiple return false statements?
Contributor
Author
There was a problem hiding this comment.
|| operator can work. It's a minor thing, but stylistically I felt the multiple returns are a little easier to scan as associated with the return value when split across multiple lines, though I preferred the || when it could be contained to a single line.
For example, in this code snippet, it's a little less obvious to me that user_has_multiple_mfa_methods? ties back to the return false, since it's so far apart.
return false if !IdentityConfig.store.second_mfa_reminder_enabled ||
user_has_dismissed_second_mfa_reminder? ||
second_mfa_enrollment_may_downgrade_for_service_provider_mfa_requirement? ||
user_has_multiple_mfa_methods?
jmdembe
approved these changes
Sep 25, 2023
Merged
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🎫 Ticket
Follow-on revision for LG-10022 (#9124)
🛠 Summary of changes
Updates the second MFA reminder logic to avoid prompting the user if they are authenticating with a partner which requires stricter MFA requirements (i.e. phishing-resistant or PIV-only). This avoids an issue where the user may inadvertently "downgrade" their authentication method, since they may choose to add a second MFA which is less secure than what was required for the request. This could result in the user being prompted excessively to reauthenticate, since the less-secure method would not be valid for the authentication request, and they'd need to reauthenticate with the more secure method.
Per related Slack discussion, a separate ticket will be created to explore revisions to the session
auth_methodtracking to allow multiple, simultaneous valid authentications, so that a less-secure-but-more-recent authentication will not invalidate a more-secure-but-less-recent authentication.📜 Testing Plan
It's easiest to test by setting an artificially low config override for sign-ins or account page, e.g. in
config/application.yml: