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

Implement Two Factor Authentication #13670

Merged
merged 44 commits into from Dec 3, 2018
Merged

Implement Two Factor Authentication #13670

merged 44 commits into from Dec 3, 2018

Conversation

tsteur
Copy link
Member

@tsteur tsteur commented Nov 5, 2018

fixes #13325 in a new plugin TwoFactorAuth

Also provides a new class PasswordVerifier which requires a user to first confirm their password in a new screen before continuing with a specific action (not available in a dialog currently).

@tsteur tsteur added the Pull Request WIP Indicates the current pull request is still work in progress and not ready yet for a review. label Nov 5, 2018
@tsteur tsteur added this to the 3.8.0 milestone Nov 5, 2018
@diosmosis
Copy link
Member

From testing locally:

  • in the setupTwoFactorAuth page, if I copy text manually, it doesn't enable the 'next' button, which confused me a bit.
  • not sure how important it is, but the 2 factor auth code input seems to save values:

image

seems a bit odd to see past values here.

  • the mailto for the "Ask super user to reset your authentication code " link isn't set properly for non-superusers. likely due to the change in UsersManager::enrichUser (the email is removed if the user isn't the current user)

@diosmosis
Copy link
Member

Looked through the code, seems ok but there's a lot to review, so could have missed something. @sgiehl might want to review as well

@tsteur
Copy link
Member Author

tsteur commented Nov 29, 2018

@diosmosis fyi applying all the changes you suggested.

the mailto for the "Ask super user to reset your authentication code " link isn't set properly for non-superusers. likely due to the change in UsersManager::enrichUser (the email is removed if the user isn't the current user)

this is a bug and regressed... will also look into how to fix it...

in the setupTwoFactorAuth page, if I copy text manually, it doesn't enable the 'next' button, which confused me a bit.

not sure if we can detect whether all the codes have been copied manually? sounds bit tricky maybe but will check if possible

@diosmosis
Copy link
Member

not sure if we can detect whether all the codes have been copied manually? sounds bit tricky maybe but will check if possible

Could just allow users to click next w/o copying/etc. Would only be important if lots of people tried to copy manually.

@tsteur
Copy link
Member Author

tsteur commented Nov 29, 2018

Could just allow users to click next w/o copying/etc. Would only be important if lots of people tried to copy manually.

platforms like github force you to press one of the buttons basically to increase likelihood that they have created a backup of the recovery codes. I just checked and it does show a notification

Please backup your recovery codes using one of the above methods before continuing the two-factor authentication setup.

So I reckon it should be good for now... also fixed couple screenshot tests but a few more need to be updated after next run. Also added support for activity log...

@sgiehl let me know whether you want to have a look or whether it can be merged.

@sgiehl
Copy link
Member

sgiehl commented Dec 2, 2018

I will have a look now...

Copy link
Member

@sgiehl sgiehl left a comment

Choose a reason for hiding this comment

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

Some Feedback:

  • Left some comments

  • When 2FA is already setup the UI imho does not make it clear enough that Setup a different device will also remove the currently configured 2FA and also the recovery codes. Github for example displays this warning when changing the 2FA device:
    image

  • Migration from GoogleAuthenticator plugin seems to work fine. Shall I release a new version that marks the plugin not compatible with Matomo 3.8?

/**
*
*/
class FormTwoFactorAuthCode extends QuickForm2
Copy link
Member

Choose a reason for hiding this comment

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

We should maybe try to avoid using QuickForm2 in the future, as that library should better be removed. It's unmaintained since 2014

Copy link
Member Author

Choose a reason for hiding this comment

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

It still works and we're using it in other places. There's not much point of replacing or not using it right now IMO. at some point we can replace all the usages at once but as long as it works I think there are other parts that are maybe more important. (for example replacing email lib etc)

@@ -1,5 +1,10 @@
{
"UsersManager": {
"2FA": "2FA",
Copy link
Member

Choose a reason for hiding this comment

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

Actually that string is also available in the 2FA plugin. Maybe we should only use one even if transifex will autofill one of the translations as soon as the other was translated. Unfortunately that doesn't happen when the translations are later changed, so in some cases their might be different translations for both...

Copy link
Member Author

Choose a reason for hiding this comment

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

I left it there separately in case TwoFactorAuth plugin is disabled. I don't think we load the translation then? We're not checking in the UI whether 2FA plugin is disabled in UsersManager as it's edge case and bit tricky. This way it still shows correct translation there.

'twofactor_recovery_code' => "CREATE TABLE {$prefixTables}twofactor_recovery_code (
idrecoverycode BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
login VARCHAR(100) NOT NULL,
recovery_code VARCHAR(40) NOT NULL,
Copy link
Member

Choose a reason for hiding this comment

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

That one differs to the update script, it only creates a VARCHAR(20)

Copy link
Member Author

Choose a reason for hiding this comment

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

👍 will fix

@tsteur
Copy link
Member Author

tsteur commented Dec 3, 2018

@sgiehl now showing a warning re changing the device. Also fixed the update schema

Yes sounds good to mark Google authenticator as invalid with 3.8 👍

@tsteur
Copy link
Member Author

tsteur commented Dec 3, 2018

merging now to avoid even more merge conflicts... getting conflicts all the time with other PRs that were merged in the meantime. let me know if there was anything else, happy to change it...

@tsteur tsteur merged commit 284bdc0 into 3.x-dev Dec 3, 2018
@tsteur tsteur deleted the 13325 branch December 3, 2018 03:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Review PRs that need a code review not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Two Factor Authentication in core + new setting "Require two-factor authentication for everyone."
3 participants