1 From the upstream commit, with the changes to CHANGELOG and the docs
4 From 1532d67c3ecf452b8c86bcc5928525398755cd01 Mon Sep 17 00:00:00 2001
5 From: Joey Hess <joeyh@joeyh.name>
6 Date: Thu, 7 May 2020 13:18:11 -0400
7 Subject: [PATCH] S3: Support signature=v4
9 To use S3 Signature Version 4. Some S3 services seem to require v4, while
10 others may only support v2, which remains the default.
12 I'm also not sure if v4 works correctly in all cases, there is this
13 upstream bug report: https://github.com/aristidb/aws/issues/262
14 I've only tested it against the default S3 endpoint.
17 Remote/S3.hs | 23 ++++++++++++++++++-
18 ..._3bbdf23c8a4a480f4f6b8e8a2f8ddecd._comment | 13 +++++++++++
19 ..._854390b9a781da82ecb85ad85eecad04._comment | 13 +++++++++++
20 doc/special_remotes/S3.mdwn | 4 ++++
21 ..._cf57e8dbd9fdc7c487565b61808b6bb2._comment | 10 ++++++++
22 6 files changed, 65 insertions(+), 1 deletion(-)
23 create mode 100644 doc/bugs/S3_special_remote_support_for_DigitalOcean_Spaces/comment_2_3bbdf23c8a4a480f4f6b8e8a2f8ddecd._comment
24 create mode 100644 doc/forum/backblaze_s3/comment_1_854390b9a781da82ecb85ad85eecad04._comment
25 create mode 100644 doc/special_remotes/S3/comment_34_cf57e8dbd9fdc7c487565b61808b6bb2._comment
27 diff --git a/Remote/S3.hs b/Remote/S3.hs
28 index cb345d1f8..e3ea492f2 100644
31 @@ -99,6 +99,8 @@ remote = specialRemoteType $ RemoteType
32 (FieldDesc "port to connect to")
33 , optionalStringParser requeststyleField
34 (FieldDesc "for path-style requests, set to \"path\"")
35 + , signatureVersionParser signatureField
36 + (FieldDesc "S3 signature version")
37 , optionalStringParser mungekeysField HiddenField
38 , optionalStringParser AWS.s3credsField HiddenField
40 @@ -148,6 +150,22 @@ protocolField = Accepted "protocol"
41 requeststyleField :: RemoteConfigField
42 requeststyleField = Accepted "requeststyle"
44 +signatureField :: RemoteConfigField
45 +signatureField = Accepted "signature"
47 +newtype SignatureVersion = SignatureVersion Int
49 +signatureVersionParser :: RemoteConfigField -> FieldDesc -> RemoteConfigFieldParser
50 +signatureVersionParser f fd =
51 + genParser go f defver fd
52 + (Just (ValueDesc "v2 or v4"))
54 + go "v2" = Just (SignatureVersion 2)
55 + go "v4" = Just (SignatureVersion 4)
58 + defver = SignatureVersion 2
60 portField :: RemoteConfigField
61 portField = Accepted "port"
63 @@ -877,7 +895,10 @@ s3Configuration c = cfg
65 | port == 443 -> AWS.HTTPS
66 | otherwise -> AWS.HTTP
67 - cfg = S3.s3 proto endpoint False
68 + cfg = case getRemoteConfigValue signatureField c of
69 + Just (SignatureVersion 4) ->
70 + S3.s3v4 proto endpoint False S3.SignWithEffort
71 + _ -> S3.s3 proto endpoint False