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

@ -30,6 +30,7 @@ git-annex (6.20180808) UNRELEASED; urgency=medium
* S3: Support buckets with versioning enabled. When a remote
is configured with exporttree=yes versioning=yes, git-annex can
download past versions of exported files from it.
* S3: Support AWS_SESSION_TOKEN.
* git-annex.cabal: Fix build without assistant, and some other refinements.
Thanks fftehnik.

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

View file

@ -0,0 +1,7 @@
[[!comment format=mdwn
username="joey"
subject="""comment 1"""
date="2018-09-05T19:36:52Z"
content="""
Sure, done.
"""]]

View file

@ -9,9 +9,11 @@ for usage examples.
The standard environment variables `AWS_ACCESS_KEY_ID` and
`AWS_SECRET_ACCESS_KEY` are used to supply login credentials
for Amazon. You need to set these only when running
for S3. You need to set these only when running
`git annex initremote`, as they will be cached in a file only you
can read inside the local git repository.
can read inside the local git repository. If youre working with
temporary security credentials, you can also set the `AWS_SESSION_TOKEN`
environment variable.
A number of parameters can be passed to `git annex initremote` to configure
the S3 remote.