-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Enforce two-factor auth (2FA: TOTP or WebAuthn) #34187
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
base: main
Are you sure you want to change the base?
Conversation
143aa29
to
2ce924b
Compare
2ce924b
to
112a7f1
Compare
3c81bf5
to
f05976c
Compare
f05976c
to
3804e6c
Compare
twoFactorAuth := sec.Key("TWO_FACTOR_AUTH").String() | ||
switch twoFactorAuth { | ||
case "": | ||
case "enforced": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
enforced
sounds like user cannot visit anything except verify 2FA but now the user can visit basic pages. Maybe user another name to keep consistent? And in the future, it may supports more modes like read-only
, only-important-operation
and etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the enforced
name is good enough. The major purpose of Gitea users is to access repositories.
read-only
and only-important-operation
are too wordy and more unclear.
This config option is "string enum" based, so there are always chances to choose better names in the future without breaking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this configuration could be extend in the future so that the name should match it's behaviour. The current behaviour will display dashboard, explores but all repositories related operations will require two factor verify. So that the name enforced
is unclear. Maybe some name like repository-operation
is better. The enforced
sounds like even login will require two factor veirfy.
only-important-operation
means a default status like what Github did, the two factor verify will be prompted only when change password or change some important informations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You decide, feel free to edit this PR directly
type LoginSource struct { | ||
TwoFactorPolicy string `xorm:"two_factor_policy NOT NULL DEFAULT ''"` | ||
} | ||
err := x.Sync(new(LoginSource)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use SyncWithOptions
to avoid index
sync.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand the details. Feel free to edit directly and document it
Fix #880
Design:
security.TWO_FACTOR_AUTH
.