rack-simple_auth 1.0.0rc → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -7
- data/MANIFEST +26 -26
- data/README.rdoc +121 -0
- data/checksum/rack-simple_auth-1.0.0.gem.sha512 +1 -0
- data/checksum/rack-simple_auth-1.0.0rc.gem.sha512 +1 -0
- data/doc/Rack.html +128 -0
- data/doc/Rack/SimpleAuth.html +252 -0
- data/doc/Rack/SimpleAuth/HMAC.html +128 -0
- data/doc/Rack/SimpleAuth/HMAC/Config.html +1003 -0
- data/doc/Rack/SimpleAuth/HMAC/Middleware.html +1418 -0
- data/doc/Rack/SimpleAuth/Logger.html +264 -0
- data/doc/_index.html +185 -0
- data/doc/class_list.html +54 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +57 -0
- data/doc/css/style.css +339 -0
- data/doc/examples/index.php +32 -0
- data/{test/rack/simple_auth/hmac/config.ru → doc/examples/rack_lobster.ru} +1 -2
- data/doc/file.README.html +221 -0
- data/doc/file_list.html +56 -0
- data/doc/frames.html +26 -0
- data/doc/index.html +221 -0
- data/doc/js/app.js +219 -0
- data/doc/js/full_list.js +178 -0
- data/doc/js/jquery.js +4 -0
- data/doc/method_list.html +179 -0
- data/doc/top-level-namespace.html +112 -0
- data/lib/rack/simple_auth.rb +3 -1
- data/lib/rack/simple_auth/hmac/config.rb +46 -8
- data/lib/rack/simple_auth/hmac/middleware.rb +102 -75
- data/lib/rack/simple_auth/logger.rb +8 -3
- data/lib/rack/simple_auth/version.rb +1 -1
- metadata +91 -105
- data/.gitignore +0 -18
- data/.rubocop.yml +0 -1
- data/.travis.yml +0 -22
- data/.yardopts +0 -1
- data/Gemfile +0 -4
- data/README.md +0 -68
- data/Rakefile +0 -8
- data/rubocop-todo.yml +0 -19
- data/task/build.rake +0 -4
- data/task/checksum.rake +0 -15
- data/task/console.rake +0 -7
- data/task/default.rake +0 -6
- data/task/floodtest.rake +0 -34
- data/task/manifest.rake +0 -8
- data/task/test.rake +0 -23
- data/test/rack/simple_auth/hmac/config_fail.ru +0 -23
- data/test/rack/simple_auth/hmac/config_fail_option.ru +0 -24
- data/test/rack/simple_auth/hmac/config_fail_run.ru +0 -22
- data/test/rack/simple_auth/hmac/config_fail_step.ru +0 -23
- data/test/rack/simple_auth/hmac/config_fail_tolerance.ru +0 -23
- data/test/rack/simple_auth/hmac/hmac_fail_run_test.rb +0 -26
- data/test/rack/simple_auth/hmac/hmac_fail_test.rb +0 -38
- data/test/rack/simple_auth/hmac/hmac_test.rb +0 -128
- data/test/test_helper.rb +0 -50
data/.gitignore
DELETED
data/.rubocop.yml
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
inherit_from: rubocop-todo.yml
|
data/.travis.yml
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
cache: bundler
|
3
|
-
|
4
|
-
before_install:
|
5
|
-
- gem update --system
|
6
|
-
- gem --version
|
7
|
-
- gem install bundler
|
8
|
-
|
9
|
-
rvm:
|
10
|
-
- 2.0.0
|
11
|
-
- 2.1.0
|
12
|
-
- 2.1.1
|
13
|
-
- ruby-head
|
14
|
-
- jruby
|
15
|
-
- rbx
|
16
|
-
|
17
|
-
matrix:
|
18
|
-
allow_failures:
|
19
|
-
- rvm: jruby
|
20
|
-
- rvm: ruby-head
|
21
|
-
|
22
|
-
script: "env COVERAGE=true bundle exec rake"
|
data/.yardopts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
--private
|
data/Gemfile
DELETED
data/README.md
DELETED
@@ -1,68 +0,0 @@
|
|
1
|
-
# Rack::SimpleAuth
|
2
|
-
|
3
|
-
Rack::SimpleAuth will contain different Authentication Class Middlewares
|
4
|
-
|
5
|
-
Until now only HMAC is implemented...
|
6
|
-
|
7
|
-
## Installation
|
8
|
-
|
9
|
-
Add this line to your application's Gemfile:
|
10
|
-
|
11
|
-
gem 'rack-simple_auth'
|
12
|
-
|
13
|
-
And then execute:
|
14
|
-
|
15
|
-
$ bundle
|
16
|
-
|
17
|
-
Or install it yourself as:
|
18
|
-
|
19
|
-
$ gem install rack-simple_auth
|
20
|
-
|
21
|
-
## Gem Status
|
22
|
-
|
23
|
-
[![Build Status](https://travis-ci.org/Benny1992/rack-simple_auth.png?branch=master)](https://travis-ci.org/Benny1992/rack-simple_auth)
|
24
|
-
[![Coverage Status](https://coveralls.io/repos/Benny1992/rack-simple_auth/badge.png?branch=master)](https://coveralls.io/r/Benny1992/rack-simple_auth?branch=master)
|
25
|
-
[![Gem Version](https://badge.fury.io/rb/rack-simple_auth.png)](http://badge.fury.io/rb/rack-simple_auth)
|
26
|
-
[![Dependency Status](https://gemnasium.com/Benny1992/rack-simple_auth.png)](https://gemnasium.com/Benny1992/rack-simple_auth)
|
27
|
-
[![Codeship](https://www.codeship.io/projects/f2d9d790-b0fe-0131-3fd5-025f180094b5/status)](https://www.codeship.io/projects/f2d9d790-b0fe-0131-3fd5-025f180094b5/status)
|
28
|
-
|
29
|
-
## Usage
|
30
|
-
|
31
|
-
### HMAC
|
32
|
-
|
33
|
-
To use HMAC Authorization you have to use the ```Rack::SimpleAuth::HMAC::Middleware``` for your Rack App
|
34
|
-
|
35
|
-
Basic Usage:
|
36
|
-
```ruby
|
37
|
-
require 'rack/lobster'
|
38
|
-
require 'rack/simple_auth'
|
39
|
-
|
40
|
-
request_config = {
|
41
|
-
'GET' => 'path',
|
42
|
-
'POST' => 'params',
|
43
|
-
'DELETE' => 'path',
|
44
|
-
'PUT' => 'path',
|
45
|
-
'PATCH' => 'path'
|
46
|
-
}
|
47
|
-
|
48
|
-
use Rack::SimpleAuth::HMAC::Middleware do |options|
|
49
|
-
options.tolerance = 0.5
|
50
|
-
options.stepsize = 0.01
|
51
|
-
|
52
|
-
options.secret = 'test_secret'
|
53
|
-
options.signature = 'test_signature'
|
54
|
-
|
55
|
-
options.logpath = "#{File.expand_path('..', __FILE__)}/logs"
|
56
|
-
options.request_config = request_config
|
57
|
-
end
|
58
|
-
|
59
|
-
run Rack::Lobster.new
|
60
|
-
```
|
61
|
-
|
62
|
-
## Contributing
|
63
|
-
|
64
|
-
1. Fork it ( http://github.com/benny1992/rack-simple_auth/fork )
|
65
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
66
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
67
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
68
|
-
5. Create new Pull Request
|
data/Rakefile
DELETED
data/rubocop-todo.yml
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
# This configuration was generated by `rubocop --auto-gen-config`
|
2
|
-
# on 2014-04-23 23:22:22 +0200 using RuboCop version 0.20.1.
|
3
|
-
# The point is for the user to remove these configuration records
|
4
|
-
# one by one as the offenses are removed from the code base.
|
5
|
-
# Note that changes in the inspected code, or installation of new
|
6
|
-
# versions of RuboCop, may require this file to be generated again.
|
7
|
-
|
8
|
-
# Offense count: 1
|
9
|
-
CyclomaticComplexity:
|
10
|
-
Max: 7
|
11
|
-
|
12
|
-
# Offense count: 55
|
13
|
-
LineLength:
|
14
|
-
Max: 150
|
15
|
-
|
16
|
-
# Offense count: 3
|
17
|
-
# Configuration parameters: CountComments.
|
18
|
-
MethodLength:
|
19
|
-
Max: 16
|
data/task/build.rake
DELETED
data/task/checksum.rake
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
require 'digest/sha2'
|
2
|
-
|
3
|
-
desc 'Creates a SHA512 checksum of the current version'
|
4
|
-
task :checksum do
|
5
|
-
checksums = File.expand_path('../../checksum', __FILE__)
|
6
|
-
name = "#{GEMSPEC.name}-#{GEMSPEC.version}.gem"
|
7
|
-
path = File.join(File.expand_path('../../pkg', __FILE__), name)
|
8
|
-
|
9
|
-
checksum_name = File.basename(path) + '.sha512'
|
10
|
-
checksum = Digest::SHA512.new.hexdigest(File.read(path))
|
11
|
-
|
12
|
-
File.open(File.join(checksums, checksum_name), 'w') do |handle|
|
13
|
-
handle.write(checksum)
|
14
|
-
end
|
15
|
-
end
|
data/task/console.rake
DELETED
data/task/default.rake
DELETED
data/task/floodtest.rake
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
test_runs = if ENV['TESTS']
|
2
|
-
Integer(ENV['TESTS'])
|
3
|
-
else
|
4
|
-
30
|
5
|
-
end
|
6
|
-
|
7
|
-
namespace :floodtest do
|
8
|
-
desc 'Run Unit floodtest (default 30 tests, configurable via ENV["TESTS"])'
|
9
|
-
task :unit do
|
10
|
-
1.upto(test_runs) do |i|
|
11
|
-
puts "Running test #{i} of #{test_runs}"
|
12
|
-
exit(-1) if !system('bundle exec rake test:unit')
|
13
|
-
Rake::Task['test:cleanup'].invoke
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
# desc 'Run Spec floodtest (default 30 tests, configurable via ENV["TESTS"])'
|
18
|
-
# task :spec do
|
19
|
-
# 1.upto(test_runs) do |i|
|
20
|
-
# puts "Running test #{i} of #{test_runs}"
|
21
|
-
# exit(-1) if !system('bundle exec rake test:spec ')
|
22
|
-
# end
|
23
|
-
# end
|
24
|
-
|
25
|
-
# desc 'Run Feature floodtest (default 30 tests, configurable via ENV["TESTS"])'
|
26
|
-
# task :feature do
|
27
|
-
# 1.upto(test_runs) do |i|
|
28
|
-
# puts "Running test #{i} of #{test_runs}"
|
29
|
-
# exit(-1) if !system('bundle exec rake test:feature')
|
30
|
-
# end
|
31
|
-
# end
|
32
|
-
end
|
33
|
-
|
34
|
-
|
data/task/manifest.rake
DELETED
data/task/test.rake
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
namespace :test do
|
2
|
-
Rake::TestTask.new(:unit) do |t|
|
3
|
-
t.libs << "test" << "bin" << "ext" << "controllers" << "helpers" << "models"
|
4
|
-
t.test_files = FileList['test/**/*_test.rb']
|
5
|
-
t.verbose = true
|
6
|
-
end
|
7
|
-
|
8
|
-
# Rake::TestTask.new(:spec) do |t|
|
9
|
-
# t.libs << "spec" << "bin" << "ext" << "controllers" << "helpers" << "models"
|
10
|
-
# t.test_files = FileList['spec/**/*_spec.rb']
|
11
|
-
# t.verbose = true
|
12
|
-
# end
|
13
|
-
|
14
|
-
# Cucumber::Rake::Task.new(:feature) do |t|
|
15
|
-
# t.cucumber_opts = "features --format pretty"
|
16
|
-
# end
|
17
|
-
|
18
|
-
task :cleanup do
|
19
|
-
system("rm -rf #{File.expand_path('../../', __FILE__)}/test/rack/simple_auth/hmac/logs")
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
|
@@ -1,23 +0,0 @@
|
|
1
|
-
require 'rack/lobster'
|
2
|
-
require 'rack/simple_auth'
|
3
|
-
|
4
|
-
request_config = {
|
5
|
-
'GET' => 'pathasdf',
|
6
|
-
'POST' => 'paramas',
|
7
|
-
'DELETE' => 'path',
|
8
|
-
'PUT' => 'path',
|
9
|
-
'PATCH' => 'path',
|
10
|
-
}
|
11
|
-
|
12
|
-
use Rack::SimpleAuth::HMAC::Middleware do |options|
|
13
|
-
options.tolerance = 0.5
|
14
|
-
options.stepsize = 0.01
|
15
|
-
|
16
|
-
options.secret = 'test_secret'
|
17
|
-
options.signature = 'test_signature'
|
18
|
-
|
19
|
-
options.logpath = "#{File.expand_path('..', __FILE__)}/logs"
|
20
|
-
options.request_config = request_config
|
21
|
-
end
|
22
|
-
|
23
|
-
run Rack::Lobster.new
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'rack/lobster'
|
2
|
-
require 'rack/simple_auth'
|
3
|
-
|
4
|
-
request_config = {
|
5
|
-
'GET' => 'path',
|
6
|
-
'POST' => 'params',
|
7
|
-
'DELETE' => 'path',
|
8
|
-
'PUT' => 'path',
|
9
|
-
'PATCH' => 'path'
|
10
|
-
}
|
11
|
-
|
12
|
-
use Rack::SimpleAuth::HMAC::Middleware do |options|
|
13
|
-
options.tolerance = 0.5
|
14
|
-
options.stepsize = 0.01
|
15
|
-
|
16
|
-
options.secret = 'test_secret'
|
17
|
-
options.signature = 'test_signature'
|
18
|
-
|
19
|
-
options.logpath = "#{File.expand_path('..', __FILE__)}/logs"
|
20
|
-
options.request_config = request_config
|
21
|
-
options.unknown_option = 'unknown'
|
22
|
-
end
|
23
|
-
|
24
|
-
run Rack::Lobster.new
|
@@ -1,22 +0,0 @@
|
|
1
|
-
require 'rack/lobster'
|
2
|
-
require 'rack/simple_auth'
|
3
|
-
|
4
|
-
request_config = {
|
5
|
-
'GET' => 'pathasdf',
|
6
|
-
'POST' => 'paramas',
|
7
|
-
'DELETE' => 'path',
|
8
|
-
'PUT' => 'path',
|
9
|
-
'PATCH' => 'path',
|
10
|
-
}
|
11
|
-
|
12
|
-
# Middleware should not be runnable...
|
13
|
-
run Rack::SimpleAuth::HMAC::Middleware do |options|
|
14
|
-
options.tolerance = 0.5
|
15
|
-
options.stepsize = 0.01
|
16
|
-
|
17
|
-
options.secret = 'test_secret'
|
18
|
-
options.signature = 'test_signature'
|
19
|
-
|
20
|
-
options.logpath = "#{File.expand_path('..', __FILE__)}/logs"
|
21
|
-
options.request_config = request_config
|
22
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
require 'rack/lobster'
|
2
|
-
require 'rack/simple_auth'
|
3
|
-
|
4
|
-
request_config = {
|
5
|
-
'GET' => 'path',
|
6
|
-
'POST' => 'params',
|
7
|
-
'DELETE' => 'path',
|
8
|
-
'PUT' => 'path',
|
9
|
-
'PATCH' => 'path',
|
10
|
-
}
|
11
|
-
|
12
|
-
use Rack::SimpleAuth::HMAC::Middleware do |options|
|
13
|
-
options.tolerance = 1
|
14
|
-
options.stepsize = 0.0001
|
15
|
-
|
16
|
-
options.secret = 'test_secret'
|
17
|
-
options.signature = 'test_signature'
|
18
|
-
|
19
|
-
options.logpath = "#{File.expand_path('..', __FILE__)}/logs"
|
20
|
-
options.request_config = request_config
|
21
|
-
end
|
22
|
-
|
23
|
-
run Rack::Lobster.new
|
@@ -1,23 +0,0 @@
|
|
1
|
-
require 'rack/lobster'
|
2
|
-
require 'rack/simple_auth'
|
3
|
-
|
4
|
-
request_config = {
|
5
|
-
'GET' => 'path',
|
6
|
-
'POST' => 'params',
|
7
|
-
'DELETE' => 'path',
|
8
|
-
'PUT' => 'path',
|
9
|
-
'PATCH' => 'path',
|
10
|
-
}
|
11
|
-
|
12
|
-
use Rack::SimpleAuth::HMAC::Middleware do |options|
|
13
|
-
options.tolerance = 0.3
|
14
|
-
options.stepsize = 0.5
|
15
|
-
|
16
|
-
options.secret = 'test_secret'
|
17
|
-
options.signature = 'test_signature'
|
18
|
-
|
19
|
-
options.logpath = "#{File.expand_path('..', __FILE__)}/logs"
|
20
|
-
options.request_config = request_config
|
21
|
-
end
|
22
|
-
|
23
|
-
run Rack::Lobster.new
|
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'test_helper.rb'
|
2
|
-
|
3
|
-
# Test HMAC Authorization Method
|
4
|
-
class HMACFailRunTest < MiniTest::Unit::TestCase
|
5
|
-
include Rack::Test::Methods
|
6
|
-
|
7
|
-
def setup
|
8
|
-
@secret = 'test_secret'
|
9
|
-
@signature = 'test_signature'
|
10
|
-
end
|
11
|
-
|
12
|
-
def app
|
13
|
-
Rack::SimpleAuth::HMAC.failrunapp
|
14
|
-
end
|
15
|
-
|
16
|
-
def test_fail
|
17
|
-
uri = '/'
|
18
|
-
content = { 'method' => 'GET', 'data' => uri }.to_json
|
19
|
-
hash = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'), @secret, content)
|
20
|
-
|
21
|
-
assert_raises(NoMethodError) { get uri, {}, 'HTTP_AUTHORIZATION' => "#{hash}:#{@signature}" }
|
22
|
-
end
|
23
|
-
|
24
|
-
def teardown
|
25
|
-
end
|
26
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
require 'test_helper.rb'
|
2
|
-
|
3
|
-
# Test HMAC Authorization Method
|
4
|
-
class HMACFailTest < MiniTest::Unit::TestCase
|
5
|
-
include Rack::Test::Methods
|
6
|
-
|
7
|
-
def setup
|
8
|
-
@secret = 'test_secret'
|
9
|
-
@signature = 'test_signature'
|
10
|
-
end
|
11
|
-
|
12
|
-
def app
|
13
|
-
Rack::SimpleAuth::HMAC.failapp
|
14
|
-
end
|
15
|
-
|
16
|
-
def test_fail
|
17
|
-
uri = '/'
|
18
|
-
content = { 'method' => 'GET', 'data' => uri }.to_json
|
19
|
-
hash = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'), @secret, content)
|
20
|
-
|
21
|
-
assert_raises(RuntimeError) { get uri, {}, 'HTTP_AUTHORIZATION' => "#{hash}:#{@signature}" }
|
22
|
-
end
|
23
|
-
|
24
|
-
def test_fail_step
|
25
|
-
assert_raises(RuntimeError) { Rack::Builder.parse_file("#{Rack::SimpleAuth.root}/test/rack/simple_auth/hmac/config_fail_step.ru").first }
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_fail_tolerance
|
29
|
-
assert_raises(RuntimeError) { Rack::Builder.parse_file("#{Rack::SimpleAuth.root}/test/rack/simple_auth/hmac/config_fail_tolerance.ru").first }
|
30
|
-
end
|
31
|
-
|
32
|
-
def test_unknown_dsl_option
|
33
|
-
assert_raises(RuntimeError) { Rack::Builder.parse_file("#{Rack::SimpleAuth.root}/test/rack/simple_auth/hmac/config_fail_option.ru").first }
|
34
|
-
end
|
35
|
-
|
36
|
-
def teardown
|
37
|
-
end
|
38
|
-
end
|