Two step authentication with Google Authenticator

Re: Two step authentication with Google Authenticator

by Andreas Grupp -
Number of replies: 9
Ok, anything that integrates better den a2fa is welcome. But I agree totally with you that an authentication module that integrates totally to the Moodle login process would be the best way. I am thinking of the following behavior:
  • User has a Moodle account in any way (manual, LDAP, ...) and is able to login by username and password
  • In the users profile there is a link to activate two-factor-authentication. The following steps to activate the two-factor-authentication are similar to the way it is done for example in Dropbox. Whether it is really necessary to have a QR-code to scan the shared secret or not is not important in my opinion. It is also possible to just type the secret into a textfield in the app on a smartphone.
  • During the login process Moodle prefers the 2-factor-auth-module and looks whether this login variant is activated for the user. If it is this way - the third field for the code is shown. If the user is not registered for the two-factor-authentication there is a fallback to the other login-modules.

Do you think the integration in this way is a complex task and can not be done with your code?

In reply to Andreas Grupp

Re: Two step authentication with Google Authenticator

by James McLean -

That's along the lines of what we have implemented, the only stumbling block at the moment is the ability for users to set up their own two-factor authentication. At the moment it requires an administrator or support staff to enable it for a user, and then provide them with the QR code - basically that requires that they're physically with the person when they enable it.

I am working on the ability for users to enable their own two-factor authentication at the moment; where they will access a page to enable it - this will flip their account to the a2fa authentication type, then provide the QR code to be scanned. I realise the secret can be entered manually - but this should be avoided IMO due to the risk of typing errors etc.

The modifications I made to this module check all installed authentication plugins for actual authentication of the first factor (username/password) and then prompt for the second factor in a separate window.

Example of token request

I have implemented some further improvements since we went to production around logging the generation of the secret and viewing the QR code  via the Events system etc. 

We have this in Production now.

Planned future improvements:

  • Ability to self-manage 2fa authentication (enable, disable, regenerate secret)
  • Stored list of 10-ish emergency codes for lost/flat/forgotten devices.
  • Ability to set a browser as trusted (unsure how to do this as yet, thinking about browser fingerprinting but will investigate best practice first) so that you only have to provide the token on an untrusted machine.
  • Message (via configurable Moodle Messaging) to users when changes made to 2fa settings - email will be forced on for this for obvious reasons.
  • PHPUnit Tests
  • Behat Tests

Any other suggestions?

As this is only one of many things I maintain and develop here that list may take some time to be completed smile I'll seek permission to distribute everything we've developed on GitHub.

In reply to James McLean

Re: Two step authentication with Google Authenticator

by James McLean -

I've completed the planned improvements:

  • Self setup/management of 2fa
  • Implementation of 10 emergency tokens, provided in clear text only when the user sets up their own a2fa via the above method
  • Set a single browser as trusted (Option not available when using an emergency token)
  • Events for all steps of the enable/disable/setup process so appropriate listeners can be setup later.

No tests as yet, typically smile

Still planning on posting the changes to github at some point. Hopefully have the time for that in the next month or so.

In reply to James McLean

Re: Two step authentication with Google Authenticator

by pro-web at -

Hi James,


your plugin looks very promissing! great work!

did you have time for posting it to github already?

I would like to know, how you did the 2 step form authentification and how about possible security issues with that.

In reply to James McLean

Re: Two step authentication with Google Authenticator

by Andreas Riepl -

Hello James, for a project we are sorting out possibilites of 2fa - is there any way we can look at the code to see if this would fit in for us? You mentioned github. Do you have plans to release it there in the near future?

Regards

Andreas

In reply to Andreas Riepl

Re: Two step authentication with Google Authenticator

by James McLean -

Thanks for your interest Andreas.

I'm currently seeking approval from our security team to release the code - I will respond once I have heard back from them.

In reply to James McLean

Re: Two step authentication with Google Authenticator

by Adib Masumian -

Hi James,

Did you ever hear back from your security team? We're looking for a solid 2FA solution on our Moodle site, and are hoping that your code might hold the key.

Thanks!

In reply to Adib Masumian

Re: Two step authentication with Google Authenticator

by James McLean -

I never did unfortunately, and due to other priorities I wasn't able to chase it up. I have just completed a major task that has taken all my time for the past few months, so I might be able to follow up on this with the security team again this week. I'll let you know how I go. 

I really would like to get this out there as it works very very well and I'm actually quite proud of the modifications I made to make this work properly, but the decision is out of my hands unfortunately.

In reply to James McLean

Re: Two step authentication with Google Authenticator

by Sven Laudel -

Hello James,


i just want to ask if there is any progress to that topic?


Best regards

Sven

In reply to Sven Laudel

Re: Two step authentication with Google Authenticator

by Sven Laudel -

Hello James,


maybe you  missed my question. Did you make any progress on publishing your changes to moodle?

I really would like to implement 2 step authentication in our installation.


Best regards

Sven