-
Notifications
You must be signed in to change notification settings - Fork 473
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SNOW-660632: Better support for EXTERNALBROWSER auth from local containers #1251
Comments
@phil-hawkins The connector already supports external browser. Does it solve your problem? See this API doc. https://docs.snowflake.com/en/user-guide/python-connector-api |
Is the goal of that to be able to connect to Snowflake using EXTERNALBROWSER authentication from a Docker container? From the description, it seems you are able to do it already even if it doesn't work all the time, would it be possible to know more about it please @phil-hawkins ? Edit: never mind I managed to do it like that https://stackoverflow.com/questions/67325900/is-it-possible-to-use-externalbrowser-authenticator-inside-docker-container-fo |
@phil-hawkins would you still be interested in creating a PR for this? Our team is happy to review it |
@sfc-gh-aalam I've got a couple fixes for this issue and am preparing a PR. More info today or tomorrow |
Observable BehaviorWhen running in a containerized environment, redirects issued by the host browser to the
I've tried many approaches to make this handling more robust and combining a few together allows the code to work very reliably for my team. These issues were seen on macOS running a Attempted Approaches1.
|
@podung Thanks for such a detailed explanation. I don't have any concerns. Please proceed with the PR. |
Couple updates:
Other than updating the Release Notes with the changes and outlining the environment variables and settings there, is there a place we keep canonical documentation that I should be updating? |
Here's the branch I'm working on if you're interested in seeing what I have so far: main...podung:snowflake-connector-python:robust_containerized_externalbrowser |
@sfc-gh-aalam PR submitted. I'm happy to change anything as you or any of the maintainers see fit, just let me know. |
What is the current behaviour?
EXTERNALBROWSER authentication is the best option in the case of SSO with MFA. However, when performed inside a local container such as a VSCode docker devcontainer, there is a race condition between the auth callback to the localhost and starting the receiver app on the localhost and auto-forwarding the randomly assigned port. This can lead to an intermittent failure to connect.
One way to address this is to assign a fixed port number with the SF_AUTH_SOCKET_PORT environment variable and statically forward this port. This removes the delay in detecting and autoforwarding a randomly assigned port. However a new problem arises: the port remains in a TIME_WAIT state for a few minutes after it is used and subsequent connections fail with
OSError: [Errno 98] Address already in use
during this period.What is the desired behaviour?
EXTERNALBROWSER auth works every time from inside a local container.
An option is to set up a static port forwarding rule as above and set the
SO_REUSEADDR
state of the port, perhaps determined by the value of new environment variable such asSF_AUTH_SOCKET_REUSEADDR
.How would this improve
snowflake-connector-python
?EXTERNALBROWSER auth would work more seamlessly from local containers.
References, Other Background
socket(7) — Linux manual page
SF_AUTH_SOCKET_PORT code
I'm up for doing a PR to address this.
The text was updated successfully, but these errors were encountered: