fix(oauth): allow ephemeral loopback redirect ports - #2705
Open
qtjg wants to merge 2 commits into
Open
Conversation
Updated comments for clarity and added validation for loopback redirect URIs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This updates the OAuth 2.1 authorization endpoint to support RFC 8252 loopback-interface redirect URIs with ephemeral ports.
What changed
httpredirect to use a different port when the registered and requested hosts are the same loopback host:localhost,127.0.0.1, or::1.This addresses issue #2703. RFC 8252 Section 7.3 requires authorization servers to allow any port for loopback IP redirect URIs so native clients can bind an ephemeral local port.
Validation
go test ./internal/api/oauthserver -run '^TestIsValidLoopbackRedirectURI$' -count=1— passed.go vet ./internal/api/oauthserver— passed.go test ./internal/api/oauthserver -count=1— the package reached its database-backed tests, but the sandbox has no PostgreSQL service listening onlocalhost:5432, so those suites could not run here (connect: connection refused).The implementation was also reviewed against the repository’s existing redirect URI validation rules and preserves exact matching outside the RFC 8252 loopback exception.