Skip to content
Snippets Groups Projects
Commit 3d1e7dbd authored by Duncan Coutts's avatar Duncan Coutts
Browse files

Force cabal upload to always use digest auth and never basic auth

parent f2d01e5a
No related branches found
No related tags found
No related merge requests found
...@@ -17,8 +17,8 @@ import Network.HTTP.Proxy ( Proxy(..), fetchProxy) ...@@ -17,8 +17,8 @@ import Network.HTTP.Proxy ( Proxy(..), fetchProxy)
import Network.URI import Network.URI
( URI (..), URIAuth (..) ) ( URI (..), URIAuth (..) )
import Network.Browser import Network.Browser
( BrowserAction, browse ( BrowserAction, browse, setAllowBasicAuth, setAuthorityGen
, setOutHandler, setErrHandler, setProxy, setAuthorityGen, request) , setOutHandler, setErrHandler, setProxy, request)
import Network.Stream import Network.Stream
( Result, ConnError(..) ) ( Result, ConnError(..) )
import Control.Exception import Control.Exception
...@@ -84,10 +84,10 @@ getHTTP :: Verbosity ...@@ -84,10 +84,10 @@ getHTTP :: Verbosity
-> Maybe String -- ^ Optional etag to check if we already have the latest file. -> Maybe String -- ^ Optional etag to check if we already have the latest file.
-> IO (Result (Response ByteString)) -> IO (Result (Response ByteString))
getHTTP verbosity uri etag = liftM (\(_, resp) -> Right resp) $ getHTTP verbosity uri etag = liftM (\(_, resp) -> Right resp) $
cabalBrowse verbosity (return ()) (request (mkRequest uri etag)) cabalBrowse verbosity Nothing (request (mkRequest uri etag))
cabalBrowse :: Verbosity cabalBrowse :: Verbosity
-> BrowserAction s () -> Maybe (String, String)
-> BrowserAction s a -> BrowserAction s a
-> IO a -> IO a
cabalBrowse verbosity auth act = do cabalBrowse verbosity auth act = do
...@@ -100,8 +100,8 @@ cabalBrowse verbosity auth act = do ...@@ -100,8 +100,8 @@ cabalBrowse verbosity auth act = do
setProxy p setProxy p
setErrHandler (warn verbosity . ("http error: "++)) setErrHandler (warn verbosity . ("http error: "++))
setOutHandler (debug verbosity) setOutHandler (debug verbosity)
auth setAllowBasicAuth False
setAuthorityGen (\_ _ -> return Nothing) setAuthorityGen (\_ _ -> return auth)
act act
downloadURI :: Verbosity downloadURI :: Verbosity
......
...@@ -18,12 +18,10 @@ import qualified Distribution.Client.BuildReports.Anonymous as BuildReport ...@@ -18,12 +18,10 @@ import qualified Distribution.Client.BuildReports.Anonymous as BuildReport
import qualified Distribution.Client.BuildReports.Upload as BuildReport import qualified Distribution.Client.BuildReports.Upload as BuildReport
import Network.Browser import Network.Browser
( BrowserAction, request ( request )
, Authority(..), addAuthority )
import Network.HTTP import Network.HTTP
( Header(..), HeaderName(..), findHeader ( Header(..), HeaderName(..), findHeader
, Request(..), RequestMethod(..), Response(..) ) , Request(..), RequestMethod(..), Response(..) )
import Network.TCP (HandleStream)
import Network.URI (URI(uriPath), parseURI) import Network.URI (URI(uriPath), parseURI)
import Data.Char (intToDigit) import Data.Char (intToDigit)
...@@ -53,12 +51,7 @@ upload verbosity repos mUsername mPassword paths = do ...@@ -53,12 +51,7 @@ upload verbosity repos mUsername mPassword paths = do
else targetRepoURI{uriPath = uriPath targetRepoURI `FilePath.Posix.combine` "upload"} else targetRepoURI{uriPath = uriPath targetRepoURI `FilePath.Posix.combine` "upload"}
Username username <- maybe promptUsername return mUsername Username username <- maybe promptUsername return mUsername
Password password <- maybe promptPassword return mPassword Password password <- maybe promptPassword return mPassword
let auth = addAuthority AuthBasic { let auth = Just (username, password)
auRealm = "Hackage",
auUsername = username,
auPassword = password,
auSite = uploadURI
}
flip mapM_ paths $ \path -> do flip mapM_ paths $ \path -> do
notice verbosity $ "Uploading " ++ path ++ "... " notice verbosity $ "Uploading " ++ path ++ "... "
handlePackage verbosity uploadURI auth path handlePackage verbosity uploadURI auth path
...@@ -89,12 +82,7 @@ report verbosity repos mUsername mPassword = do ...@@ -89,12 +82,7 @@ report verbosity repos mUsername mPassword = do
else targetRepoURI{uriPath = ""} else targetRepoURI{uriPath = ""}
Username username <- maybe promptUsername return mUsername Username username <- maybe promptUsername return mUsername
Password password <- maybe promptPassword return mPassword Password password <- maybe promptPassword return mPassword
let auth = addAuthority AuthBasic { let auth = Just (username, password)
auRealm = "Hackage",
auUsername = username,
auPassword = password,
auSite = uploadURI
}
forM_ repos $ \repo -> case repoKind repo of forM_ repos $ \repo -> case repoKind repo of
Left remoteRepo Left remoteRepo
-> do dotCabal <- defaultCabalDir -> do dotCabal <- defaultCabalDir
...@@ -120,9 +108,9 @@ check :: Verbosity -> [FilePath] -> IO () ...@@ -120,9 +108,9 @@ check :: Verbosity -> [FilePath] -> IO ()
check verbosity paths = do check verbosity paths = do
flip mapM_ paths $ \path -> do flip mapM_ paths $ \path -> do
notice verbosity $ "Checking " ++ path ++ "... " notice verbosity $ "Checking " ++ path ++ "... "
handlePackage verbosity checkURI (return ()) path handlePackage verbosity checkURI Nothing path
handlePackage :: Verbosity -> URI -> BrowserAction (HandleStream ByteString) () handlePackage :: Verbosity -> URI -> Maybe (String, String)
-> FilePath -> IO () -> FilePath -> IO ()
handlePackage verbosity uri auth path = handlePackage verbosity uri auth path =
do req <- mkRequest uri path do req <- mkRequest uri path
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment