Skip to content
/ core Public

Commit fb50b42

Browse files
authored
Make presign siagnatures similar to official SDK (#2037)
1 parent 1d4ab37 commit fb50b42

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66

77
- Remove redundant ext-json requirement
88

9+
### Fixed
10+
11+
- SignerV4: Fix presign request for some S3 compatible third services
12+
913
## 1.28.0
1014

1115
### Added

src/Signer/SignerV4.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class SignerV4 implements Signer
3939
'from' => true,
4040
'referer' => true,
4141
'user-agent' => true,
42+
'x-amz-user-agent' => true,
4243
'x-amzn-trace-id' => true,
4344
'aws-sdk-invocation-id' => true,
4445
'aws-sdk-retry' => true,
@@ -139,7 +140,7 @@ private function handleSignature(Request $request, Credentials $credentials, \Da
139140
$bodyDigest = $this->buildBodyDigest($request, $isPresign);
140141

141142
if ($isPresign) {
142-
// Should be called after `buildBodyDigest` because this method may remove the header `x-amz-content-sha256`
143+
// Should be called after `buildBodyDigest` because this method moves the header `x-amz-content-sha256` in the querystring
143144
$this->convertHeaderToQuery($request);
144145
}
145146

@@ -243,7 +244,8 @@ private function convertHeaderToQuery(Request $request): void
243244
{
244245
foreach ($request->getHeaders() as $name => $value) {
245246
if ('x-amz' === substr($name, 0, 5)) {
246-
$request->setQueryAttribute($name, $value);
247+
$attribute = implode('-', array_map(ucfirst(...), explode('-', $name)));
248+
$request->setQueryAttribute($attribute, $value);
247249
}
248250

249251
if (isset(self::BLACKLIST_HEADERS[$name])) {

0 commit comments

Comments
 (0)