Skip to content

fix(authentication-oauth): allow any port on loopback OAuth origins - #3699

Merged
marshallswain merged 2 commits into
dovefrom
fix/oauth-loopback-origin-ports
Aug 11, 2026
Merged

fix(authentication-oauth): allow any port on loopback OAuth origins#3699
marshallswain merged 2 commits into
dovefrom
fix/oauth-loopback-origin-ports

Conversation

@marshallswain

@marshallswain marshallswain commented Aug 11, 2026

Copy link
Copy Markdown
Member

Summary

  • Fixes local OAuth redirects after the 5.0.40 exact-origin security change (fix(oauth): Patch open redirect and origin validation #3653 / fix(authentication-oauth): Use actual URL origin comparison for origin check #3676), which rejected common setups where the frontend runs on a different port than the configured origin (e.g. http://localhost vs http://localhost:5173).
  • For local machine hosts only (localhost, 127.0.0.1, ::1, 0.0.0.0), match on scheme + host and ignore port.
  • On a successful match, redirect using the referer origin so the access token returns to the correct local port.
  • Non-loopback hosts still require an exact WHATWG origin match (security fix preserved). Config entries are also normalized via URL (trailing slash / default port / path on the config string no longer break matching).
  • Clearer NotAuthenticated errors: report the normalized referer origin, list configured origins, and hint about ports and loopback matching.

Closes #3684

Test plan

  • npm test --workspace @feathersjs/authentication-oauth (34 passing)
  • Loopback any-port allow for localhost, 127.0.0.1, ::1, 0.0.0.0
  • Redirect uses referer port, not config port
  • localhost127.0.0.1
  • Non-loopback still requires exact port
  • Scheme must still match on loopback
  • Rejection errors include configured origins and a port/loopback hint
  • Existing open-redirect / prefix-bypass security tests still pass

Exact origin matching from the 5.0.40 security fix rejected common local
dev setups where the frontend runs on a different port than the configured
origin (e.g. http://localhost vs http://localhost:5173).

For localhost, 127.0.0.1, and ::1 only, match on scheme + host and ignore
port, then redirect using the referer origin so the token returns to the
correct local port. Non-loopback hosts still require an exact origin match.

Closes #3684
@marshallswain marshallswain self-assigned this Aug 11, 2026
…in errors

Include 0.0.0.0 in the loopback port-flex allowlist used for local OAuth
redirects. When a referer is rejected, report the normalized origin,
configured allowlist, and a short hint about ports and loopback matching.
@marshallswain
marshallswain merged commit 1a58896 into dove Aug 11, 2026
4 checks passed
@marshallswain
marshallswain deleted the fix/oauth-loopback-origin-ports branch August 11, 2026 01:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix on authentication-oauth now breaks local dev with port number

1 participant