diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2022-01-14 23:03:31 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-14 16:03:31 +0100 |
commit | 35c3553870e35b2e7cfcc599645791acda6afcef (patch) | |
tree | 0ad600c2d1cd94ef12566482832768c9efcf8a69 /routers/web/auth/auth.go | |
parent | 8808293247bebd20482c3c625c64937174503781 (diff) | |
download | gitea-35c3553870e35b2e7cfcc599645791acda6afcef.tar.gz gitea-35c3553870e35b2e7cfcc599645791acda6afcef.zip |
Support webauthn (#17957)
Migrate from U2F to Webauthn
Co-authored-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Diffstat (limited to 'routers/web/auth/auth.go')
-rw-r--r-- | routers/web/auth/auth.go | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/routers/web/auth/auth.go b/routers/web/auth/auth.go index b9765abfb5..d6b3635584 100644 --- a/routers/web/auth/auth.go +++ b/routers/web/auth/auth.go @@ -236,14 +236,14 @@ func SignInPost(ctx *context.Context) { return } - // Check if the user has u2f registration - hasU2Ftwofa, err := auth.HasU2FRegistrationsByUID(u.ID) + // Check if the user has webauthn registration + hasWebAuthnTwofa, err := auth.HasWebAuthnRegistrationsByUID(u.ID) if err != nil { ctx.ServerError("UserSignIn", err) return } - if !hasTOTPtwofa && !hasU2Ftwofa { + if !hasTOTPtwofa && !hasWebAuthnTwofa { // No two factor auth configured we can sign in the user handleSignIn(ctx, u, form.Remember) return @@ -254,7 +254,7 @@ func SignInPost(ctx *context.Context) { return } - // User will need to use 2FA TOTP or U2F, save data + // User will need to use 2FA TOTP or WebAuthn, save data if err := ctx.Session.Set("twofaUid", u.ID); err != nil { ctx.ServerError("UserSignIn: Unable to set twofaUid in session", err) return @@ -268,7 +268,7 @@ func SignInPost(ctx *context.Context) { if hasTOTPtwofa { // User will need to use U2F, save data if err := ctx.Session.Set("totpEnrolled", u.ID); err != nil { - ctx.ServerError("UserSignIn: Unable to set u2fEnrolled in session", err) + ctx.ServerError("UserSignIn: Unable to set WebAuthn Enrolled in session", err) return } } @@ -279,8 +279,8 @@ func SignInPost(ctx *context.Context) { } // If we have U2F redirect there first - if hasU2Ftwofa { - ctx.Redirect(setting.AppSubURL + "/user/u2f") + if hasWebAuthnTwofa { + ctx.Redirect(setting.AppSubURL + "/user/webauthn") return } |