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.
Files changed (57) hide show
  1. checksums.yaml +7 -7
  2. data/MANIFEST +26 -26
  3. data/README.rdoc +121 -0
  4. data/checksum/rack-simple_auth-1.0.0.gem.sha512 +1 -0
  5. data/checksum/rack-simple_auth-1.0.0rc.gem.sha512 +1 -0
  6. data/doc/Rack.html +128 -0
  7. data/doc/Rack/SimpleAuth.html +252 -0
  8. data/doc/Rack/SimpleAuth/HMAC.html +128 -0
  9. data/doc/Rack/SimpleAuth/HMAC/Config.html +1003 -0
  10. data/doc/Rack/SimpleAuth/HMAC/Middleware.html +1418 -0
  11. data/doc/Rack/SimpleAuth/Logger.html +264 -0
  12. data/doc/_index.html +185 -0
  13. data/doc/class_list.html +54 -0
  14. data/doc/css/common.css +1 -0
  15. data/doc/css/full_list.css +57 -0
  16. data/doc/css/style.css +339 -0
  17. data/doc/examples/index.php +32 -0
  18. data/{test/rack/simple_auth/hmac/config.ru → doc/examples/rack_lobster.ru} +1 -2
  19. data/doc/file.README.html +221 -0
  20. data/doc/file_list.html +56 -0
  21. data/doc/frames.html +26 -0
  22. data/doc/index.html +221 -0
  23. data/doc/js/app.js +219 -0
  24. data/doc/js/full_list.js +178 -0
  25. data/doc/js/jquery.js +4 -0
  26. data/doc/method_list.html +179 -0
  27. data/doc/top-level-namespace.html +112 -0
  28. data/lib/rack/simple_auth.rb +3 -1
  29. data/lib/rack/simple_auth/hmac/config.rb +46 -8
  30. data/lib/rack/simple_auth/hmac/middleware.rb +102 -75
  31. data/lib/rack/simple_auth/logger.rb +8 -3
  32. data/lib/rack/simple_auth/version.rb +1 -1
  33. metadata +91 -105
  34. data/.gitignore +0 -18
  35. data/.rubocop.yml +0 -1
  36. data/.travis.yml +0 -22
  37. data/.yardopts +0 -1
  38. data/Gemfile +0 -4
  39. data/README.md +0 -68
  40. data/Rakefile +0 -8
  41. data/rubocop-todo.yml +0 -19
  42. data/task/build.rake +0 -4
  43. data/task/checksum.rake +0 -15
  44. data/task/console.rake +0 -7
  45. data/task/default.rake +0 -6
  46. data/task/floodtest.rake +0 -34
  47. data/task/manifest.rake +0 -8
  48. data/task/test.rake +0 -23
  49. data/test/rack/simple_auth/hmac/config_fail.ru +0 -23
  50. data/test/rack/simple_auth/hmac/config_fail_option.ru +0 -24
  51. data/test/rack/simple_auth/hmac/config_fail_run.ru +0 -22
  52. data/test/rack/simple_auth/hmac/config_fail_step.ru +0 -23
  53. data/test/rack/simple_auth/hmac/config_fail_tolerance.ru +0 -23
  54. data/test/rack/simple_auth/hmac/hmac_fail_run_test.rb +0 -26
  55. data/test/rack/simple_auth/hmac/hmac_fail_test.rb +0 -38
  56. data/test/rack/simple_auth/hmac/hmac_test.rb +0 -128
  57. data/test/test_helper.rb +0 -50
data/.gitignore DELETED
@@ -1,18 +0,0 @@
1
- *.gem
2
- *.rbc
3
- .bundle
4
- .config
5
- .yardoc
6
- Gemfile.lock
7
- InstalledFiles
8
- _yardoc
9
- coverage
10
- doc/
11
- lib/bundler/man
12
- pkg
13
- rdoc
14
- spec/reports
15
- test/tmp
16
- test/version_tmp
17
- tmp
18
- *.swp
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
@@ -1,4 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in rack-simple_auth.gemspec
4
- gemspec
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
@@ -1,8 +0,0 @@
1
- require "bundler/gem_tasks"
2
- require 'rake/testtask'
3
- # require 'cucumber/rake/task'
4
-
5
- GEMSPEC = Gem::Specification.load('rack-simple_auth.gemspec')
6
- Dir.glob('task/*.rake').each { |r| import r }
7
-
8
-
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
@@ -1,4 +0,0 @@
1
- desc 'Builds a new Gem and its checksum'
2
- task :signed_build => [:build] do
3
- Rake::Task['checksum'].invoke
4
- end
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
@@ -1,7 +0,0 @@
1
- task :console do
2
- require 'irb'
3
- require 'irb/completion'
4
- require 'rack/simple_auth'
5
- ARGV.clear
6
- IRB.start
7
- end
data/task/default.rake DELETED
@@ -1,6 +0,0 @@
1
- task :default do
2
- Rake::Task['test:unit'].invoke
3
- # Rake::Task['test:spec'].invoke
4
- # Rake::Task['test:feature'].invoke
5
- Rake::Task['test:cleanup'].invoke
6
- end
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
@@ -1,8 +0,0 @@
1
- desc 'Generates the MANIFEST file'
2
- task :manifest do
3
- files = `git ls-files`.split("\n").sort
4
- handle = File.open(File.expand_path('../../MANIFEST', __FILE__), 'w')
5
-
6
- handle.write(files.join("\n"))
7
- handle.close
8
- end
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