mirror of
https://github.com/RayLabsHQ/gitea-mirror.git
synced 2026-11-28 17:48:28 +01:00
feat(auth): 2FA with an authenticator app (#552) Accounts with a password can turn on 2FA from the account menu. Setup asks for the password, shows a QR code and the key to type by hand, checks one code from the app, then shows ten backup codes to copy or download. Login with a password then asks for the app's code or a backup code, with an opt-in "trust this device for 30 days". When 2FA is on, the menu shows On and opens Manage 2FA for new backup codes or turning it off. Built on Better Auth's twoFactor plugin: migration 0025 adds users.two_factor_enabled and the two_factors table. The plugin only gates /sign-in/email, so SSO, header auth and API keys are unchanged. It is listed before oauthProvider so a password alone never mints an OAuth authorization code; tests fail if the order is swapped. bun run disable-2fa -- --email=... turns it off for someone who lost both the phone and the backup codes, and forgets trusted browsers. Also fixes a race in the login form: it always sent the browser to the dashboard after one second, which cut off an app signing in through Gitea Mirror when its callback or the consent page took longer than that.