hawk-auth 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE +27 -0
- data/README.md +96 -0
- data/Rakefile +1 -0
- data/hawk-auth.gemspec +22 -0
- data/lib/hawk.rb +6 -0
- data/lib/hawk/version.rb +3 -0
- metadata +85 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
Copyright (c) 2013 Apollic Software, LLC. All rights reserved.
|
2
|
+
|
3
|
+
Redistribution and use in source and binary forms, with or without
|
4
|
+
modification, are permitted provided that the following conditions are
|
5
|
+
met:
|
6
|
+
|
7
|
+
* Redistributions of source code must retain the above copyright
|
8
|
+
notice, this list of conditions and the following disclaimer.
|
9
|
+
* Redistributions in binary form must reproduce the above
|
10
|
+
copyright notice, this list of conditions and the following disclaimer
|
11
|
+
in the documentation and/or other materials provided with the
|
12
|
+
distribution.
|
13
|
+
* Neither the name of Apollic Software, LLC nor the names of its
|
14
|
+
contributors may be used to endorse or promote products derived from
|
15
|
+
this software without specific prior written permission.
|
16
|
+
|
17
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
18
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
19
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
20
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
21
|
+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
22
|
+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
23
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
24
|
+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
25
|
+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
26
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
27
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/README.md
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
# Hawk
|
2
|
+
|
3
|
+
Ruby implementation of [Hawk HTTP authentication scheme](https://github.com/hueniverse/hawk).
|
4
|
+
|
5
|
+
**Authorization Request Header**
|
6
|
+
|
7
|
+
```
|
8
|
+
Authorization: Hawk id="{credentials id}", ts="{epoch timestamp}", nonce="{nonce}", hash="{hash}", ext="{ext}", mac="{mac}", app="{application id}", d1g="{d1g}"
|
9
|
+
```
|
10
|
+
|
11
|
+
`hash`, `ext`, `app`, and `d1g` should only be included if used in mac function.
|
12
|
+
|
13
|
+
**Authorization Response Header**
|
14
|
+
|
15
|
+
```
|
16
|
+
Server-Authorization: Hawk mac="{mac}", hash="{hash}", ext="{ext}"
|
17
|
+
```
|
18
|
+
|
19
|
+
`mac` is constructed using the same params as in the request with the exception of `hash` and `ext` which are replaced with new values.
|
20
|
+
|
21
|
+
`hash` and `ext` are both optional.
|
22
|
+
|
23
|
+
**MAC Function**
|
24
|
+
|
25
|
+
```
|
26
|
+
base-64(
|
27
|
+
hmac-{algorithm (e.g. sha-256)}(
|
28
|
+
hawk.{hawk version}.{type}
|
29
|
+
{epoch timestamp}
|
30
|
+
{nonce}
|
31
|
+
{uppercase request method}
|
32
|
+
{lowercase request path}
|
33
|
+
{lowercase request host}
|
34
|
+
{request port}
|
35
|
+
{hash (see below) or empty line}
|
36
|
+
{ext (optional)}
|
37
|
+
{application id (optional)}
|
38
|
+
{application id digest (requires application id)}
|
39
|
+
)
|
40
|
+
)
|
41
|
+
```
|
42
|
+
|
43
|
+
**Payload Hash Function**
|
44
|
+
|
45
|
+
```
|
46
|
+
base-64(
|
47
|
+
digest-{algorithm (e.g. sha-256)}(
|
48
|
+
hawk.#{hawk version}.payload
|
49
|
+
{plain content-type (e.g. application/json)}
|
50
|
+
{request payload or empty line}
|
51
|
+
)
|
52
|
+
)
|
53
|
+
```
|
54
|
+
|
55
|
+
**Bewit MAC Function**
|
56
|
+
|
57
|
+
```
|
58
|
+
base-64(
|
59
|
+
{credentials id} + \ + {expiry epoch timestamp} + \ + hmac-{algorithm (e.g. sha-256)}(
|
60
|
+
hawk.{hawk version}.bewit
|
61
|
+
{epoch timestamp}
|
62
|
+
{nonce}
|
63
|
+
{uppercase request method}
|
64
|
+
{lowercase request path}
|
65
|
+
{lowercase request host}
|
66
|
+
{request port}
|
67
|
+
{ext (optional)}
|
68
|
+
) + \ + {ext or empty}
|
69
|
+
)
|
70
|
+
```
|
71
|
+
|
72
|
+
## Installation
|
73
|
+
|
74
|
+
Add this line to your application's Gemfile:
|
75
|
+
|
76
|
+
gem 'hawk-auth'
|
77
|
+
|
78
|
+
And then execute:
|
79
|
+
|
80
|
+
$ bundle
|
81
|
+
|
82
|
+
Or install it yourself as:
|
83
|
+
|
84
|
+
$ gem install hawk-auth
|
85
|
+
|
86
|
+
## Usage
|
87
|
+
|
88
|
+
TODO: write usage instructions
|
89
|
+
|
90
|
+
## Contributing
|
91
|
+
|
92
|
+
1. Fork it
|
93
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
94
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
95
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
96
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/hawk-auth.gemspec
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'hawk/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "hawk-auth"
|
8
|
+
gem.version = Hawk::VERSION
|
9
|
+
gem.authors = ["Jesse Stuart"]
|
10
|
+
gem.email = ["jesse@jessestuart.ca"]
|
11
|
+
gem.description = "Ruby implementation of Hawk"
|
12
|
+
gem.summary = "Ruby implementation of Hawk"
|
13
|
+
gem.homepage = ""
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
gem.add_development_dependency "bundler", "~> 1.3"
|
21
|
+
gem.add_development_dependency "rake"
|
22
|
+
end
|
data/lib/hawk.rb
ADDED
data/lib/hawk/version.rb
ADDED
metadata
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: hawk-auth
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Jesse Stuart
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-04-11 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.3'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.3'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rake
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
description: Ruby implementation of Hawk
|
47
|
+
email:
|
48
|
+
- jesse@jessestuart.ca
|
49
|
+
executables: []
|
50
|
+
extensions: []
|
51
|
+
extra_rdoc_files: []
|
52
|
+
files:
|
53
|
+
- .gitignore
|
54
|
+
- Gemfile
|
55
|
+
- LICENSE
|
56
|
+
- README.md
|
57
|
+
- Rakefile
|
58
|
+
- hawk-auth.gemspec
|
59
|
+
- lib/hawk.rb
|
60
|
+
- lib/hawk/version.rb
|
61
|
+
homepage: ''
|
62
|
+
licenses: []
|
63
|
+
post_install_message:
|
64
|
+
rdoc_options: []
|
65
|
+
require_paths:
|
66
|
+
- lib
|
67
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
68
|
+
none: false
|
69
|
+
requirements:
|
70
|
+
- - ! '>='
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ! '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
requirements: []
|
80
|
+
rubyforge_project:
|
81
|
+
rubygems_version: 1.8.23
|
82
|
+
signing_key:
|
83
|
+
specification_version: 3
|
84
|
+
summary: Ruby implementation of Hawk
|
85
|
+
test_files: []
|