Support localhost redirection with arbitrary port
Preflight checklist
- I could not find a solution in the existing issues, docs, nor discussions.
- I agree to follow this project's Code of Conduct.
- I have read and am following this repository's Contribution Guidelines.
- I have joined the Ory Community Slack.
- I am signed up to the Ory Security Patch Newsletter.
Ory Network Project
No response
Describe your problem
In #1732 127.0.0.1 and [::1] were implemented to allow the usage of arbitrary ports.
Many MCP clients like claude code and others do not use 127.0.0.1 but localhost and generate a random port for the OAuth callback.
See this commit message: https://github.com/agentserver/agentserver/commit/ff15f32239634e0b30daeddd8553989331586b8a
The MCP context possibly also relates to #4061
Describe your ideal solution
Could you please add localhost as a third allowed option alongside 127.0.0.1 and [::1] to use an arbitrary port.
I know, the RFC does not recommend doing this but there are many usecases that unfortunatly require it anyway: https://datatracker.ietf.org/doc/html/rfc8252#section-8.3
Other OAuth implementations e.g. Microsoft Entra ID do support it.
Also there are WSL (Windows Subsystem for Linux) network configurations that do only work using localhost and do not work with 127.0.0.1.
Workarounds or alternatives
None.
Version
v26.0.2
Additional Context
No response
Source: ory/hydra