AWS V4 signing algorithm for OkHttp requests
Clone or download
Latest commit d1cec5c Dec 21, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.idea Initial commit Dec 21, 2018
okhttp-aws-signer Initial commit Dec 21, 2018
.gitignore Initial commit Dec 21, 2018
.jitpack.yml Initial commit Dec 21, 2018
LICENSE Initial commit Dec 21, 2018
README.md Initial commit Dec 21, 2018
build.gradle Initial commit Dec 21, 2018
gradle.properties Initial commit Dec 21, 2018
gradlew Initial commit Dec 21, 2018
gradlew.bat Initial commit Dec 21, 2018
libraries.gradle Initial commit Dec 21, 2018
maven-jar.gradle Initial commit Dec 21, 2018
settings.gradle Initial commit Dec 21, 2018
wrapper.gradle Initial commit Dec 21, 2018

README.md

Okhttp AWS Signer

This is a kotlin library that implements the AWS V4 signing algorithm described here for the OkHttp requests. It has no dependency on the Amazon sdks.

Getting the library

Currently the easiest way to get the library is by using JitPack

dependencies {
    implementation 'com.github.babbel:okhttp-aws-signer:<tag>'
}

You can also create a fat JAR by executing the gradle task shadowJar. This task comes from the shadow plugin.

Usage

You'll need to first setup the signer object:

val signer = OkHttpAwsV4Signer(region, serviceName)

region is the region you have your services running, i.e., eu-west-1.

serviceName should be the name of the service your calling, i.e., execute-api.

Once you have a request you can easily sign it with:

val newRequest = signer.sign(request, accessKeyId, accessKey)

The signing algorithm requires that the host and the x-amz-date headers be present in the request prior to signing. Please make sure to include them. The x-amz-date header must be formatted with the pattern "yyyyMMdd'T'HHmmss'Z'".

Developing

All changes are welcomed in the form of PRs. Please explain the change in the PR's description. We'll make our best to be swift in getting it through.

The gradle wrapper is not versioned under the repo, but can be easily downloaded by executing the task wrapper inside the file wrapper.gradle. A typical execution of this looks like:

gradle wrapper -b wrapper.gradle

To run the tests, please execute:

./gradlew clean test