Skip to content

Commit 0730fe9

Browse files
committed
readme
1 parent 0702066 commit 0730fe9

File tree

1 file changed

+68
-2
lines changed

1 file changed

+68
-2
lines changed

README.md

Lines changed: 68 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,74 @@
11
aws-request-signer
2-
===
2+
==================
33

4-
Helper to evaluate the signing headers for HTTP requests to Amazon Web Services. This is a Scala port of the Java [aws-signing-request-interceptor](https://github.com/inreachventures/aws-signing-request-interceptor).
4+
Helper to evaluate the signing headers for HTTP requests to Amazon Web Services. This is a Scala port of (part of) the Java [aws-signing-request-interceptor](https://github.com/inreachventures/aws-signing-request-interceptor).
55

66
I originally needed this library to support AWS' [Elasticsearch Service](https://aws.amazon.com/elasticsearch-service/), but this library is 'AWS service agnostic'.
77

88

9+
Import via SBT
10+
--------------
11+
12+
In your build.sbt file,
13+
14+
```sbt
15+
resolvers += Resolver.jcenterRepo
16+
17+
libraryDependencies += "io.ticofab" %% "aws-request-signer" % "0.1.0"
18+
```
19+
20+
Usage
21+
-----
22+
23+
The procedure to sign AWS Api requests is described on the [official documentation](http://docs.aws.amazon.com/general/latest/gr/sigv4_signing.html). The idea is that each request must be signed through the evaluation of a hash which depends on the very request itself. The resulting string can then be added to the request either as a header or as a query param. This library focuses on the header way.
24+
25+
You first need to instantiate the signer, for example:
26+
27+
```scala
28+
val awsCredentialProvider = new StaticCredentialsProvider(new BasicAWSCredentials("YOUR-ID", "YOUR-SECRET"))
29+
val service = "es"
30+
val region = "eu-central-1"
31+
def clock(): DateTime = DateTime.now
32+
val signer = AwsSigner(awsCredentialProvider, region, service, clock)
33+
```
34+
35+
Then use it for each request, via
36+
37+
```scala
38+
def getSignedHeaders(uri: String,
39+
method: String,
40+
queryParams: Map[String, String],
41+
headers: Map[String, String],
42+
payload: Option[Array[Byte]]): Map[String, String]
43+
```
44+
45+
46+
Check the examples in the test folder of this project. Once you have the headers, add them to your HTTP request and fire it.
47+
48+
49+
Dependencies
50+
------------
51+
52+
* [AWS Java SDK][1]
53+
* [ScalaTest][2]
54+
55+
License
56+
--------
57+
58+
Copyright 2015 Fabio Tiriticco - Fabway
59+
60+
Licensed under the Apache License, Version 2.0 (the "License");
61+
you may not use this file except in compliance with the License.
62+
You may obtain a copy of the License at
63+
64+
http://www.apache.org/licenses/LICENSE-2.0
65+
66+
Unless required by applicable law or agreed to in writing, software
67+
distributed under the License is distributed on an "AS IS" BASIS,
68+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
69+
See the License for the specific language governing permissions and
70+
limitations under the License.
71+
72+
[1]: https://aws.amazon.com/sdk-for-java/
73+
[2]: http://www.scalatest.org
74+

0 commit comments

Comments
 (0)