mirror of
https://github.com/go-gitea/gitea.git
synced 2026-12-05 23:14:52 +01:00
Adds the [RFC 8628](https://datatracker.ietf.org/doc/html/rfc8628) device authorization flow to the built-in OAuth2 provider, so CLI tools like `gt` can sign in on machines without a browser. The tool shows a short code, which the user enters at `/login/oauth/device` in any browser to approve the sign-in. Public OAuth2 applications opt in individually, and the built-in `git-credential-oauth`, Git Credential Manager and `gt` applications have it enabled. `[oauth2] ENABLE_DEVICE_FLOW` turns the flow off for the whole instance and `DEVICE_FLOW_EXPIRATION_TIME` sets the code lifetime. Each device sign-in gets its own grant, which can be revoked separately. <img width="516" height="255" alt="Code entry" src="https://github.com/user-attachments/assets/94461417-bba7-491a-9aa7-bcd09b5518c4" /> <img width="516" height="302" alt="Consent" src="https://github.com/user-attachments/assets/515cd92c-499a-40a9-9d17-cc6765ca6acf" /> <img width="516" height="161" alt="Authorization complete" src="https://github.com/user-attachments/assets/4dce0d8a-6419-437b-89b7-fde3be152f35" /> <img width="600" alt="Device grant in the authorized applications list" src="https://github.com/user-attachments/assets/6a144521-33a0-4f35-b012-56ad4d4f81f1" /> Fixes: https://github.com/go-gitea/gitea/issues/27309 Docs: https://gitea.com/gitea/docs/pulls/672 Assisted-by: Claude Code:claude-fable-5-2 Assisted-by: OpenAI Codex:gpt-6.2-astra --------- Co-authored-by: bircni <bircni@icloud.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: techknowlogick <164197+techknowlogick@users.noreply.github.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: silverwind <me@silverwind.io>