Skip to content

fix(webdav): retry stale digest authentication - #9616

Open
otiscuilei wants to merge 1 commit into
AlistGo:mainfrom
otiscuilei:fix/webdav-refresh-stale-digest-nonce
Open

fix(webdav): retry stale digest authentication#9616
otiscuilei wants to merge 1 commit into
AlistGo:mainfrom
otiscuilei:fix/webdav-refresh-stale-digest-nonce

Conversation

@otiscuilei

@otiscuilei otiscuilei commented Aug 12, 2026

Copy link
Copy Markdown

What this changes

Refreshes Digest authentication when a WebDAV server rejects an expired nonce with a new WWW-Authenticate challenge containing stale=true.

Previously, the first Digest challenge was handled, but any later 401 from an already active DigestAuth immediately returned an authorization error. Servers that periodically expire nonces therefore became unusable until the client was recreated.

The retry is deliberately bounded to one stale challenge so a misbehaving server cannot cause unbounded recursion. Responses are closed before retrying so the underlying connection can be reused safely.

Tests

  • Added an httptest WebDAV flow covering initial authentication, nonce expiry, refreshed authentication, and success
  • Added a repeated-stale test proving the retry is bounded
  • go test ./pkg/gowebdav -count=1
  • All pkg/... tests pass except the existing pkg/aria2/rpc integration tests, which require an aria2 server on localhost:6800

Fixes #7556

@otiscuilei
otiscuilei force-pushed the fix/webdav-refresh-stale-digest-nonce branch from e14ecd8 to 1ab440c Compare August 12, 2026 12:00
@okatu-loli

Copy link
Copy Markdown
Collaborator

This looks solid to me. Checked the DigestAuth struct literal lines up with the field order {user, pw, digestParts}, the retry is bounded to a single stale challenge so theres no runaway recursion, and the response body gets closed before each retry. Tests cover both the happy path and the bounded case, which is what I wanted to see.

One tiny thing, not a blocker: the !canRetry stale branch returns without closing rs.Body, but the neighboring 401 branches do the same, so at least its consistent. Happy to merge.

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.

更新gowebdav依赖以支持Digest Auth中的stale指令

2 participants