Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug 1871065 - [DUO] Update BMO to move away from the deprecated iframe Duo prompt to the suggested Duo Universal Prompt #2202

Merged
merged 7 commits into from Mar 26, 2024

Conversation

dklawren
Copy link
Collaborator

@dklawren dklawren commented Mar 14, 2024

Connor and I will be doing a in-person code review for this due to the size and timing of it but I will add some details here as well.

  • Instead of showing the Duo MFA dialog inside an iframe we are moving to a redirection scheme which sends the user to a Duo hosted verification page, and then redirects back to BMO once they complete the verification.
  • BMO will then use a temporary auth code provided by Duo to send a request with a client secret and get back the final status of the users verification. Failing if the user was not successful.
  • This flow is very similar to how standard OAuth2 works and uses similarly named endpoints at Duo as OAuth2.
  • I have added some test cases to verify that the Duo part inside BMO is working properly. One test case is for functional testing of the DuoClient module. The other is a UI test that mocks a very basic the Duo site and redirects back to BMO.
  • The new Duo Universal Prompt uses a client_id and client_secret value instead of the previous duo_ikey, duo_akey, and duo_skey values. The duo_ikey and duo_skey values are interchangeable with the client_id and client_secret respectively.
  • The admin params page for Duo has been updated to show client_id and client_secret params.
  • DuoAPI and DuoWeb modules removed.

@dklawren dklawren requested a review from cgsheeh March 17, 2024 16:09
Bugzilla/App/MFA/Duo.pm Outdated Show resolved Hide resolved
Bugzilla/App/MFA/Duo.pm Outdated Show resolved Hide resolved
Bugzilla/DuoClient.pm Outdated Show resolved Hide resolved
Bugzilla/MFA/Duo.pm Outdated Show resolved Hide resolved
external_test_api.pl Show resolved Hide resolved
Bugzilla/DuoClient.pm Outdated Show resolved Hide resolved
@dklawren dklawren requested a review from cgsheeh March 21, 2024 00:36
Copy link
Collaborator

@cgsheeh cgsheeh left a comment

Choose a reason for hiding this comment

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

A few nits, but doing "request changes" just to ensure the sub claim is correct.

Bugzilla/DuoClient.pm Outdated Show resolved Hide resolved
Bugzilla/DuoClient.pm Show resolved Hide resolved
Bugzilla/DuoClient.pm Outdated Show resolved Hide resolved
Comment on lines +513 to +517
# If we got this far and MFA is Duo, we should be verified
if ($user->mfa eq 'Duo' && !$event->{duo_verified}) {
ThrowUserError('duo_user_error', {reason => 'Invalid Duo Security MFA Code'});
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's make a function for this and re-use it in userprefs.cgi.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I am not sure that creating a function for this will gain much as it would be a very small check and is only in two places currently. Would the utility function throw the error or would it just return true or false. Would it do the $mfa eq 'Duo' check or would we do that before calling it. Just not sure it is worth the code line savings yet.

Copy link
Collaborator

Choose a reason for hiding this comment

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

The whole if block should be in one function like assert_duo_verified($user->mfa, $event), since we're checking the exact same condition and throwing the exact same error in both places. It's mostly a maintainability suggestion, so if you're fine with maintaining the same logic in multiple places, it's no problem.

@dklawren dklawren requested a review from cgsheeh March 22, 2024 16:14
Copy link
Collaborator

@cgsheeh cgsheeh left a comment

Choose a reason for hiding this comment

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

Very nice!

@dklawren dklawren merged commit d7ca4b5 into mozilla-bteam:master Mar 26, 2024
17 checks passed
@dklawren dklawren deleted the 1871065 branch March 26, 2024 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants