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

Add trusted devices for 2FA #559

Merged
merged 65 commits into from
Jan 18, 2020

Conversation

bytehead
Copy link
Member

@bytehead bytehead commented Jul 7, 2019

This is a first draft of a trusted devices implementation for the Contao 2FA.
It uses the built-in stuff from the scheb/two-factor-bundle and I would consider this as a poor man implementation because it only sets a versioned cookie and does not care about user agent or the like.

My advice would be to store a GUID in a cookie or in local storage AND use the User-Agent header to identify and store the device server-side as a trusted device. As of this we can show a list of trusted devices to the user where he easily can remove the ones he wants (or even all).

We should send an email when a new device is flagged as a trusted device. If the user didn't add it, or if he doesn't recognize the device information, he can clear his trusted devices immediately.

ToDo:

  • Decide if cookie or local storage
  • Store a list of trusted devices server-side (e.g. User-Agent with cookie GUID or the like)
  • Send an e-mail if a new trusted device is added
  • Implement it as well for frontend users when [RTM] 2FA for frontend scope #363 is merged
  • Tests

2FA login screen:
Bildschirmfoto 2019-09-02 um 15 59 21

2FA backend module:
Bildschirmfoto 2019-09-02 um 16 00 39

2FA frontend module:
Bildschirmfoto 2019-09-02 um 22 32 05

@bytehead bytehead self-assigned this Jul 7, 2019
@bytehead
Copy link
Member Author

bytehead commented Jul 7, 2019

See #265 (comment) as well.

@bytehead bytehead added this to the 4.9 milestone Jul 7, 2019
@Toflar
Copy link
Member

Toflar commented Jul 8, 2019

Local storage and server side sounds like a super strange combination to me?! 😄

@bytehead
Copy link
Member Author

bytehead commented Jul 8, 2019

Why? We can use a combination of both to identify trusted devices.

@aschempp
Copy link
Member

aschempp commented Jul 8, 2019

How is the server supposed to validate data in the local storage?

@bytehead
Copy link
Member Author

bytehead commented Jul 8, 2019

🤦‍♂ Was too early in the morning 😂

@bytehead bytehead changed the title POC: 2FA Trusted Devices [POC] 2FA Trusted Devices Jul 9, 2019
@leofeyer leofeyer force-pushed the master branch 2 times, most recently from b2174a9 to 8728020 Compare July 10, 2019 16:39
@bytehead bytehead force-pushed the feature/2fa-trusted-devices branch 2 times, most recently from 9cc1497 to a780be2 Compare July 17, 2019 20:16
@bytehead bytehead changed the title [POC] 2FA Trusted Devices [RFC] 2FA Trusted Devices Sep 3, 2019
@bytehead bytehead marked this pull request as ready for review September 3, 2019 13:10
@bytehead bytehead force-pushed the feature/2fa-trusted-devices branch 2 times, most recently from 1567d04 to 75cff33 Compare September 6, 2019 06:03
@leofeyer leofeyer mentioned this pull request Nov 11, 2019
@richardhj
Copy link
Member

It uses the built-in stuff from the scheb/two-factor-bundle and I would consider this as a poor man implementation because it only sets a versioned cookie and does not care about user agent or the like.

A cookie can be set/modified client-side, but the same is for the User-Agent. Why is checking for both cookie and user-agent considered as more secure then?
If you update your Firefox from version 70 to 72, is this still considered as the same trusted device?

@aschempp
Copy link
Member

I would assume the cookie is sort of signed to prevent modification. As you can see in the screen shot, only the browser name is shown but not the version, so that should not be a problem?

@bytehead bytehead force-pushed the feature/2fa-trusted-devices branch 2 times, most recently from 1080920 to 4b7cb34 Compare December 5, 2019 14:51
@bytehead bytehead changed the title [RFC] 2FA Trusted Devices [WIP] 2FA Trusted Devices Dec 9, 2019
@bytehead bytehead force-pushed the feature/2fa-trusted-devices branch 2 times, most recently from 8a8f331 to 064f590 Compare December 23, 2019 11:13
aschempp
aschempp previously approved these changes Jan 17, 2020
aschempp
aschempp previously approved these changes Jan 18, 2020
leofeyer
leofeyer previously approved these changes Jan 18, 2020
@leofeyer leofeyer changed the title [RFC] 2FA Trusted Devices Add trusted devices for 2FA Jan 18, 2020
@leofeyer leofeyer merged commit b6d81c4 into contao:master Jan 18, 2020
@leofeyer
Copy link
Member

Thanks a lot for your hard work @bytehead.

@bytehead bytehead deleted the feature/2fa-trusted-devices branch January 18, 2020 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants