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

Allow U2F 2FA without TOTP #11573

Merged
merged 9 commits into from
Nov 8, 2021
Merged

Allow U2F 2FA without TOTP #11573

merged 9 commits into from
Nov 8, 2021

Conversation

kdomanski
Copy link
Contributor

@kdomanski kdomanski commented May 23, 2020

This change enables the usage of U2F without being forced to enroll an TOTP authenticator.
The /user/auth/u2f has been changed to hide the "use TOTP instead" bar if TOTP is not enrolled.

Fixes #5410
Fixes #17495

@kdomanski

This comment has been minimized.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label May 23, 2020
@6543

This comment has been minimized.

@kdomanski

This comment has been minimized.

@jonasfranz
Copy link
Member

IMHO We should enforce totp since u2f is currently only supported in a few browsers.

@silverwind
Copy link
Member

Why unconditionally load the JS? Can we not gate it behind some variable that only loads it on pages where it's needed? As it's right now it will load on every single page which I find quite bad.

@kdomanski
Copy link
Contributor Author

@jonasfranz It's not possible to set up U2F in a non-supporting browser in the first place.

@kdomanski
Copy link
Contributor Author

@silverwind If I understand correctly, currently the U2F js would also load on every page, as long as the user is enrolled in TOTP. The core issue seems to be that the loading of that file happens in the footer template.

To address this, I'd move the loading to security_u2f.tmpl and u2f.tmpl in another PR.

@6543
Copy link
Member

6543 commented May 23, 2020

what to do with the API since there is no auth for U2F there, so at least we should put a hint if U2F is enabled without TOTP, to interact with the API the user has to create a token itself

@kdomanski
Copy link
Contributor Author

Hmm, I didn't think about the API. Back to the drawing board.

@6543
Copy link
Member

6543 commented May 23, 2020

@kdomanski I think its fine we just have to inform the user ...

@rugk
Copy link
Contributor

rugk commented May 24, 2020

Thx for cc'ing, but I cannot review this PR as I don't know the technologies involved (Go etc.). That said, if it fixes #5410 as stated there, I'm happy the change get's into gitea. 😃

@kdomanski
Copy link
Contributor Author

Updated tests which were setting U2F on root user without enabling TOTP.

@kdomanski
Copy link
Contributor Author

@6543 Is it possible to use the API with login/password and TOTP? I couldn't find anything in the docs. I could add a hint in the body of the API unauthorized response, but it seems like it's orthogonal to this PR and belongs in another one.

@6543
Copy link
Member

6543 commented May 29, 2020

I would ad no hit to api 403 responce

and yes we should add add this to swagger docs #11667 (a other pull)

@6543
Copy link
Member

6543 commented May 29, 2020

but when adding a U2F key without an existing TOTP a hint on the UI could warn about API and account recovery etc ...

@jonasfranz
Copy link
Member

@kdomanski Many users are using multiple devices. I think we should require TOTP by default and make a configuration option to disable this requirement.

@IreneKnapp
Copy link

+1 to @jonasfranz's suggestion. From a security perspective the best practice on the user's side is to have two or more U2F devices, so that one can serve as a backup if the other is lost.

@rugk
Copy link
Contributor

rugk commented Jun 1, 2020

Then we would gain nothing, if you want a config, do the reverse: enable a config that requires TOTP before U2F.
No other website does require it like this.

We want U2F without TOTP. By default.

@kdomanski
Copy link
Contributor Author

Added a warning box that only appears when there's no TOTP enrollment.

@lafriks
Copy link
Member

lafriks commented Jun 9, 2020

@rugk imho github also allow u2f only if you have topt enrolled

@IreneKnapp
Copy link

Google also allows TOTP to be disabled. In fact, Google offers a mode for its high-risk users in which an account cannot be configured with TOTP, SMS, or other alternate forms of authentication. (Turning this mode off incurs a mandatory delay of several weeks, and may incur a requirement to present legal identification.)

@lafriks lafriks added the type/enhancement An improvement of existing functionality label Jun 9, 2020
@lafriks lafriks added this to the 1.13.0 milestone Jun 9, 2020
@kdomanski
Copy link
Contributor Author

@CirnoT @6543 Could you please review this?

Recording of the change in action:
Recording of the change in action

@CirnoT
Copy link
Contributor

CirnoT commented Jun 27, 2020

Aside from TOTP warning comment above I would also add additional warning whenever user has less than 2 U2F keys (second key as backup in case first is lost or breaks).

@@ -26,9 +26,7 @@
{{if .RequireMinicolors}}
<script src="{{StaticUrlPrefix}}/vendor/plugins/jquery.minicolors/jquery.minicolors.min.js"></script>
{{end}}
{{if .RequireU2F}}
Copy link
Contributor

@CirnoT CirnoT Jun 27, 2020

Choose a reason for hiding this comment

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

Why this removal here?

ref #11585

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Until #11585 is merged, this line completely prevents U2F from operating if the user doesn't have TOTP enrollments.

@@ -69,7 +69,6 @@
Minicolors: {{if .RequireMinicolors}}true{{else}}false{{end}},
SimpleMDE: {{if .RequireSimpleMDE}}true{{else}}false{{end}},
Tribute: {{if .RequireTribute}}true{{else}}false{{end}},
U2F: {{if .RequireU2F}}true{{else}}false{{end}},
Copy link
Contributor

Choose a reason for hiding this comment

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

Unnecessary, handled by #11585 and will cause conflict for zero benefit

@mrsdizzie mrsdizzie modified the milestones: 1.13.0, 1.14.0 Sep 11, 2020
@lunny lunny modified the milestones: 1.14.0, 1.15.0 Jan 27, 2021
@6543
Copy link
Member

6543 commented Jan 27, 2021

since now a admin can reset 2FA it's less concerning that user can loose access to it's account

routers/user/auth.go Outdated Show resolved Hide resolved
templates/user/settings/security_u2f.tmpl Show resolved Hide resolved
@techknowlogick techknowlogick modified the milestones: 1.15.0, 1.16.0 Jun 15, 2021
@kdomanski kdomanski closed this Aug 22, 2021
@rugk
Copy link
Contributor

rugk commented Aug 22, 2021

Why was this closed?

@go-gitea go-gitea locked and limited conversation to collaborators Oct 19, 2021
@zeripath zeripath reopened this Nov 6, 2021
@zeripath zeripath removed the issue/confirmed Issue has been reviewed and confirmed to be present or accepted to be implemented label Nov 6, 2021
Copy link
Contributor

@zeripath zeripath left a comment

Choose a reason for hiding this comment

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

Apologies for the late review. I've updated this to head and I think this is now ready

@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Nov 6, 2021
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Nov 8, 2021
@6543
Copy link
Member

6543 commented Nov 8, 2021

🚀

@6543 6543 merged commit 021df29 into go-gitea:main Nov 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/enhancement An improvement of existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

UI to setup FIDO keys is not available until after setting up TOTP Allow U2F 2FA when TOTP is disabled