mirror of
https://github.com/go-gitea/gitea.git
synced 2026-03-12 02:24:21 -05:00
Ability to enforce two-factor authentication #333
Closed
opened 2025-11-02 03:18:58 -06:00 by GiteaMirror
·
35 comments
No Branch/Tag Specified
main
release/v1.25
release/v1.24
release/v1.23
release/v1.22
release/v1.21
release/v1.20
release/v1.19
release/v1.18
release/v1.17
release/v1.16
release/v1.15
release/v1.14
release/v1.13
release/v1.12
release/v1.11
release/v1.10
release/v1.9
release/v1.8
v1.25.3
v1.25.2
v1.25.1
v1.25.0
v1.24.7
v1.25.0-rc0
v1.26.0-dev
v1.24.6
v1.24.5
v1.24.4
v1.24.3
v1.24.2
v1.24.1
v1.24.0
v1.23.8
v1.24.0-rc0
v1.25.0-dev
v1.23.7
v1.23.6
v1.23.5
v1.23.4
v1.23.3
v1.23.2
v1.23.1
v1.23.0
v1.23.0-rc0
v1.24.0-dev
v1.22.6
v1.22.5
v1.22.4
v1.22.3
v1.22.2
v1.22.1
v1.22.0
v1.23.0-dev
v1.22.0-rc1
v1.21.11
v1.22.0-rc0
v1.21.10
v1.21.9
v1.21.8
v1.21.7
v1.21.6
v1.21.5
v1.21.4
v1.21.3
v1.21.2
v1.20.6
v1.21.1
v1.21.0
v1.21.0-rc2
v1.21.0-rc1
v1.20.5
v1.22.0-dev
v1.21.0-rc0
v1.20.4
v1.20.3
v1.20.2
v1.20.1
v1.20.0
v1.19.4
v1.21.0-dev
v1.20.0-rc2
v1.20.0-rc1
v1.20.0-rc0
v1.19.3
v1.19.2
v1.19.1
v1.19.0
v1.19.0-rc1
v1.20.0-dev
v1.19.0-rc0
v1.18.5
v1.18.4
v1.18.3
v1.18.2
v1.18.1
v1.18.0
v1.17.4
v1.18.0-rc1
v1.19.0-dev
v1.18.0-rc0
v1.17.3
v1.17.2
v1.17.1
v1.17.0
v1.17.0-rc2
v1.16.9
v1.17.0-rc1
v1.18.0-dev
v1.16.8
v1.16.7
v1.16.6
v1.16.5
v1.16.4
v1.16.3
v1.16.2
v1.16.1
v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1
v1.3.2
v1.3.1
v1.3.0
v1.3.0-rc2
v1.3.0-rc1
v1.2.3
v1.2.2
v1.2.1
v1.2.0
v1.2.0-rc3
v1.2.0-rc2
v1.1.4
v1.2.0-rc1
v1.1.3
v1.1.2
v1.1.1
v1.1.0
v1.0.2
v1.0.1
v1.0.0
v0.9.99
Labels
Clear labels
$20
$250
$50
$500
backport/done
💎 Bounty
docs-update-needed
good first issue
hacktoberfest
issue/bounty
issue/confirmed
issue/critical
issue/duplicate
issue/needs-feedback
issue/not-a-bug
issue/regression
issue/stale
issue/workaround
lgtm/need 2
modifies/api
modifies/translation
outdated/backport/v1.18
outdated/theme/markdown
outdated/theme/timetracker
performance/bigrepo
performance/cpu
performance/memory
performance/speed
pr/breaking
proposal/accepted
proposal/rejected
pr/wip
pull-request
reviewed/wontfix
💰 Rewarded
skip-changelog
status/blocked
topic/accessibility
topic/api
topic/authentication
topic/build
topic/code-linting
topic/commit-signing
topic/content-rendering
topic/deployment
topic/distribution
topic/federation
topic/gitea-actions
topic/issues
topic/lfs
topic/mobile
topic/moderation
topic/packages
topic/pr
topic/projects
topic/repo
topic/repo-migration
topic/security
topic/theme
topic/ui
topic/ui-interaction
topic/ux
topic/webhooks
topic/wiki
type/bug
type/deprecation
type/docs
type/enhancement
type/feature
type/miscellaneous
type/proposal
type/question
type/refactoring
type/summary
type/testing
type/upstream
Mirrored from GitHub Pull Request
Milestone
No items
No Milestone
Projects
Clear projects
No project
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/gitea#333
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @minecrafter on GitHub (Feb 9, 2017).
Currently, two-factor authentication is optional. It would be nice if we had a global (site) or per-organization setting to enforce two-factor authentication.
@bkcsoft commented on GitHub (Feb 12, 2017):
As for per-organization change, I propose that if you login w/o 2FA enabled you're account will be redirected to
/user/settings/two_factorwith an option to leave the "offending" organization :)Obviously the 2FA-page would need an update to list orgs (that require 2FA) to leave if you disable 2FA.
@elvarb commented on GitHub (Dec 12, 2017):
This feature is very important for overall security.
Best way to implement it would be to have it a part of Authenticators settings, that way you can for example require 2fa for ldap imported users while having it optional for local users.
@yarumair commented on GitHub (Dec 3, 2018):
Just wondering if this is implemented as i think its pretty nice feature to have within an organization
@stale[bot] commented on GitHub (Feb 3, 2019):
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions.
@9thWonderAgency commented on GitHub (Jul 25, 2019):
I am but a simple Gitea user, would like to voice that my organization would also find this a very important feature. Please!
@zeripath commented on GitHub (Jan 29, 2020):
Ok if we're gonna do this we need to think about what happens if a user tries to login without two factor.
Is it that they get redirected immediately to the enroll 2fa page similar to the must change password screen?
@tomposmiko commented on GitHub (Apr 17, 2020):
It would already be enough if we could enforce the setting for each user one by one.
Would that be easier to implement?
@MOZGIII commented on GitHub (Jul 16, 2020):
That would be reasonable.
It is also a good idea to allow specifying a time duration since registration until the 2FA requirement starts blocking the access. I.e. you can do some limited things until this 2FA enforcement timeout without 2FA.
@njsubedi commented on GitHub (Dec 29, 2020):
@zeripath I think the best way is to redirect to the 2FA Settings page, and show a message "Your administrator has made 2FA mandatory for all users who use $AUTHENTICATION_SOURCE authentication."
@andreas-bulling commented on GitHub (Oct 30, 2022):
Any updates on this? This feature would also be super important for me. Thanks!
@lunny commented on GitHub (Oct 30, 2022):
#16880 try to fix this but closed.
@wxiaoguang commented on GitHub (Oct 30, 2022):
That's an impossible task at the moment.
See https://github.com/go-gitea/gitea/issues/13606#issuecomment-947320267
But if you are using Gitea for private usage, you can take the PR https://github.com/go-gitea/gitea/pull/16880 (build your own Gitea) , it works well for that case. I am keeping sync my 2FA branch with main branch.
I closed https://github.com/go-gitea/gitea/pull/16880 to reduce invalid pending PRs and avoid unnecessary CI resource consumption.
@OdinVex commented on GitHub (Jan 13, 2023):
Would like the ability to easily specify the algorithm, digit count, and period across the server.
@Mikaela commented on GitHub (Feb 22, 2023):
Shouldn't this have been implemented before https://github.com/go-gitea/gitea/pull/22999 and https://github.com/go-gitea/gitea/pull/23023?
If the organisation requires 2FA, then everyone has it enabled and there is no question about it.
@lunny commented on GitHub (Feb 22, 2023):
Users could enable 2FA in their settings, but no option for the organization/team to enforce that.
@brechtvl commented on GitHub (Feb 23, 2023):
For organizations, I think it would be better to make the member somehow inactive until they enable 2FA. And then users can add 2FA or remove themselves from the organization when they want to.
Organizations shouldn't have the power to disrupt a user's login in my opinion. Also for API application access, one organization adding an 2FA requirement should not block access entirely, so you would need a concept of inactive membership in only some organizations anyway.
Or just removing the member of course, it's just a bit less convenient. Then the member can not fix the problem themselves but rather has to ask the owner to add them again.
@ruess commented on GitHub (May 22, 2023):
To me this is a logical and easy way to implement this. We don't have to mess with the current login system, but can simply restrict the user's capabilities until they enable 2FA.
@OdinVex commented on GitHub (May 22, 2023):
I think it might be good to hide the fact that 2FA isn't enabled for a user from other entities, so that Organizations can't probe accounts to figure out if they have 2FA (at least until they become a member with 2FA?)? Rogue Organizations, I'm thinking.
@csteaderman commented on GitHub (Aug 25, 2023):
Any status/progress on this issue?
@wxiaoguang commented on GitHub (Aug 25, 2023):
No, but you could build your own binary by my patch #16880 (there are design details) / https://github.com/wxiaoguang/gitea/tree/enforce-2fa
@csteaderman commented on GitHub (Aug 25, 2023):
Does your patch enforce site wide 2FA, or is it per-organization? Is there a PR to merge this into the main source?
@rudolphfroger commented on GitHub (Mar 9, 2024):
Apparently this feature is now advertised as a Gitea Enterprise edition advantage, so I assume this feature won't happen in the open source edition?
@prologic commented on GitHub (Mar 9, 2024):
Why would this be an Enterprise-only feature?
@rudolphfroger commented on GitHub (Mar 9, 2024):
Sorry, I didn't include a reference: https://blog.gitea.com/gitea-enterprise/
@techknowlogick commented on GitHub (Mar 12, 2024):
It will certainly be added to the project, or at the very least, I hope it will be, as any contribution needs to follow the contribution guidelines and the process outlined in the document. The status of the code in the commercial offering from CommitGo, is that it was developed for a customer, and we are working with them to ensure that the code can and does meet the DCO that Gitea requires of any contribution. I believe the PR linked above can still be applied to a Gitea build, and will meet your needs. From the comments on it, a different approach and changes elsewhere in the system may be the path forward that the project will take, as a proposal for a working group to discuss was suggested.
@prologic commented on GitHub (Mar 13, 2024):
Good to hear 👌 I may have to increase my monthly donations 😅
@11Firefox11 commented on GitHub (Sep 10, 2024):
Are there any news on this?
@rudolphfroger even better reference: https://docs.gitea.com/enterprise/features/mandatory-2fa .
@warasilapm commented on GitHub (Sep 11, 2024):
+1
This is a feature we'd all like to see outside of Enterprise.
@ggarret314 commented on GitHub (Dec 18, 2024):
My work wanted this as a feature. I took what @wxiaoguang made in #16880 and updated it for the most recently released version of Gitea (v1.22.6), plus and minus a few changes. I have it in a branch in my own repo here: https://github.com/ggarret314/gitea/tree/v1.22.6-enforce2fa
I see the comments made in #13606(comment), but I still don't understand how this can be a requested feature with such a simple goal for as long as it has been without any implementation. If I have more time to learn Gitea's codebase and the PR process, I'll try to re-up this issue. Until then, I'll try to take the guidon from wxiaoguang and update current versions of Gitea with enforced 2fa ability.
@eeyrjmr commented on GitHub (Dec 18, 2024):
why so long? well it takes someone to implement it. There is limited coders and even fewer reviewers and also different people have different opinions on what is important... an infinite number of people stating an infinite number of features is the most important means that it won't get done
Luckily this feature has been implemented and is included within 1.23 (release candidate). if you cross to the bottom of the issue you linked #13606 you will see @wxiaoguang committed to it and implemented it in https://github.com/go-gitea/gitea/pull/32687
@ggarret314 commented on GitHub (Dec 18, 2024):
I looked through the commits, the problem being resolved there is separate from what I'm solving in my fork (as well as what @wxiaoguang was solving in his #16880 changes). I'm not trying to stop password-based login, I just want 2FA enforced, which is what the open issue this comment thread is about. My solution doesn't solve exactly what the initial commenter wants with separate settings for global / organizational enforcement, but it does enforce 2FA to be enabled globally across the site, using the 2FA solution provided inside Gitea. My apologies if it was confusing why I cross referenced a different issue; I referenced his comment because he mentioned it on why enforcing 2FA (this issue) is hard to implement.
@wxiaoguang commented on GitHub (Dec 19, 2024):
I didn't continue " (Discontinued) Enforce two-factor authentication #16880 " because it is far from ideal to be integrated into Gitea (I am still using it in my private instance). Ideally it should be an org-level config option and it should also work with different auth-source.
@wxiaoguang commented on GitHub (Apr 12, 2025):
Let's try it again in 1.24: Enforce two-factor auth (2FA: TOTP or WebAuthn) #34187
@bendem commented on GitHub (May 2, 2025):
I don't see documentation for this, how does it work in conjunction with auth sources? I couldn't quite understand from the code. What happens if I have 3 user sources (ldap, oidc, local)? In my case, OIDC ensures 2FA is used so I would only want it enabled for LDAP and local.
@wxiaoguang commented on GitHub (May 2, 2025):
Hmm yes, no document yet.
I guess it might be like this:
app.ini:security.TWO_FACTOR_AUTH=enforced