rack-auditor 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MDI3YjVkNDA3OTI1MjdhODZhM2QyM2M5M2ZkMjc5ZmVhOWY2NDI1OQ==
5
+ data.tar.gz: !binary |-
6
+ Njc2YTQ3MDllNGNkMzViMmE0NDU1YjdmY2M4OWU2OGE1MTY0NzQ4Ng==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ ZDA1YmExNzMzNjZmMDYxYmY5NzU1NjJlMzYwZjhmYTdlMWViM2I4MjQxNjlj
10
+ ZjE1OTJmNDVmMjg2NjI3N2VlYWY1ZTczNDZkOWVlYjU5MDkxMzM5YWJlNWNi
11
+ NDM1NjVhOThhZDk3ZTkzNDFmMGZjZmQxOTM1YTc0M2ZlMjc3Yjc=
12
+ data.tar.gz: !binary |-
13
+ OWI3ODUzNDE3YmZiYmExN2IwMGUxMWUwYzdjM2JmN2ZkYTg2MTU4MjU0ZDNj
14
+ NGVmZWUwOWNkNzQ0MzY3NmNlODU2ZDg5NGU5ZDFiYjhhMzMwZWUxNTA4NmE4
15
+ YzQ2NTIyMTYwYjBhNDE2NDRhYWI5Mjg4YmM1NTgyOTNkYmRhMzE=
data/README.md ADDED
@@ -0,0 +1,10 @@
1
+ ```
2
+ _____ .___.__ __
3
+ / _ \ __ __ __| _/|__|/ |_ ___________
4
+ / /_\ \| | \/ __ | | \ __\/ _ \_ __ \
5
+ / | \ | / /_/ | | || | ( <_> ) | \/
6
+ \____|__ /____/\____ | |__||__| \____/|__|
7
+ \/ \/
8
+ ```
9
+
10
+ Auditor is a quick and dirty litle middleware that allows you verify a request against an identity provider.
@@ -0,0 +1,44 @@
1
+ require 'httparty'
2
+
3
+ module Rack
4
+ class Auditor
5
+ ROOT_URL = 'http://icis-identity-example.herokuapp.com/api/v1/verify.json'
6
+
7
+ def initialize(app, root_uri = 'http://snowflake.dev/')
8
+ @app, @root_uri = app, root_uri
9
+ end
10
+
11
+ def call(env)
12
+ key = env['HTTP_X_API_KEY']
13
+ secret = env['HTTP_X_API_SECRET']
14
+
15
+ return forbidden unless key && secret
16
+
17
+ response = HTTParty.get "#{@root_uri}?api_key=#{key}&api_secret=#{secret}"
18
+
19
+ case response.code
20
+ when 403
21
+ forbidden
22
+ when 404
23
+ error_code(404, 'Not Found')
24
+ when 500
25
+ error_code(500, 'Server Error')
26
+ when 503
27
+ error_code(503, 'Maintenance')
28
+ when 504
29
+ error_code(504, 'System Down')
30
+ end
31
+
32
+ @app.call(env)
33
+ end
34
+
35
+ private
36
+ def forbidden
37
+ error_code(403, 'Unauthorized')
38
+ end
39
+
40
+ def error_code(code, message)
41
+ [code, {'Content-Type' => 'text/plain'}, [message]]
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,35 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = "rack-auditor"
3
+ s.version = "0.1.0"
4
+
5
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
6
+ s.authors = ["Patrick Robertson"]
7
+ s.date = "2013-11-20"
8
+ s.description = "Middleware that allows you to verify a request against an identity provider"
9
+ s.email = "patricksrobertson@gmail.com"
10
+ s.files = [
11
+ "README.md",
12
+ "lib/rack/auditor.rb",
13
+ "rack-auditor.gemspec",
14
+ ]
15
+ s.homepage = "http://github.com/patricksrobertson/rack-auditor"
16
+ s.licenses = ["MIT"]
17
+ s.require_paths = ["lib"]
18
+ s.rubygems_version = "1.8.24"
19
+ s.summary = "Middleware for ICIS identity provider verification"
20
+
21
+ if s.respond_to? :specification_version then
22
+ s.specification_version = 3
23
+
24
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
25
+ s.add_runtime_dependency(%q<rack>, [">= 0"])
26
+ s.add_runtime_dependency(%q<httparty>, [">= 0"])
27
+ else
28
+ s.add_dependency(%q<rack>, [">= 0"])
29
+ s.add_dependency(%q<httparty>, [">= 0"])
30
+ end
31
+ else
32
+ s.add_dependency(%q<rack>, [">= 0"])
33
+ s.add_dependency(%q<httparty>, [">= 0"])
34
+ end
35
+ end
metadata ADDED
@@ -0,0 +1,74 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rack-auditor
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Patrick Robertson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-11-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rack
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ! '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ! '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: httparty
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: Middleware that allows you to verify a request against an identity provider
42
+ email: patricksrobertson@gmail.com
43
+ executables: []
44
+ extensions: []
45
+ extra_rdoc_files: []
46
+ files:
47
+ - README.md
48
+ - lib/rack/auditor.rb
49
+ - rack-auditor.gemspec
50
+ homepage: http://github.com/patricksrobertson/rack-auditor
51
+ licenses:
52
+ - MIT
53
+ metadata: {}
54
+ post_install_message:
55
+ rdoc_options: []
56
+ require_paths:
57
+ - lib
58
+ required_ruby_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ required_rubygems_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ! '>='
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ requirements: []
69
+ rubyforge_project:
70
+ rubygems_version: 2.1.10
71
+ signing_key:
72
+ specification_version: 3
73
+ summary: Middleware for ICIS identity provider verification
74
+ test_files: []