Skip to content

jnngrm/authorization-hmac256

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

authorization-hmac256

Amazon style authorization using HMAC-SHA256 signing.

installation

$ npm install --save authorization-hmac256

options

  • service: (STRING) the name of the service, typically acronym like AWS or CWS (Classy Web Services)
  • token: (STRING) unique identifier for client making call, like OAuth2 client ID
  • secret: (STRING) secret value used for signing

usage

HmacAuthorize.sign(method, path, contentType, body)

const request = require('request');
const HmacAuthorize = require('authorization-hmac256')({
  service: 'service',
  token: 'token',
  secret: 'secret'
});

function postSomething(next) {
  let method = 'POST';
  let resource = '/sample/resource';
  let contentType = 'application/json';
  let body = {
    key: 'value'
  };
  let authorization = HmacAuthorize.sign(method, resource, contentType, JSON.stringify(body));
  request({
    url: 'http://api.acme.org',
    method,
    headers: {
      'Content-Type': contentType,
      'Authorization': authorization
    },
    body: JSON.stringify(body)
  }, next);
}

About

Amazon style authorization using signing.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •