git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 0/3] http: fix emptyAuth=auto for Negotiate/SPNEGO

From
Matthew John Cheetham via GitGitGadget <gitgitgadget@gmail.com>
Date
Apr 16, 2026, 09:20 UTC
Message-ID
<pull.2087.git.1776331259.gitgitgadget@gmail.com>

When a server advertises Negotiate (SPNEGO) authentication alongside Basic, the "auto" mode of http.emptyAuth should allow libcurl to attempt Kerberos authentication using the system ticket cache before falling back to credential_fill(). Currently this never happens due to an interaction between two older features.

The Negotiate-stripping logic from 4dbe66464b (remote-curl: fall back to Basic auth if Negotiate fails, 2015-01-08) removes CURLAUTH_GSSNEGOTIATE on the first 401, before the auto-detection from 40a18fc77c (http: add an "auto" mode for http.emptyauth, 2017-02-25) gets a chance to see it as an "exotic" method. The result is that auto mode silently degrades to the same behavior as emptyAuth=false for any server whose only non-Basic/Digest method is Negotiate, forcing Kerberos users to manually set http.emptyAuth=true to get seamless ticket-based authentication.

This series fixes the interaction by delaying the Negotiate stripping in auto mode by one round-trip, giving empty auth a chance to use the system Kerberos ticket. If there is no valid ticket, Negotiate is stripped on the second 401 and we fall through to credential_fill() as before. The true and false modes are unchanged.

Patch 1: Extract a http_reauth_prepare() helper from the three retry paths that call credential_fill() on HTTP_REAUTH. Pure refactor, no behavior change.

Patch 2: Delay the GSSNEGOTIATE stripping in auto mode and teach http_reauth_prepare() to skip credential_fill() when empty auth should be attempted first.

Patch 3: Add tests verifying that auto mode produces an extra round-trip (empty auth attempt) compared to false mode, using the existing nph-custom-auth.sh CGI infrastructure.

There is a trade-off in auto mode: when a server advertises Negotiate but the client has no valid Kerberos ticket, there is one extra round-trip compared to the current behavior. This matches the trade-off already documented in 40a18fc77c. Users who want to avoid it can set http.emptyAuth=false.

Note: this patch series was taken early into Git for Windows for the
2.54.0-rc2 release.
https://github.com/git-for-windows/git/commit/8e94b65c003783d7d7b09d9fccdf06a1363e347c
Matthew John Cheetham (3):
  http: extract http_reauth_prepare() from retry paths
  http: attempt Negotiate auth in http.emptyAuth=auto mode
  t5563: add tests for http.emptyAuth with Negotiate
 http.c                      | 32 +++++++++++++++-
 http.h                      |  6 +++
 remote-curl.c               |  4 +-
 t/t5563-simple-http-auth.sh | 74 +++++++++++++++++++++++++++++++++++++
 4 files changed, 112 insertions(+), 4 deletions(-)
base-commit: 2b39a27d40682c09ac1c031f099ee602061597cd
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-2087%2Fmjcheetham%2Fspnego-fix-upstream-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2087/mjcheetham/spnego-fix-upstream-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/2087
-- 
gitgitgadget
Next: Matthew John Cheetham via GitGitGadget
Message 1 of 13 in “http: fix emptyAuth=auto for Negotiate/SPNEGO”
  1. 0/3 http: fix emptyAuth=auto for Negotiate/SPNEGOMatthew John Cheetham via GitGitGadget, Apr 16, 2026
  2. 1/3 http: extract http_reauth_prepare() from retry pathsMatthew John Cheetham via GitGitGadget, Apr 16, 2026
  3. Junio C HamanoApr 16, 2026
  4. 2/3 http: attempt Negotiate auth in http.emptyAuth=auto modeMatthew John Cheetham via GitGitGadget, Apr 16, 2026
  5. Junio C HamanoApr 16, 2026
  6. Matthew John CheethamApr 28, 2026
  7. 3/3 t5563: add tests for http.emptyAuth with NegotiateMatthew John Cheetham via GitGitGadget, Apr 16, 2026
  8. 0/4 http: fix emptyAuth=auto for Negotiate/SPNEGOMatthew John Cheetham via GitGitGadget, Apr 30, 2026
  9. 1/4 http: extract http_reauth_prepare() from retry pathsMatthew John Cheetham via GitGitGadget, Apr 30, 2026
  10. 2/4 http: attempt Negotiate auth in http.emptyAuth=auto modeMatthew John Cheetham via GitGitGadget, Apr 30, 2026
  11. 3/4 t5563: add tests for http.emptyAuth with NegotiateMatthew John Cheetham via GitGitGadget, Apr 30, 2026
  12. 4/4 doc: clarify http.emptyAuth valuesMatthew John Cheetham via GitGitGadget, Apr 30, 2026
  13. Matthew John CheethamApr 30, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.