S3: Support AWS_SESSION_TOKEN

This commit was sponsored by Boyd Stephen Smith Jr. on Patreon.
This commit is contained in:
Joey Hess 2018-09-05 15:53:57 -04:00
parent ae5d95d80b
commit 7407a80c27
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
4 changed files with 18 additions and 5 deletions

View file

@ -55,6 +55,7 @@ import Utility.FileSystemEncoding
import Annex.Content
import Annex.Url (withUrlOptions)
import Utility.Url (checkBoth, UrlOptions(..))
import Utility.Env
type BucketName = String
type BucketObject = String
@ -698,10 +699,12 @@ genericPublicUrl p baseurl = baseurl ++ p
genCredentials :: CredPair -> IO AWS.Credentials
genCredentials (keyid, secret) = AWS.Credentials
<$> pure (T.encodeUtf8 (T.pack keyid))
<*> pure (T.encodeUtf8 (T.pack secret))
<$> pure (tobs keyid)
<*> pure (tobs secret)
<*> newIORef []
<*> pure Nothing
<*> (fmap tobs <$> getEnv "AWS_SESSION_TOKEN")
where
tobs = T.encodeUtf8 . T.pack
mkLocationConstraint :: AWS.Region -> S3.LocationConstraint
mkLocationConstraint "US" = S3.locationUsClassic