Skip to content

fix: sign in over HTTPS when the server requires it - #1932

Open
ranjithguggilla wants to merge 1 commit into
tableau:developmentfrom
ranjithguggilla:fix/1091-signin-requires-https
Open

ranjithguggilla wants to merge 1 commit into
tableau:developmentfrom
ranjithguggilla:fix/1091-signin-requires-https

Conversation

@ranjithguggilla

Copy link
Copy Markdown

Closes #1091

Motivation

Signing in to an http:// address when the server requires https fails with 405 Method Not Allowed, and the credentials have already been sent in cleartext. The issue asks the client to check the unauthenticated endpoint and switch to https before the sign-in request.

Behavior change

sign_in first GETs serverInfo with no credentials and without following redirects.

  • A redirect to https on the same host switches the stored server address, and the sign-in POST goes there.
  • An http response of 400, 403, or 405 is followed by the same GET over https. A 200 response switches the address.
  • A server that answers serverInfo over http is left on http.
  • If the probe cannot be made, sign-in continues at the address the caller gave.

Test plan

Three mocked cases: a 301 to https, a 200 over http, and a 405 on http with a 200 on https. test/test_auth.py and test/test_redirect_handling.py pass.

Not covered: a live server that redirects http to https.

An http sign-in against a server that only accepts https fails with 405
after the credentials have already been sent. Probe the unauthenticated
serverInfo endpoint first and switch the address to https when that
probe redirects or when http is refused and https answers.
@jacalata

jacalata commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Thanks for this, @ranjithguggilla. Probing serverInfo before sign-in is the right approach for #1091. A few changes are needed, plus a question and some tests.

Please fix: the probe ignores http_options (_use_https_if_the_server_requires_it)

The probe calls self.parent_srv.session.get(probe_url, allow_redirects=False, timeout=timeout, verify=verify), which passes only timeout and verify. Every other request goes through Endpoint.set_parameters, which also applies proxies, cert, headers and a custom User-Agent. A caller behind a proxy or using a client cert gets a probe that fails and is swallowed, so https is never detected. Or the probe reaches the server by a different route than the sign-in. Could you build the kwargs with Endpoint.set_parameters(http_options, None, None, None, {"allow_redirects": False}), or send the probe through _make_request with auth_token=None?

Please fix: probe failures are logged at INFO

except Exception logs at INFO on both probes. A TLS failure on the https probe, such as a self-signed cert with verify=True, leaves the user on http with no visible warning. Could you log it at WARNING and say that https wasn't reachable and sign-in is continuing over http?

Please fix: sign_in docstring

The docstring doesn't mention the extra unauthenticated request, or that server.server_address can change from http to https. Callers who cache the address should be told.

Question: redirects that change the port

The check target.netloc == parsed.netloc compares host and port. http://host:8080 redirecting to https://host:8443, or http://host redirecting to https://host:443, isn't switched, so the sign-in POST goes to http with the credentials in the body. When the switch does happen, the new address is rebuilt from the original netloc ("https://" + address[len("http://") :]), not from the redirect target. Is the same-netloc rule intentional as the safe subset? If so, could the docstring say so?

Tests

The three tests cover a 301 to https, a 200 over http, and a 405 on http with a 200 on https. Could you add cases for:

  • a probe exception, and a 405 on http where https also fails, so we know sign-in still proceeds over http
  • the http_options handling above

A test for a redirect to a different host (the address should stay on http) is nice to have.

Drafted with AI assistance (Claude); reviewed and posted by Jac.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Type 3] Don't let signin requests be sent if they use http when server expects https

2 participants