Git Product home page Git Product logo

aws-sign4's Introduction

Common Lisp library for Amazon Web Services signing version 4.

Project home: https://github.com/rotatef/aws-sign4

This library implements the Signature Version 4 Signing Process, as described here: http://docs.aws.amazon.com/general/latest/gr/signature-version-4.html

Highlights:

  • Passes all tests in the test suite from Amazon.
  • Tested on ABCL, ACL, CCL, CLISP and SBCL.
  • Signing only, not tied to a specific http client library.

Example

See example.lisp for an example of using Drakma to make a request to SWF.

S3 supports presigned URL. This make is possible to give a web browser temporary access to download an object directly from S3. Example:

(let ((aws-sign4:*aws-credentials*
        (lambda ()
          (values "AKIAIOSFODNN7EXAMPLE" "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"))))
  (aws-sign4:aws-sign4 :region :eu-west-1
                       :service :s3
                       :host "s3-eu-west-1.amazonaws.com"
                       :path "/some-bucket/some-file"
                       :expires 300)) 
=> "https://s3-eu-west-1.amazonaws.com/some-bucket/some-file?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIOSFODNN7EXAMPLE%2F20170908%2Feu-west-1%2Fs3%2Faws4_request&X-Amz-Date=20170908T121925Z&X-Amz-Expires=300&X-Amz-SignedHeaders=host&X-Amz-Signature=42c841837976e9c206f80554b50aa879fdb3aa4f3e6f61934ce8eba436205abf                      

API

Variable

AWS-SIGN4:*AWS-CREDENTIALS*

Bind this variable to a function returning two values, the access key and the secret key.

AWS-SIGN4:AWS-SIGN4 &key ...

Calculates the signature for a http request.

Parameters:

  • region - String designator for the AWS region. Default "us-east-1".
  • service - String designator for the AWS service name.
  • method - String designator for the http method.
  • host - The hostname/endpoint to for the request. Default is the value of the host header.
  • path - The path part of the request URI.
  • params - The query parameters of the URI as an assoc list.
  • headers - The headers as an assoc list as an assoc list.
  • payload - The payload, as a string or vector of octets. Strings are encoded to octets using UTF-8.
  • date-header - The name of the date-header, :X-AMZ-DATE or :DATE. Default :X-AMZ-DATE.
  • request-date - The request date as a local-time timestamp. Default (LOCAL-TIME:NOW).
  • expires - Provides the time period, in seconds, for which the generated presigned URL is valid.
  • scheme - Scheme used in presigned URL, defaults to https.

Returns seven values. Only the two first are needed, the others are useful for debugging.

  • If expire is nil or not supplied, the value of "Authorization" header. If expire is supplied, the presigned URL.
  • Value of "X-Amz-Date" or "Date" header.
  • Canonical request
  • String to sign
  • Credential scope
  • Signed headers
  • Signature

aws-sign4's People

Contributors

bakketun avatar fukamachi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

aws-sign4's Issues

GET requests and the payload parameter

In GET requests one must provide :payload "" in order to generate valid signatures. This is confusing and unnecessary.

This creates an invalid signature:
(aws-sign4:aws-sign4 :region :us-east-1
:service "route53"
:method :get
:host "route53.amazonaws.com"
:path "/2013-04-01/hostedzone")

This generates a valid signature:
(aws-sign4:aws-sign4 :region :us-east-1
:service "route53"
:method :get
:payload ""
:host "route53.amazonaws.com"
:path "/2013-04-01/hostedzone")

Test fails on CCL

Disabling tests on CCL until this is fixed:
fd7e8ce

Current version in cl-travis is 1.10. The latest version of ironclad can't be loaded with this version of CCL. I get the following error message: Unknown X86 instruction (CCL::RETQ)

luismbo/cl-travis#20

Behaviour when service is undefined

When the signing function is called with service bound to nil, the credential scope value features the string nil which should probably not happen.

The correct behaviour should be to either:

  • Signal an error, with a retry allowing to provide a service string.
  • Provide a sensible default string value for the service. This could be "service" as in AWS test suite for signv4, the empty string or a phony value "this-is-not-an-actual-service-name".

My personal preference goes to the first possibility. What do you think?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.