maitre_d 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b27a7d6903d91dea29a32af183b05a2b87689190
4
- data.tar.gz: 511c60706f0fd6d560d8930afb2eeac0815bb33e
3
+ metadata.gz: 3384d15408a2e029d8419521510854402d0055a1
4
+ data.tar.gz: 2bcb69e276cc0d4024eb15a9f0f7de061ae61d67
5
5
  SHA512:
6
- metadata.gz: 894af66d98c2dd376de02fd6925d330fad5dc40c1dc223e0c06bc470c67120c6f1a68ae685b4f8b6987f5a372a85c739b27e4216be447a77fef71db4f9625d13
7
- data.tar.gz: d01c6f9f505f9fe2a129ffac826eebb074139cfa678a0cc0a6eca961b6094d12590cf0b88b56b4b0ce936416400d94302fe7edc74870da9bf469910d4c0a4a3b
6
+ metadata.gz: 264cb01a7047ac115042b6c9b4de13c1571e737498aa76b1a20df878b834703304703da4da8a6c37e0e81ce85b83278549f45966dd018faa05e0c1fbb531c9ca
7
+ data.tar.gz: 37046db0c44e4f92902023a11fff7ee6faeab9b673813beab5505d930f29b0bd584e0a1d0378e14e80df81eeedb4e001baa7d277e6d5d59495737c2fd6e2a724
data/.travis.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 1.9.3
4
- - 2.2.0
3
+ - 2.3.4
4
+ - 2.4.1
5
5
  script: bundle exec rspec spec
data/README.textile CHANGED
@@ -2,7 +2,7 @@ h1. Maître d'
2
2
 
3
3
  "!https://secure.travis-ci.org/flying-sphinx/maitre_d.png!":http://travis-ci.org/flying-sphinx/maitre_d
4
4
 
5
- Rack APIs powered by Grape for managing Heroku and CloudControl add-ons.
5
+ Rack APIs powered by Sliver for managing Heroku and CloudControl add-ons.
6
6
 
7
7
  Maître d' manages all the authorisation checking for API requests and provides simple hooks for you to write just the code you need to handle provisioning, plan changes, deprovisioning and single-sign-on (SSO) requests.
8
8
 
@@ -10,7 +10,7 @@ h2. Installing
10
10
 
11
11
  Add the following to your Gemfile:
12
12
 
13
- <pre><code>gem 'maitre_d', '~> 0.5.0'</code></pre>
13
+ <pre><code>gem 'maitre_d', '~> 0.6.0'</code></pre>
14
14
 
15
15
  h3. With Rails
16
16
 
@@ -1,12 +1,8 @@
1
1
  class MaitreD::API::Authenticated
2
2
  include Sliver::Action
3
3
 
4
- def skip?
5
- return false if valid_authorization?
6
-
7
- response.body = ['401 Unauthorized']
8
- response.status = 401
9
- true
4
+ def self.guards
5
+ [MaitreD::API::AuthenticationGuard]
10
6
  end
11
7
 
12
8
  def call
@@ -14,12 +10,12 @@ class MaitreD::API::Authenticated
14
10
  response.status ||= 200
15
11
  end
16
12
 
17
- private
18
-
19
13
  def configuration
20
14
  environment['maitre_d.configuration']
21
15
  end
22
16
 
17
+ private
18
+
23
19
  def listener
24
20
  configuration.listener.new
25
21
  end
@@ -31,15 +27,4 @@ class MaitreD::API::Authenticated
31
27
  def provider_id
32
28
  configuration.provider_id_from params
33
29
  end
34
-
35
- def valid_authorization?
36
- valid_authorization.strip == environment['HTTP_AUTHORIZATION'].strip
37
- end
38
-
39
- def valid_authorization
40
- encoded_authorization = Base64.encode64(
41
- "#{configuration.id}:#{configuration.password}"
42
- )
43
- "Basic #{encoded_authorization}"
44
- end
45
30
  end
@@ -0,0 +1,24 @@
1
+ class MaitreD::API::AuthenticationGuard < Sliver::Hook
2
+ def continue?
3
+ valid_authorization?
4
+ end
5
+
6
+ def respond
7
+ response.status = 401
8
+ response.body = ['401 Unauthorized']
9
+ response.headers['Content-Length'] = response.body.first.length.to_s
10
+ end
11
+
12
+ private
13
+
14
+ def valid_authorization?
15
+ valid_authorization.strip == action.request.env['HTTP_AUTHORIZATION'].strip
16
+ end
17
+
18
+ def valid_authorization
19
+ encoded_authorization = Base64.encode64(
20
+ "#{action.configuration.id}:#{action.configuration.password}"
21
+ )
22
+ "Basic #{encoded_authorization}"
23
+ end
24
+ end
@@ -1,14 +1,8 @@
1
1
  class MaitreD::API::SSO
2
2
  include Sliver::Action
3
3
 
4
- def skip?
5
- return false if valid_token? && valid_timestamp?
6
-
7
- response.status = 403
8
- response.body = ['403 Forbidden']
9
- response.headers['Content-Length'] = response.body.first.length.to_s
10
-
11
- true
4
+ def self.guards
5
+ [MaitreD::API::SSOGuard]
12
6
  end
13
7
 
14
8
  def call
@@ -31,17 +25,11 @@ class MaitreD::API::SSO
31
25
  response.headers['Location'] = hash[:uri]
32
26
  end
33
27
 
34
- private
35
-
36
28
  def configuration
37
29
  environment['maitre_d.configuration']
38
30
  end
39
31
 
40
- def expected_token
41
- @expected_token ||= Digest::SHA1.hexdigest(
42
- "#{params['id']}:#{configuration.sso_salt}:#{params['timestamp']}"
43
- ).to_s
44
- end
32
+ private
45
33
 
46
34
  def listener
47
35
  configuration.listener.new
@@ -54,12 +42,4 @@ class MaitreD::API::SSO
54
42
  def session
55
43
  environment['rack.session'] ||= {}
56
44
  end
57
-
58
- def valid_timestamp?
59
- params['timestamp'].to_i >= (Time.now - 5*60).to_i
60
- end
61
-
62
- def valid_token?
63
- expected_token == params['token']
64
- end
65
45
  end
@@ -0,0 +1,31 @@
1
+ class MaitreD::API::SSOGuard < Sliver::Hook
2
+ def continue?
3
+ valid_token? && valid_timestamp?
4
+ end
5
+
6
+ def respond
7
+ response.status = 403
8
+ response.body = ['403 Forbidden']
9
+ response.headers['Content-Length'] = response.body.first.length.to_s
10
+ end
11
+
12
+ private
13
+
14
+ def expected_token
15
+ @expected_token ||= Digest::SHA1.hexdigest(
16
+ "#{params['id']}:#{action.configuration.sso_salt}:#{params['timestamp']}"
17
+ ).to_s
18
+ end
19
+
20
+ def params
21
+ action.request.params
22
+ end
23
+
24
+ def valid_timestamp?
25
+ params['timestamp'].to_i >= (Time.now - 5*60).to_i
26
+ end
27
+
28
+ def valid_token?
29
+ expected_token == params['token']
30
+ end
31
+ end
data/lib/maitre_d/api.rb CHANGED
@@ -23,8 +23,10 @@ class MaitreD::API
23
23
  end
24
24
  end
25
25
 
26
+ require 'maitre_d/api/authentication_guard'
26
27
  require 'maitre_d/api/authenticated'
27
28
  require 'maitre_d/api/change_plan'
28
29
  require 'maitre_d/api/create'
29
30
  require 'maitre_d/api/delete'
31
+ require 'maitre_d/api/sso_guard'
30
32
  require 'maitre_d/api/sso'
data/maitre_d.gemspec CHANGED
@@ -3,7 +3,7 @@ $:.push File.expand_path('../lib', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = 'maitre_d'
6
- s.version = '0.5.0'
6
+ s.version = '0.6.0'
7
7
  s.authors = ['Pat Allan']
8
8
  s.email = ['pat@freelancing-gods.com']
9
9
  s.homepage = 'http://github.com/flying-sphinx/maitre_d'
@@ -17,11 +17,11 @@ Gem::Specification.new do |s|
17
17
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
18
  s.require_paths = ['lib']
19
19
 
20
- s.add_runtime_dependency 'sliver', '~> 0.0.4'
20
+ s.add_runtime_dependency 'sliver', '~> 0.2.2'
21
21
  s.add_runtime_dependency 'multi_json', '>= 1.3.0'
22
22
 
23
- s.add_development_dependency 'combustion', '0.5.1'
23
+ s.add_development_dependency 'combustion', '~> 0.5'
24
24
  s.add_development_dependency 'kensa', '2.1.0'
25
- s.add_development_dependency 'rails', '~> 4.1.0'
26
- s.add_development_dependency 'rspec-rails', '~> 3.1.0'
25
+ s.add_development_dependency 'rails', '~> 4.2'
26
+ s.add_development_dependency 'rspec-rails', '~> 3.6'
27
27
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: maitre_d
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pat Allan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-01 00:00:00.000000000 Z
11
+ date: 2017-05-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sliver
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.0.4
19
+ version: 0.2.2
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.0.4
26
+ version: 0.2.2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: multi_json
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -42,16 +42,16 @@ dependencies:
42
42
  name: combustion
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '='
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.5.1
47
+ version: '0.5'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '='
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 0.5.1
54
+ version: '0.5'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: kensa
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -72,28 +72,28 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 4.1.0
75
+ version: '4.2'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 4.1.0
82
+ version: '4.2'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rspec-rails
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 3.1.0
89
+ version: '3.6'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: 3.1.0
96
+ version: '3.6'
97
97
  description: A Rack API (through Grape) for Heroku add-on providers.
98
98
  email:
99
99
  - pat@freelancing-gods.com
@@ -113,10 +113,12 @@ files:
113
113
  - lib/maitre_d.rb
114
114
  - lib/maitre_d/api.rb
115
115
  - lib/maitre_d/api/authenticated.rb
116
+ - lib/maitre_d/api/authentication_guard.rb
116
117
  - lib/maitre_d/api/change_plan.rb
117
118
  - lib/maitre_d/api/create.rb
118
119
  - lib/maitre_d/api/delete.rb
119
120
  - lib/maitre_d/api/sso.rb
121
+ - lib/maitre_d/api/sso_guard.rb
120
122
  - lib/maitre_d/cloud_control.rb
121
123
  - lib/maitre_d/heroku.rb
122
124
  - maitre_d.gemspec
@@ -151,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
151
153
  version: '0'
152
154
  requirements: []
153
155
  rubyforge_project: maitre_d
154
- rubygems_version: 2.2.2
156
+ rubygems_version: 2.6.11
155
157
  signing_key:
156
158
  specification_version: 4
157
159
  summary: Rack APIs for Heroku add-ons