Skip to content

Commit 53311d6

Browse files
committed
Fix authentication in Safari.
We now offer 'qop="auth"', because without it, authentication in Safari fails immediately. With the field set to auth, authentication seems to work in the latest Firefox, Safari, Chrome and Internet Explorer. However, the HTTP package as used in cabal-install has a bug where it send 'qop="auth"' without an 'nc' or 'cnonce' field. So we are lenient: when these fields are not present, we fall back to no qop. Fixes haskell#132. [1] haskell/HTTP#54
1 parent e3103a3 commit 53311d6

File tree

1 file changed

+3
-2
lines changed
  • Distribution/Server/Framework

1 file changed

+3
-2
lines changed

Distribution/Server/Framework/Auth.hs

+3-2
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,8 @@ getDigestAuthInfo authHeader req = do
248248
nc <- Map.lookup "nc" authMap
249249
cnonce <- Map.lookup "cnonce" authMap
250250
return (QopAuth nc cnonce)
251+
`mplus`
252+
return QopNone
251253
Nothing -> return QopNone
252254
_ -> mzero
253255
return DigestAuthInfo {
@@ -293,12 +295,11 @@ headerDigestAuthChallenge (RealmName realmName) = do
293295
headerName = "WWW-Authenticate"
294296
-- Note that offering both qop=\"auth,auth-int\" can confuse some browsers
295297
-- e.g. see http://code.google.com/p/chromium/issues/detail?id=45194
296-
-- TODO: can't even offer qop="auth" because the HTTP package does it wrong
297298
headerValue nonce =
298299
"Digest " ++
299300
intercalate ", "
300301
[ "realm=" ++ inQuotes realmName
301-
, "qop=" ++ inQuotes ""
302+
, "qop=" ++ inQuotes "auth"
302303
, "nonce=" ++ inQuotes nonce
303304
, "opaque=" ++ inQuotes ""
304305
]

0 commit comments

Comments
 (0)