auth: login: explicit check for ipv6 port bindings#1251
auth: login: explicit check for ipv6 port bindings#1251svetlyopet wants to merge 1 commit intostackitcloud:mainfrom
Conversation
|
This PR was marked as stale after 7 days of inactivity and will be closed after another 7 days of further inactivity. If this PR should be kept open, just add a comment, remove the stale label or push new commits to it. |
|
Adding a comment to keep the PR active. |
|
This PR was marked as stale after 7 days of inactivity and will be closed after another 7 days of further inactivity. If this PR should be kept open, just add a comment, remove the stale label or push new commits to it. |
marceljk
left a comment
There was a problem hiding this comment.
Thanks for you contribution! looks good to me 😃
internal/pkg/auth/user_login.go
Outdated
| if ipv6ListenerErr != nil { | ||
| continue | ||
| } | ||
| _ = ipv6Listener.Close() |
There was a problem hiding this comment.
potential race condition:
If after this line another service binds to [::1]:{port} we have the same situation as before.
There was a problem hiding this comment.
moved the ipv6Listener close call to after successfully binding on ipv4
…stener for redirectUrl
b3b96b4 to
7c7bc12
Compare
Description
Fixes 1250
This PR tries to address the issue of the net.Listen() not being able to see that the requested port is already taken on MacOS.
This happens specifically on MacOS, when there is already a service bound to a port on the IPv6 localhost interface, but the port is free on the IPv4 localhost interface. The net.Listen() method sees that the port is open on the 127.0.0.1 interface, and binds to that one. When the user gets redirected to localhost in the browser, it can redirect to either one of the services using the same port on the different interfaces(seems like localhost resolving to the IPv6 is preferred).
Testing
I tested by running the following python service locally, and executing
stackit auth loginafter that which replicates the issue and can be observed.Checklist
make fmtmake generate-docs(will be checked by CI)make test(will be checked by CI)make lint(will be checked by CI)