Skip to content

Commit

Permalink
rename and format
Browse files Browse the repository at this point in the history
  • Loading branch information
Cory Mawhorter committed Mar 1, 2013
1 parent 7234a76 commit 7c1d9d0
Show file tree
Hide file tree
Showing 15 changed files with 184 additions and 127 deletions.
17 changes: 17 additions & 0 deletions .editorconfig
@@ -0,0 +1,17 @@
# editorconfig.org
root = true

[*]
indent_style = tab
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.js]
indent_style = space
indent_size = 2

[*.json]
indent_style = space
indent_size = 2
1 change: 0 additions & 1 deletion .gitignore
@@ -1,2 +1 @@
.idea
node_modules
1 change: 0 additions & 1 deletion .npmignore
@@ -1,2 +1 @@
/node_modules/
.idea
4 changes: 3 additions & 1 deletion .travis.yml
@@ -1,3 +1,5 @@
language: node_js
node_js:
- 0.8
- 0.6
- 0.7
- 0.8
46 changes: 46 additions & 0 deletions LICENSE
@@ -0,0 +1,46 @@
Copyright (c) 2012 Mark Wolfe
Copyright (c) 2013 Cory Mawhorter

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

Copyright (c) 2013 Cory Mawhorter

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
22 changes: 0 additions & 22 deletions LICENSE-MIT

This file was deleted.

42 changes: 19 additions & 23 deletions README.md
@@ -1,32 +1,31 @@
# ofuda
# hmmac (pronounced hammock)

HMAC authentication module for NodeJS.
HMAC authentication module and middleware for express/connect and node.

[![Build Status](https://secure.travis-ci.org/wolfeidau/ofuda.png)](http://travis-ci.org/wolfeidau/ofuda)
hmmac was forked from [ofuda](http://github.com/wolfeidau/ofuda).

[![Build Status](https://secure.travis-ci.org/cmawhorter/hmmac.png)](http://travis-ci.org/cmawhorter/hmmac)

## Getting Started
Install the module with: `npm install ofuda`
_Coming Soon_ npm install hmmac

```javascript
Ofuda = require('ofuda');
var Hmmac = require('hmmac');

var ofuda = new Ofuda({headerPrefix:'Amz', hash: 'sha1', serviceLabel: 'AWS', accessKeyId: '44CF9590006BF252F707', accessKeySecret: 'OtxrzxIsfpFjA7SwPzILwy8Bw21TLhquhboDYROV'});
var hmmac = new Hmmac({headerPrefix:'Amz', hash: 'sha1', serviceLabel: 'AWS', accessKeyId: '44CF9590006BF252F707', accessKeySecret: 'OtxrzxIsfpFjA7SwPzILwy8Bw21TLhquhboDYROV'});

ofuda.signHttpRequest(request); // appends a hmac authorisation header to the request
hmmac.signHttpRequest(request); // appends a hmac authorisation header to the request
```

## Documentation
_(Coming soon)_

## Examples

Use as a client is illustrated below.

```javascript
var http = require('http');
var Ofuda = require('ofuda');
var Hmmac = require('hmmac');

var ofuda = new Ofuda({headerPrefix:'Amz', hash: 'sha1', serviceLabel: 'AWS', debug: true});
var hmmac = new Hmmac({headerPrefix:'Amz', hash: 'sha1', serviceLabel: 'AWS', debug: true});

var credentials = {accessKeyId: '44CF9590006BF252F707', accessKeySecret: 'OtxrzxIsfpFjA7SwPzILwy8Bw21TLhquhboDYROV'};

Expand All @@ -41,7 +40,7 @@ http_options = {
}
};

signedOptions = ofuda.signHttpRequest(credentials, http_options);
signedOptions = hmmac.signHttpRequest(credentials, http_options);

var req = http.request(signedOptions, function(res) {
console.log('STATUS: ' + res.statusCode);
Expand All @@ -56,18 +55,18 @@ Use as a server is as follows.

```javascript
var http = require('http'),
Ofuda = require('ofuda');
Hmmac = require('hmmac');


var ofuda = new Ofuda({headerPrefix:'Amz', hash: 'sha1', serviceLabel: 'AWS', debug: true});
var hmmac = new Hmmac({headerPrefix:'Amz', hash: 'sha1', serviceLabel: 'AWS', debug: true});

var validateCredentials = function(requestAccessKeyId){
return {accessKeyId: requestAccessKeyId, accessKeySecret: 'OtxrzxIsfpFjA7SwPzILwy8Bw21TLhquhboDYROV'};
}

http.createServer(function (request, response) {

if(ofuda.validateHttpRequest(request, validateCredentials)){
if(hmmac.validateHttpRequest(request, validateCredentials)){
response.writeHead(200);
response.end('Success!');
} else {
Expand All @@ -80,12 +79,9 @@ http.createServer(function (request, response) {
console.log('Server running at http://127.0.0.1:8080/');
```

## Contributing
In lieu of a formal style guide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [grunt](https://github.com/cowboy/grunt).

## Release History
_(Nothing yet)_

## License
Copyright (c) 2012 Mark Wolfe
Copyright (c) 2012 Mark Wolfe
Licensed under the MIT license.

Copyright (c) 2013 Cory Mawhorter
Licensed under the MIT license.
6 changes: 3 additions & 3 deletions examples/app.js
@@ -1,15 +1,15 @@
var http = require('http'),
Ofuda = require('../lib/ofuda');
Hmmac = require('../lib/hmmac');

var ofuda = new Ofuda({headerPrefix:'Amz', hash: 'sha1', serviceLabel: 'AWS', debug: true});
var hmmac = new Hmmac({headerPrefix:'Amz', hash: 'sha1', serviceLabel: 'AWS', debug: true});

var validateCredentials = function(requestAccessKeyId){
return {accessKeyId: requestAccessKeyId, accessKeySecret: 'OtxrzxIsfpFjA7SwPzILwy8Bw21TLhquhboDYROV'};
}

http.createServer(function (request, response) {

if(ofuda.validateHttpRequest(request, validateCredentials)){
if(hmmac.validateHttpRequest(request, validateCredentials)){
response.writeHead(200);
response.end('Success!');
} else {
Expand Down
6 changes: 3 additions & 3 deletions examples/client.js
@@ -1,7 +1,7 @@
var http = require('http');
var Ofuda = require('../lib/ofuda');
var Hmmac = require('../lib/hmmac');

var ofuda = new Ofuda({headerPrefix: 'Amz', hash: 'sha1', serviceLabel: 'AWS', debug: true});
var hmmac = new Hmmac({headerPrefix: 'Amz', hash: 'sha1', serviceLabel: 'AWS', debug: true});

var credentials = {accessKeyId: '44CF9590006BF252F707', accessKeySecret: 'OtxrzxIsfpFjA7SwPzILwy8Bw21TLhquhboDYROV'};

Expand All @@ -17,7 +17,7 @@ http_options = {
}
};

signedOptions = ofuda.signHttpRequest(credentials, http_options);
signedOptions = hmmac.signHttpRequest(credentials, http_options);

var req = http.request(signedOptions, function (res) {
console.log('STATUS: ' + res.statusCode);
Expand Down

0 comments on commit 7c1d9d0

Please sign in to comment.