Skip to content

Commit

Permalink
Fix authentication in Safari.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
hesselink committed Apr 8, 2014
1 parent e3103a3 commit 53311d6
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Distribution/Server/Framework/Auth.hs
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,8 @@ getDigestAuthInfo authHeader req = do
nc <- Map.lookup "nc" authMap
cnonce <- Map.lookup "cnonce" authMap
return (QopAuth nc cnonce)
`mplus`
return QopNone
Nothing -> return QopNone
_ -> mzero
return DigestAuthInfo {
Expand Down Expand Up @@ -293,12 +295,11 @@ headerDigestAuthChallenge (RealmName realmName) = do
headerName = "WWW-Authenticate"
-- Note that offering both qop=\"auth,auth-int\" can confuse some browsers
-- e.g. see http://code.google.com/p/chromium/issues/detail?id=45194
-- TODO: can't even offer qop="auth" because the HTTP package does it wrong
headerValue nonce =
"Digest " ++
intercalate ", "
[ "realm=" ++ inQuotes realmName
, "qop=" ++ inQuotes ""
, "qop=" ++ inQuotes "auth"
, "nonce=" ++ inQuotes nonce
, "opaque=" ++ inQuotes ""
]
Expand Down

0 comments on commit 53311d6

Please sign in to comment.