support git remotes that need http basic auth
using git credential to get the password One thing this doesn't do is wrap the password prompting inside the prompt action. So with -J, the output can be a bit garbled.
This commit is contained in:
parent
45250c3273
commit
1883f7ef8f
12 changed files with 143 additions and 44 deletions
|
@ -747,7 +747,7 @@ checkUrlM external url =
|
|||
retrieveUrl :: Retriever
|
||||
retrieveUrl = fileRetriever $ \f k p -> do
|
||||
us <- getWebUrls k
|
||||
unlessM (downloadUrl k p us f) $
|
||||
unlessM (withUrlOptions $ downloadUrl k p us f) $
|
||||
giveup "failed to download content"
|
||||
|
||||
checkKeyUrl :: Git.Repo -> CheckPresent
|
||||
|
|
|
@ -276,7 +276,7 @@ tryGitConfigRead autoinit r
|
|||
warning $ "Unable to parse git config from " ++ configloc
|
||||
return $ Left l
|
||||
|
||||
geturlconfig = Url.withUrlOptions $ \uo -> do
|
||||
geturlconfig = Url.withUrlOptionsPromptingCreds $ \uo -> do
|
||||
v <- withTmpFile "git-annex.tmp" $ \tmpfile h -> do
|
||||
liftIO $ hClose h
|
||||
let url = Git.repoLocation r ++ "/config"
|
||||
|
@ -382,7 +382,7 @@ inAnnex' repo rmt (State connpool duc _ _) key
|
|||
checkhttp = do
|
||||
showChecking repo
|
||||
gc <- Annex.getGitConfig
|
||||
ifM (Url.withUrlOptions $ \uo -> anyM (\u -> Url.checkBoth u (fromKey keySize key) uo) (keyUrls gc repo rmt key))
|
||||
ifM (Url.withUrlOptionsPromptingCreds $ \uo -> anyM (\u -> Url.checkBoth u (fromKey keySize key) uo) (keyUrls gc repo rmt key))
|
||||
( return True
|
||||
, giveup "not found"
|
||||
)
|
||||
|
@ -514,7 +514,8 @@ copyFromRemote'' :: Git.Repo -> Bool -> Remote -> State -> Key -> AssociatedFile
|
|||
copyFromRemote'' repo forcersync r st@(State connpool _ _ _) key file dest meterupdate
|
||||
| Git.repoIsHttp repo = unVerified $ do
|
||||
gc <- Annex.getGitConfig
|
||||
Annex.Content.downloadUrl key meterupdate (keyUrls gc repo r key) dest
|
||||
Url.withUrlOptionsPromptingCreds $
|
||||
Annex.Content.downloadUrl key meterupdate (keyUrls gc repo r key) dest
|
||||
| not $ Git.repoIsUrl repo = guardUsable repo (unVerified (return False)) $ do
|
||||
params <- Ssh.rsyncParams r Download
|
||||
u <- getUUID
|
||||
|
|
|
@ -37,6 +37,7 @@ import Crypto
|
|||
import Backend.Hash
|
||||
import Utility.Hash
|
||||
import Utility.SshHost
|
||||
import Utility.Url
|
||||
import Logs.Remote
|
||||
import Logs.RemoteState
|
||||
import qualified Utility.GitLFS as LFS
|
||||
|
@ -283,7 +284,7 @@ discoverLFSEndpoint tro h
|
|||
if needauth (responseStatus resp)
|
||||
then do
|
||||
cred <- prompt $ inRepo $ Git.getUrlCredential (show lfsrepouri)
|
||||
let endpoint' = addbasicauth cred endpoint
|
||||
let endpoint' = addbasicauth (Git.credentialBasicAuth cred) endpoint
|
||||
let testreq' = LFS.startTransferRequest endpoint' transfernothing
|
||||
flip catchNonAsync (const (returnendpoint endpoint')) $ do
|
||||
resp' <- makeSmallAPIRequest testreq'
|
||||
|
@ -303,12 +304,10 @@ discoverLFSEndpoint tro h
|
|||
|
||||
needauth status = status == unauthorized401
|
||||
|
||||
addbasicauth cred endpoint =
|
||||
case (Git.credentialUsername cred, Git.credentialPassword cred) of
|
||||
(Just u, Just p) ->
|
||||
LFS.modifyEndpointRequest endpoint $
|
||||
applyBasicAuth (encodeBS u) (encodeBS p)
|
||||
_ -> endpoint
|
||||
addbasicauth (Just ba) endpoint =
|
||||
LFS.modifyEndpointRequest endpoint $
|
||||
applyBasicAuth' ba
|
||||
addbasicauth Nothing endpoint = endpoint
|
||||
|
||||
-- The endpoint is cached for later use.
|
||||
getLFSEndpoint :: LFS.TransferRequestOperation -> TVar LFSHandle -> Annex (Maybe LFS.Endpoint)
|
||||
|
|
|
@ -387,7 +387,7 @@ retrieve hv r rs c info = fileRetriever $ \f k p -> withS3Handle hv $ \case
|
|||
Left failreason -> do
|
||||
warning failreason
|
||||
giveup "cannot download content"
|
||||
Right us -> unlessM (downloadUrl k p us f) $
|
||||
Right us -> unlessM (withUrlOptions $ downloadUrl k p us f) $
|
||||
giveup "failed to download content"
|
||||
|
||||
retrieveHelper :: S3Info -> S3Handle -> (Either S3.Object S3VersionID) -> FilePath -> MeterUpdate -> Annex ()
|
||||
|
|
|
@ -90,7 +90,7 @@ downloadKey key _af dest p = unVerified $ get =<< getWebUrls key
|
|||
YoutubeDownloader -> do
|
||||
showOutput
|
||||
youtubeDlTo key u' dest
|
||||
_ -> downloadUrl key p [u'] dest
|
||||
_ -> Url.withUrlOptions $ downloadUrl key p [u'] dest
|
||||
|
||||
downloadKeyCheap :: Key -> AssociatedFile -> FilePath -> Annex Bool
|
||||
downloadKeyCheap _ _ _ = return False
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue