Skip to content

Middleware to add AWS signature v4 signing to clj-http requests.

Notifications You must be signed in to change notification settings

sharetribe/aws-sig4

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

aws-sig4

AWS signature v4 request signing implemented as an clj-http middleware. This is a pure clojure implementation and does not require the AWS SDK. It only provides the middleware and doesn't do anything else like autodetecting AWS credentials. Providing correct credentials, region and service name is the responsibility of caller.

This library has seen only limited production use so far. Bugs and problems may exist. Please file issues if you encounter any problems.

Circle CI

Installation

With Leiningen/Boot:

[org.sharetribe/aws-sig4 "0.1.4"]

Usage

Require clj-http client and the middleware.

(require '[aws-sig4.middleware :as aws-sig4]
         '[clj-http.client :as http])

Build an auth middleware instance by passing in AWS parameters.

(def wrap-aws-auth (aws-sig4/build-wrap-aws-auth {:region "us-east-1"
                                                  :service "es"
                                                  :access-key "AWS_ACCESS_KEY"
                                                  :secret-key "AWS_SECRET_KEY"
                                                  :token "AWS_SESSION_TOKEN" ; optional
                                                  }))

Wrap outgoing requests with the middleware instance. Optionally include wrap-aws-date to ensure that all requests have either the required Date header, or if not generate X-Amz-Date header. wrap-aws-date must be defined first in the middleware chain.

(http/with-additional-middleware
  [wrap-aws-auth aws-sig4/wrap-aws-date]
  (http/get "https://my-es-instance.us-east-1.es.amazonaws.com/_cat/indices"))

That's it.

Hint: Consider using temporary security credentials when accessing AWS services.

License

Copyright © 2015 Sharetribe Ltd.

Distributed under The Apache License, Version 2.0

About

Middleware to add AWS signature v4 signing to clj-http requests.

Resources

Stars

Watchers

Forks

Packages

No packages published