Skip to content

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

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

ranjithguggilla wants to merge 2 commits into
tableau:developmentfrom
ranjithguggilla:fix/1091-signin-requires-https

Conversation

@ranjithguggilla

@ranjithguggilla ranjithguggilla commented Nov 22, 2026 •

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, using the same HTTP options as the sign-in request (proxy, client certificate, headers, timeout, verify, and User-Agent). The probe does not follow redirects.

  • A redirect to https on the same host and port switches the stored server address. The new address keeps that host and port and only changes the scheme. A different host or port, including https on port 443 when the original URL had no port, is left on http, and the sign-in POST stays 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 either probe fails, a warning says sign-in is continuing over HTTP, and the POST goes to the address the caller gave.

Test plan

Mocked cases: a 301 to https, a 200 over http, a 405 on http with a 200 on https, a probe exception, a 405 where the https probe also fails, a redirect to a different host, a redirect that changes the port, and a probe that carries proxy, certificate, header, timeout, and verify settings. 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.

The probe sent only timeout and verify, so a proxy or client certificate
made it fail and left sign-in on http. It now uses Endpoint.set_parameters
and still does not follow redirects. A failed https probe is a warning
that says sign-in is continuing over HTTP, and the docstring says the
stored address changes only for the same host and port.
Copilot AI balanced review requested due to automatic review settings December 1, 2026 09:03

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@ranjithguggilla

Copy link
Copy Markdown
Author

The probe now goes through Endpoint.set_parameters, so it uses the same proxy, client certificate, headers, timeout, verify, and User-Agent as sign-in, and it still sends no auth token. allow_redirects is forced off after that, so the probe can see the redirect even if the caller asked requests to follow them.

The same-host-and-port check is intentional, and it is the same rule the redirect walker already uses. The stored address keeps the original host and port and only changes the scheme. A redirect to another host, or to another port (http://host:8080 to https://host:8443, or http://host to https://host:443), does not switch, so the credentials stay on the address the caller set. That is now in the sign_in docstring.

A failed probe is logged at WARNING. When the https probe cannot be reached, the message says so and that sign-in continues over HTTP.

New tests cover a probe exception, a 405 where https also fails, a redirect to a different host, a redirect that changes the port, and the HTTP options on the probe.

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

3 participants