diff options
author | Andrew <write@imaginarycode.com> | 2017-01-15 21:14:29 -0500 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2017-01-16 10:14:29 +0800 |
commit | 6dd096b7f08799ff27d9e34356fb1163ca10f388 (patch) | |
tree | e5823a27df5def081c9c39f5fac1424a81875f6d /modules/auth/user_form.go | |
parent | 64375d875b4d46a6081026290da8efd82c84b25f (diff) | |
download | gitea-6dd096b7f08799ff27d9e34356fb1163ca10f388.tar.gz gitea-6dd096b7f08799ff27d9e34356fb1163ca10f388.zip |
Two factor authentication support (#630)
* Initial commit for 2FA support
Signed-off-by: Andrew <write@imaginarycode.com>
* Add vendored files
* Add missing depends
* A few clean ups
* Added improvements, proper encryption
* Better encryption key
* Simplify "key" generation
* Make 2FA enrollment page more robust
* Fix typo
* Rename twofa/2FA to TwoFactor
* UNIQUE INDEX -> UNIQUE
Diffstat (limited to 'modules/auth/user_form.go')
-rw-r--r-- | modules/auth/user_form.go | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/modules/auth/user_form.go b/modules/auth/user_form.go index 1fa5b55c67..0f083a2e00 100644 --- a/modules/auth/user_form.go +++ b/modules/auth/user_form.go @@ -173,3 +173,23 @@ type NewAccessTokenForm struct { func (f *NewAccessTokenForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors { return validate(errs, ctx.Data, f, ctx.Locale) } + +// TwoFactorAuthForm for logging in with 2FA token. +type TwoFactorAuthForm struct { + Passcode string `binding:"Required"` +} + +// Validate valideates the fields +func (f *TwoFactorAuthForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors { + return validate(errs, ctx.Data, f, ctx.Locale) +} + +// TwoFactorScratchAuthForm for logging in with 2FA scratch token. +type TwoFactorScratchAuthForm struct { + Token string `binding:"Required"` +} + +// Validate valideates the fields +func (f *TwoFactorScratchAuthForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors { + return validate(errs, ctx.Data, f, ctx.Locale) +} |