OAuth module missing special handling for loopback redirect URI #9626

Closed
opened 2025-11-02 08:44:50 -06:00 by GiteaMirror · 0 comments
Owner

Originally created by @hickford on GitHub (Sep 28, 2022).

OAuth RFC https://datatracker.ietf.org/doc/html/rfc8252#section-7.3 describes special handling for loopback redirect URIs, in particular that the port need not match.

The authorization server MUST allow any port to be specified at the
time of the request for loopback IP redirect URIs
, to accommodate
clients that obtain an available ephemeral port from the operating
system at the time of the request.

This is vital for local apps, but the behaviour is missing in Gitea.
Relevant code 5a3b9ac875/models/auth/oauth2.go (L58-L60)

GitHub implements this behaviour https://docs.github.com/en/developers/apps/building-oauth-apps/authorizing-oauth-apps#localhost-redirect-urls

The redirect_uri does not need to match the port specified in the callback url for the app.

Originally created by @hickford on GitHub (Sep 28, 2022). OAuth RFC https://datatracker.ietf.org/doc/html/rfc8252#section-7.3 describes special handling for loopback redirect URIs, in particular that **the port need not match**. > **The authorization server MUST allow any port to be specified at the time of the request for loopback IP redirect URIs**, to accommodate clients that obtain an available ephemeral port from the operating system at the time of the request. This is vital for local apps, but the behaviour is missing in Gitea. Relevant code https://github.com/go-gitea/gitea/blob/5a3b9ac875b06e0810aa2100ee0caae4efe0b4ce/models/auth/oauth2.go#L58-L60 GitHub implements this behaviour https://docs.github.com/en/developers/apps/building-oauth-apps/authorizing-oauth-apps#localhost-redirect-urls > The redirect_uri does not need to match the port specified in the callback url for the app.
GiteaMirror added the type/bug label 2025-11-02 08:44:50 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#9626