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

Enable OTP 2FA #3798

Merged
merged 15 commits into from
Jan 30, 2019
Merged

Enable OTP 2FA #3798

merged 15 commits into from
Jan 30, 2019

Conversation

j0k3r
Copy link
Member

@j0k3r j0k3r commented Dec 2, 2018

Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Documentation needed
Translation missing
CHANGELOG.md no
License MIT

Fixes #2822

Moved stuff from the "reset area" to a dedicated tab. Might be better.

screen 2018-12-02 a 17 37 13

Enable OTP 2FA:

  • Update SchebTwoFactorBundle to version 3
  • Enable Google 2fa on the bundle
  • Disallow ability to use both email and google as 2fa
  • use $this->addFlash shortcut instead of $this->get('session')->getFlashBag()->add
  • update admin to be able to enable/reset the 2fa

Here is a gif when enabling OTP app:

2fa

  • Backup codes
  • Hash backup codes
  • Replace "Google Authenticator"
  • Ability to test a generated code

@j0k3r j0k3r added this to the 2.4.0 milestone Dec 2, 2018
@j0k3r j0k3r requested review from Kdecherf and tcitworld December 2, 2018 16:39
Copy link
Member

@Kdecherf Kdecherf left a comment

Choose a reason for hiding this comment

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

Nice 👍

However I have two notes:

Copy link
Member

@tcitworld tcitworld left a comment

Choose a reason for hiding this comment

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

Agreed with @Kdecherf and these two extra remarks:

  • Put the QR code more upfront (people should use it more than the text code)
  • From an UX PoV most services which offer 2FA will ask you to confirm 2FA is working with a code generated by the 2FA app, is this doable here ?

@virtadpt
Copy link

virtadpt commented Dec 2, 2018

This is probably a dumb question, but will this interfere with existing app integrations (e.g., Android) if we upgrade to get this functionality and turn it on?

@tcitworld
Copy link
Member

@virtadpt It will indeed.

@j0k3r
Copy link
Member Author

j0k3r commented Dec 3, 2018

@virtadpt the email 2fa is already available. You can give a try.
We added the OTP option in that PR.

@j0k3r
Copy link
Member Author

j0k3r commented Dec 6, 2018

@Kdecherf done
@tcitworld I moved the QR code upfront. About the code validation I agree, but I don't really know how to better integrate it. I think I'll let it for later and create an issue about that.

I have question regarding the OTP secret & backup codes: should the administrator be able to view them? Like:
image

@Kdecherf
Copy link
Member

Kdecherf commented Dec 7, 2018

@j0k3r imo administrators must not see secret keys and backup codes. Also, backup codes must not be saved somewhere: they are shown only once.

Here is a side-note on the text of checkbox for OTP: we should avoid "Google" as well here.

@j0k3r
Copy link
Member Author

j0k3r commented Dec 7, 2018

Backup codes are saved in the database, so we can check if the given code is valid (and then remove it from the backup codes).
Ok I agree about secret & codes from the admin.

@Kdecherf
Copy link
Member

Kdecherf commented Dec 7, 2018

Oh, well, I saw it differently in my mind :D You're right.

@tcitworld
Copy link
Member

Backup codes are saved in the database, so we can check if the given code is valid (and then remove it from the backup codes).

Is there any reason why we don't hash them inside database ?

@j0k3r
Copy link
Member Author

j0k3r commented Dec 7, 2018

@tcitworld None. We can hash backup code.
But the secret code generated for the OTP app can't be hashed. Which means, an admin can still configure its OTP app with the secret from a given user using the secret code. 😕

@noplanman
Copy link

Just popping in to ask about the status on this. Would love to see this merged 😊

@j0k3r
Copy link
Member Author

j0k3r commented Jan 14, 2019

I need to get back on this to:

  • remove info for the admin POV
  • add a better OTP validation process

@j0k3r j0k3r force-pushed the update-two-factor-bundle branch from b276da4 to 111fd61 Compare January 15, 2019 09:07
@j0k3r
Copy link
Member Author

j0k3r commented Jan 15, 2019

Rebased against the updated 2.4 branch.

@j0k3r j0k3r force-pushed the update-two-factor-bundle branch from 111fd61 to 0ad4436 Compare January 18, 2019 15:55
@j0k3r
Copy link
Member Author

j0k3r commented Jan 18, 2019

I've updated how it works now.
We can verify a generated code before enabling it.

Just one thing left: hashing backup codes.

@j0k3r
Copy link
Member Author

j0k3r commented Jan 19, 2019

Regarding my last comment I'm wondering if we really should hash backup code in the database? 🤔

@j0k3r j0k3r requested review from tcitworld and Kdecherf January 19, 2019 19:08
@tcitworld
Copy link
Member

Regarding my last comment I'm wondering if we really should hash backup code in the database? 🤔

My opinion would be to check how popular libraries / softs handle this.

@j0k3r
Copy link
Member Author

j0k3r commented Jan 19, 2019

GitHub allow you to view your backup codes. So I guess they didn't hash them.

@techexo
Copy link
Contributor

techexo commented Jan 19, 2019

I have at least two services (Ubisoft and I think Microsoft) telling me when activating otp "this is your code and don't lose them". So they probably hash them.

Kdecherf
Kdecherf previously approved these changes Jan 20, 2019
Copy link
Member

@Kdecherf Kdecherf left a comment

Choose a reason for hiding this comment

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

LGTM

As for the hashing of backup codes, we could ignore it as for now considering that the rest of the database is not encrypted.

Copy link
Member

@tcitworld tcitworld left a comment

Choose a reason for hiding this comment

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

It seems quite easy to me to have backups codes hashed, so I'd still vote for this before merging it.

The whole point of having backup codes is not being able to see them again once connected, so that if someone gets access to your session on a computer you just left, he's not able to get access to them.

j0k3r added 13 commits January 23, 2019 13:28
- Update SchebTwoFactorBundle to version 3
- Enable Google 2fa on the bundle
- Disallow ability to use both email and google as 2fa
- Update Ocramius Proxy Manager to handle typed function & attributes (from PHP 7)
- use `$this->addFlash` shortcut instead of `$this->get('session')->getFlashBag()->add`
- update admin to be able to create/reset the 2fa
Replace “Google Authenticator” by “Google Authenticator, Authy or FreeOTP” in all text.

Translate how to use the code / qr code.
Also remove the forced `server_version` from dbal config to avoid an
hard overriding across all database.
And add a step to validate a generated code from the OTP app
@j0k3r
Copy link
Member Author

j0k3r commented Jan 23, 2019

Rebased because of conflicts.

@j0k3r j0k3r dismissed tcitworld’s stale review January 23, 2019 13:54

BackupCodes are now hashed

@j0k3r j0k3r requested review from tcitworld and Kdecherf January 23, 2019 13:54
@Kdecherf
Copy link
Member

It seems quite easy to me to have backups codes hashed, so I'd still vote for this before merging it.

The whole point of having backup codes is not being able to see them again once connected, so that if someone gets access to your session on a computer you just left, he's not able to get access to them.

I didn't think about that vector, you make a point.

@Kdecherf
Copy link
Member

I'll review and test the workflow tomorrow

Copy link
Member

@Kdecherf Kdecherf left a comment

Choose a reason for hiding this comment

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

"tomorrow" 6 days ago 👀

looks good 👍

@Kdecherf Kdecherf merged commit 2e5b3fa into 2.4 Jan 30, 2019
@Kdecherf Kdecherf deleted the update-two-factor-bundle branch January 30, 2019 00:02
@j0k3r j0k3r mentioned this pull request May 29, 2019
@j0k3r j0k3r mentioned this pull request Jun 5, 2019
@j0k3r j0k3r mentioned this pull request Oct 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants