Skip to content
Lua resty module to calculate AWS signature v4 authorization header
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib/resty adding query string args Jun 28, 2017
t
Makefile Adding Makefile install task Jun 23, 2017
README.md update readme Dec 7, 2016
lua-resty-aws-auth-0.11-0.src.rock
lua-resty-aws-auth-0.12-0.rockspec update version string Jan 13, 2017

README.md

lua-resty-aws-auth

Simple lua resty utilities to generate amazon v4 authorization and signature headers.

Installation

Openresty installation should be compiled with --with-luajit directive otherwise you will get an error,

module 'ffi' not found

Install the package using luarocks

#luarocks install lua-resty-aws-auth

Usage

local aws_auth = require "resty.aws-auth"
local config = {
  aws_host       = "email.us-east-1.amazonaws.com",
  aws_key        = "AKIDEXAMPLE",
  aws_secret     = "xxxsecret",
  aws_region     = "us-east-1",
  aws_service    = "ses",
  content_type   = "application/x-www-form-urlencoded",
  request_method = "POST",
  request_path   = "/",
  request_body   = { hello="world" } -- table of all request params
}

local aws = aws_auth:new(config)

-- get the generated authorization header
-- eg: AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/iam/aws4_request,
---    SignedHeaders=content-type;host;x-amz-date, Signature=xxx
local auth = aws:get_authorization_header()

-- get the x-amz-date header
local amz_date = aws:get_amz_date_header()

Add Authorization and x-amz-date header to ngx.req.headers

aws:set_ngx_auth_headers()

Reference Signing AWS With Signature V4 AWS service namespaces list AWS region and endpoints

You can’t perform that action at this time.