Skip to content

Bind to localhost when finding available ports#1280

Open
joeljons wants to merge 6 commits intodatabricks:mainfrom
joeljons:fix-isPortAvailable
Open

Bind to localhost when finding available ports#1280
joeljons wants to merge 6 commits intodatabricks:mainfrom
joeljons:fix-isPortAvailable

Conversation

@joeljons
Copy link

Description

Change so that checking for available ports checks by binding to localhost.

When connecting with OAuth Browser flow (AuthMech=11;Auth_Flow=2) a local webserver is started to catch the redirect from the OAuth flow.
If port 8020 (or the port(s) configured by OAuth2RedirectUrlPort) was occupied and bound to localhost the port availability check though it was free because it checked using the wildcard adress.
This led to the jdbc connect failed with DatabricksDriverException: ExternalHeaderFactory not initialized. Call configure() first.

Testing

  • Updated tests in ClientConfiguratorTest to bind to localhost.
  • Added a new test case for where the occupied port is only bound to the wildcard address.
  • Manual testing of having other services occupying the port, including the HttpServer started by the OAuth Browser flow from another session.

Additional Notes to the Reviewer

Multiple servers can be started on the same port if bound to different hosts or the wildcard address. The HttpServer started in Consent.getOAuthCallbackParameters binds to localhost, so ClientConfigurator.isPortAvailable should also bind to localhost when checking. Although redirectUrl in Consent can be configured it is always localhost set by ClientConfigurator.setupU2MConfig.

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.

1 participant