AWS Signing Request Interceptor

Request Interceptor for Apache Client that signs the request for AWS

License

License

Categories

Categories

AWS Container PaaS Providers
GroupId

GroupId

vc.inreach.aws
ArtifactId

ArtifactId

aws-signing-request-interceptor
Last Version

Last Version

0.0.22
Release Date

Release Date

Type

Type

jar
Description

Description

AWS Signing Request Interceptor
Request Interceptor for Apache Client that signs the request for AWS
Project URL

Project URL

https://github.com/inreachventures/aws-signing-request-interceptor
Source Code Management

Source Code Management

https://github.com/inreachventures/aws-signing-request-interceptor

Download aws-signing-request-interceptor

How to add to project

<!-- https://jarcasting.com/artifacts/vc.inreach.aws/aws-signing-request-interceptor/ -->
<dependency>
    <groupId>vc.inreach.aws</groupId>
    <artifactId>aws-signing-request-interceptor</artifactId>
    <version>0.0.22</version>
</dependency>
// https://jarcasting.com/artifacts/vc.inreach.aws/aws-signing-request-interceptor/
implementation 'vc.inreach.aws:aws-signing-request-interceptor:0.0.22'
// https://jarcasting.com/artifacts/vc.inreach.aws/aws-signing-request-interceptor/
implementation ("vc.inreach.aws:aws-signing-request-interceptor:0.0.22")
'vc.inreach.aws:aws-signing-request-interceptor:jar:0.0.22'
<dependency org="vc.inreach.aws" name="aws-signing-request-interceptor" rev="0.0.22">
  <artifact name="aws-signing-request-interceptor" type="jar" />
</dependency>
@Grapes(
@Grab(group='vc.inreach.aws', module='aws-signing-request-interceptor', version='0.0.22')
)
libraryDependencies += "vc.inreach.aws" % "aws-signing-request-interceptor" % "0.0.22"
[vc.inreach.aws/aws-signing-request-interceptor "0.0.22"]

Dependencies

compile (5)

Group / Artifact Type Version
com.google.guava : guava jar 18.0
commons-codec : commons-codec jar 1.9
org.apache.httpcomponents : httpcore jar 4.4.1
org.apache.httpcomponents : httpclient jar 4.4.1
com.amazonaws : aws-java-sdk-core jar 1.10.19

test (3)

Group / Artifact Type Version
junit : junit jar 4.12
org.mockito : mockito-core jar 1.10.19
org.assertj : assertj-core jar 3.2.0

Project Modules

There are no modules declared in this project.

aws-signing-request-interceptor

Request Interceptor for Apache Client that signs the request for AWS.

Originally created to support AWS' Elasticsearch Service using the Jest client.

Usage

You have to add the AWSSigningRequestInterceptor to the end of the Apache client request chain. Otherwise it won't have visibility of all of the headers being added to the request.

This depends on the AWS core SDK as it relies on an AWSCredentialsProvider to get the key, secret and optional session token. It's advised that you use dependencyManagement to lock in the version of aws-java-sdk-core that works for your project.

private static final String SERVICE = "es";
private static final String REGION = "eu-west-1";
...
final Supplier<LocalDateTime> clock = () -> LocalDateTime.now(ZoneOffset.UTC);
final AWSSigner awsSigner = new AWSSigner(awsCredentialsProvider, REGION, SERVICE, clock);
builder.addInterceptorLast(new AWSSigningRequestInterceptor(awsSigner));

To be able to add the AWSSigningRequestInterceptor to Jest, and thus be able to sign requests to the Elasticsearch Service, you need to override the configureHttpClient method in the JestClientFactory.

final AWSSigningRequestInterceptor requestInterceptor = new AWSSigningRequestInterceptor(awsSigner);
final JestClientFactory factory = new JestClientFactory() {
    @Override
    protected HttpClientBuilder configureHttpClient(HttpClientBuilder builder) {
        builder.addInterceptorLast(requestInterceptor);
        return builder;
    }
    @Override
    protected HttpAsyncClientBuilder configureHttpClient(HttpAsyncClientBuilder builder) {
        builder.addInterceptorLast(requestInterceptor);
        return builder;
    }
};

The project can be found in maven central:

<dependency>
    <groupId>vc.inreach.aws</groupId>
    <artifactId>aws-signing-request-interceptor</artifactId>
    <version>0.0.22</version>
</dependency>

Other Languages

If you're looking for a native Scala version of the AWSSigner then take a look at @ticofab's port: https://github.com/ticofab/aws-request-signer

vc.inreach.aws

InReach Ventures

Scaling early stage investment across Europe through software

Versions

Version
0.0.22
0.0.21
0.0.20
0.0.18
0.0.17
0.0.16
0.0.15
0.0.14
0.0.13
0.0.12
0.0.11
0.0.10
0.0.9
0.0.8
0.0.7
0.0.6
0.0.5
0.0.4
0.0.3
0.0.2