king_hmac 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,8 +1,8 @@
1
- = king-hmac
1
+ = king_hmac
2
2
 
3
3
  This gem started with a copy & disection of auth-hmac gem v1.1.1
4
4
 
5
- king-hmac is a Ruby implementation of HMAC[http://en.wikipedia.org/wiki/HMAC]
5
+ king_hmac is a Ruby implementation of HMAC[http://en.wikipedia.org/wiki/HMAC]
6
6
  based authentication of HTTP requests. HMAC authentication involves a client and
7
7
  server having a shared secret key. When sending the request the client, signs
8
8
  the request using the secret key. This involves building a canonical
@@ -26,12 +26,12 @@ but without the Amazon specific components, i.e. it is HMAC for the rest of us.
26
26
 
27
27
  == INSTALL:
28
28
  Gem hosted on gemcutter.org
29
- sudo gem install king-hmac
29
+ sudo gem install king_hmac
30
30
 
31
31
  == Source Code
32
- See http://github.com/salesking/king-hmac
32
+ See http://github.com/salesking/king_hmac
33
33
  The source repository:
34
- git clone git://github.com/salesking/king-hmac.git
34
+ git clone git://github.com/salesking/king_hmac.git
35
35
 
36
36
  == When to use it?
37
37
 
@@ -126,7 +126,7 @@ following:
126
126
 
127
127
  The result is then Base64 encoded and added to the headers of the request as the
128
128
  +Authorization+ header in the format:
129
- Authorization: KingHmac::Auth <access_id>:<base64 encoded king-hmac>
129
+ Authorization: KingHmac::Auth <access_id>:<base64 encoded king_hmac>
130
130
 
131
131
  When authenaticating a request, KingHmac::Auth looks for the Authorization
132
132
  header in the above format, parses out the components, regenerates a HMAC for
@@ -140,6 +140,6 @@ KingHmac::Auth style requests in other languages.
140
140
 
141
141
  == Authors and Contributors
142
142
 
143
- This gem started with a copy & disection of auth-king-hmac gem v1.1.1.
143
+ This gem started with a copy & disection of auth-king_hmac gem v1.1.1.
144
144
  Most of this doc was written by Sean Geoghegan
145
- auth-king-hmac was developed by Sean Geoghegan http://rubyforge.org/projects/auth-king-hmac && by Peerworks[http://peerworks.org].
145
+ auth-king_hmac was developed by Sean Geoghegan http://rubyforge.org/projects/auth-king_hmac && by Peerworks[http://peerworks.org].
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0
1
+ 1.0.1
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{king_hmac}
8
- s.version = "1.0.0"
8
+ s.version = "1.0.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Georg Leciejewski"]
12
- s.date = %q{2010-04-10}
12
+ s.date = %q{2010-04-23}
13
13
  s.description = %q{A Ruby Gem for authenticating HTTP requests using a HMAC}
14
14
  s.email = %q{gl@salesking.eu}
15
15
  s.extra_rdoc_files = [
@@ -4,28 +4,29 @@ module KingHmac
4
4
  class Middleware
5
5
 
6
6
  # === Parameter
7
- # opts<Hash>::
7
+ # app<Object>:: Another Rack app, just a class responding to .call
8
+ # opts<Hash>:: {'keys'=>{'my_access_key'=>'my_secret'}, 'only'=>['a path', 'backend', 'api'] }
8
9
  # === opts params:
9
- # keys<Hash{String=>String}>:: Must be an array of accesskey=> secret
10
+ # keys<Hash{String=>String}>:: Multiple sets of accesskey=> secret
10
11
  # respond to the [] method and return a secret for access key id
11
- # only<Array[String]>:: path's to protect
12
+ # only<Array[String]>:: path's to protect ['admin', 'backend', 'api']
12
13
  def initialize(app, opts={})
13
14
  @app = app
14
15
  @opts = opts
15
- @plain_error = "HMAC Authentication failed. Get yourself a valid HMAC Key .. Dude .. or ask your admin to get you some credentials"
16
+ @error = "HMAC Authentication failed. Get yourself a valid HMAC Key .. Dude .. or ask your admin to get you some credentials"
16
17
  @hmac_auth = KingHmac::Auth.new(@opts['keys'])
17
18
  end
18
19
 
19
20
  def call(env)
20
- path = env['PATH_INFO']
21
+ path = env['PATH_INFO'] || '' #root path / does not have path info
21
22
  do_hmac_check = @opts['only'].detect{|i| path.include?(i) }
22
23
  if do_hmac_check
23
24
  unless hmac_authenticated?(::Rack::Request.new(env))
24
25
  headers = {'Content-Type' => "text/plain",
25
- 'Content-Length' => "#{@plain_error.length}",
26
+ 'Content-Length' => "#{@error.length}",
26
27
  'WWW-Authenticate' => 'AuthHMAC'
27
28
  }
28
- [401, headers, [@plain_error]]
29
+ [401, headers, [@error]]
29
30
  else #valid credentials
30
31
  @app.call(env)
31
32
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 0
8
- - 0
9
- version: 1.0.0
8
+ - 1
9
+ version: 1.0.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Georg Leciejewski
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-04-10 00:00:00 +02:00
17
+ date: 2010-04-23 00:00:00 +02:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency