Skip to content

Commit

Permalink
Update ECR authorization Token URL
Browse files Browse the repository at this point in the history
Port of fabric8io/docker-maven-plugin#1318

Related to #702

Signed-off-by: Rohan Kumar <[email protected]>
  • Loading branch information
rohanKanojia committed Jun 11, 2021
1 parent c01c5c3 commit d17ac9e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Usage:
### 1.4.0-SNAPSHOT
* Fix #705: JIB assembly works on Windows
* Fix #714: feat: Helm support for Golang expressions
* Port fabric8io/docker-maven-plugin#1318: Update ECR autorization token URL

### 1.3.0
* Fix #497: Assembly descriptor removed but still in documentation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@
* @since 2016-12-9
*/
public class AwsSigner4Request {
static final SimpleDateFormat TIME_FORMAT = new SimpleDateFormat("yyyyMMdd'T'HHmmss'Z'");

static {
TimeZone utc = TimeZone.getTimeZone("GMT");
TIME_FORMAT.setTimeZone(utc);
}

private static final byte[] EMPTY_BYTES = new byte[0];

Expand Down Expand Up @@ -111,9 +117,9 @@ private static String getSigningDateTime(HttpRequest request, Date signingTime)
if (dateHeader != null) {
return dateHeader.getValue();
}
final SimpleDateFormat timeFormat= new SimpleDateFormat("yyyyMMdd'T'HHmmss'Z'");
timeFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
return timeFormat.format(signingTime);
synchronized (TIME_FORMAT) {
return TIME_FORMAT.format(signingTime);
}
}

private static URI getUri(HttpRequest request) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ private JsonObject executeRequest(CloseableHttpClient client, HttpPost request)
}

HttpPost createSignedRequest(AuthConfig localCredentials, Date time) {
String host = "ecr." + region + ".amazonaws.com";
String host = "api.ecr." + region + ".amazonaws.com";

logger.debug("Get ECR AuthorizationToken from %s", host);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ public void testHeaders() {
ZonedDateTime.of(2016, 12, 17, 21, 10, 58, 0, ZoneId.of("GMT"))
.toInstant());
HttpPost request = eea.createSignedRequest(localCredentials, signingTime);
assertEquals("ecr.eu-west-1.amazonaws.com", request.getFirstHeader("host").getValue());
assertEquals("api.ecr.eu-west-1.amazonaws.com", request.getFirstHeader("host").getValue());
assertEquals("20161217T211058Z", request.getFirstHeader("X-Amz-Date").getValue());
assertEquals("AWS4-HMAC-SHA256 Credential=username/20161217/eu-west-1/ecr/aws4_request, SignedHeaders=content-type;host;x-amz-target, Signature=1bab0f5c269debe913e532011d5d192b190bb4c55d3de1bc1506eefb93e058e1", request.getFirstHeader("Authorization").getValue());
assertEquals("AWS4-HMAC-SHA256 Credential=username/20161217/eu-west-1/ecr/aws4_request, SignedHeaders=content-type;host;x-amz-target, Signature=2ae11d499499cc951900aac0fbec96009382ba4f735bd14baa375c3e51d50aa9", request.getFirstHeader("Authorization").getValue());
}

@Test
Expand Down

0 comments on commit d17ac9e

Please sign in to comment.