Skip to content

Commit f2db579

Browse files
committed
stack upload uses HTTP digest authentication
1 parent 8ebadf3 commit f2db579

6 files changed

Lines changed: 12 additions & 8 deletions

File tree

ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Other enhancements:
1616
* `stack setup` detects systems where gcc enables PIE by default (such as Ubuntu
1717
16.10) and adjusts the GHC `configure` options accordingly.
1818
[#2542](https://github.com/commercialhaskell/stack/issues/2542)
19+
* Upload to Hackage with HTTP digest instead of HTTP basic.
1920

2021
Bug fixes:
2122

src/Stack/Upload.hs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import Data.Aeson (FromJSON (..),
3939
(.:), (.=))
4040
import qualified Data.ByteString.Char8 as S
4141
import qualified Data.ByteString.Lazy as L
42+
import Data.Maybe (fromMaybe)
4243
import Data.Text (Text)
4344
import qualified Data.Text as T
4445
import Data.Text.Encoding (encodeUtf8)
@@ -47,15 +48,16 @@ import Data.Typeable (Typeable)
4748
import Network.HTTP.Client (BodyReader, Manager,
4849
Response,
4950
RequestBody(RequestBodyLBS),
50-
applyBasicAuth, brRead,
51+
brRead,
5152
newManager,
5253
parseRequest,
5354
requestHeaders,
5455
responseBody,
5556
responseStatus,
5657
withResponse)
5758
import Network.HTTP.Client.MultipartFormData (formDataBody, partFileRequestBody)
58-
import Network.HTTP.Client.TLS (tlsManagerSettings)
59+
import Network.HTTP.Client.TLS (tlsManagerSettings,
60+
applyDigestAuth)
5961
import Network.HTTP.Types (statusCode)
6062
import Path (toFilePath)
6163
import Prelude -- Fix redundant import warnings
@@ -203,13 +205,14 @@ mkUploader config us = do
203205
{ upload_ = \tarName bytes -> do
204206
let formData = [partFileRequestBody "package" tarName (RequestBodyLBS bytes)]
205207
req2 <- formDataBody formData req1
206-
let req3 = applyBasicAuth
208+
mreq3 <- applyDigestAuth
207209
(encodeUtf8 $ hcUsername creds)
208210
(encodeUtf8 $ hcPassword creds)
209211
req2
212+
manager
210213
putStr $ "Uploading " ++ tarName ++ "... "
211214
hFlush stdout
212-
withResponse req3 manager $ \res ->
215+
withResponse (fromMaybe req2 mreq3) manager $ \res ->
213216
case statusCode $ responseStatus res of
214217
200 -> putStrLn "done!"
215218
401 -> do

stack-7.8.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ extra-deps:
4848
- x509-validation-1.6.3
4949
- x509-store-1.6.1
5050
- x509-system-1.6.3
51-
- http-client-tls-0.3.0
51+
- http-client-tls-0.3.1
5252
- connection-0.2.5
5353
- regex-applicative-text-0.1.0.1
5454
- monad-unlift-0.1.1.0

stack-8.0.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ nix:
1111
extra-deps:
1212
- http-client-0.5.0
1313
- http-conduit-2.2.0
14-
- http-client-tls-0.3.0
14+
- http-client-tls-0.3.1
1515
- unicode-transforms-0.1.0.1
1616
- store-0.2.1.0
1717
- store-core-0.2.0.0

stack.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ library
187187
, hit
188188
, hpc
189189
, http-client >= 0.5.0
190-
, http-client-tls >= 0.3.0
190+
, http-client-tls >= 0.3.1
191191
, http-conduit >= 2.2.0
192192
, http-types >= 0.8.6 && < 0.10
193193
, lifted-async

stack.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ extra-deps:
1717
- store-core-0.2.0.0
1818
- th-orphans-0.13.1
1919
- http-client-0.5.0
20-
- http-client-tls-0.3.0
20+
- http-client-tls-0.3.1
2121
- http-conduit-2.2.0
2222
- optparse-applicative-0.13.0.0
2323
- text-metrics-0.1.0

0 commit comments

Comments
 (0)