Replies: 1 comment
|
Closing this — see the updated body. Digest authentication is already fully achievable today by composing |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Overview
HTTP Digest Authentication (RFC 7616) doesn't need new API in this package — it's already achievable today by composing two existing pieces of public API, with no changes to the network layer.
Why
Digest auth is a two-round-trip challenge-response: send a request, get a
401back with aWWW-Authenticate: Digest realm=..., nonce=...challenge, compute a response hash from it, and resend the request with the computedAuthorization: Digest ...header.TaskResult.head(returned byDataTask.result()) already exposes both the status code and the response headers, so the challenge is fully readable..map(_:)is already generic enough ((Input) async throws -> Output, withInput == Outputhere) to inspect that result and, when it's a401, build and execute an entirely newDataTaskwith the computed header — no replay of the original request needed, no new modifier required.Authorization's existing(_:token:)initializer already produces the right header shape by coincidence: it builds"\(type.rawValue) \(token)", and Digest's header is exactly"Digest " + comma-separated-key-value-string, soAuthorization(.init("Digest"), token: "username=\"...\", realm=\"...\", nonce=\"...\", response=\"...\"")is already correct today.No infinite-retry risk: the retried call is a plain
DataTask, not wrapped in.mapagain, so it only ever gets the one extra attempt.Decision
Closing as out of scope for the network layer. The RFC 7616 challenge-parsing and hashing (HA1/HA2/response, MD5 or SHA-256, qop/cnonce/nc bookkeeping) is generic auth logic that belongs in userland or a small crypto-facing helper (
swift-crypto), not this package — and the retry orchestration itself is already fully expressible with.map, so there isn't even a convenience modifier worth bundling here (unlike a case where the pattern couldn't be expressed with existing API at all).All reactions