Repository navigation
fix: sign in over HTTPS when the server requires it - #1932
ranjithguggilla wants to merge 2 commits into
Conversation
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.
|
Thanks for this, @ranjithguggilla. Probing Please fix: the probe ignores The probe calls Please fix: probe failures are logged at INFO
Please fix: The docstring doesn't mention the extra unauthenticated request, or that Question: redirects that change the port The check 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 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.
|
The probe now goes through 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 ( 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. |
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_infirst GETsserverInfowith 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.serverInfoover http is left on http.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.pyandtest/test_redirect_handling.pypass.Not covered: a live server that redirects http to https.