maitre_d 0.3.0 → 0.4.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: 1e79119958343605dabd87304c21e2e9c770711b
4
- data.tar.gz: 4ed73d17abf94091dfb18e566984637699e8569a
3
+ metadata.gz: f3c4e61ea06b3875e6b2a365f0acabad42b242a9
4
+ data.tar.gz: 3767ddfb5f8b6e7d2f044ba6b978a4a9eb88b58e
5
5
  SHA512:
6
- metadata.gz: 36feafdb16cd476413a95b34da6dfc675c43fa47772b04d6ec34117aeb71c42646556700920582689dda9fa845667451c93f8812408d340e14cd76eb5fe6cb3a
7
- data.tar.gz: aa9b728329779092e8f1482e50db5dbfe45751cce6957135ec35f8d7f959b162cd55fbcd0e093db3534b7bf82249becbccdc3604981f217dc780b61b5d7c10bd
6
+ metadata.gz: e4c934c994c138437397a82f584a25e2631aaea6182b09a97d2a1952f1c0687894750d48e79b44b7ae863ce92cfb260de731cbd26d9d310d7f72bfee5a84e566
7
+ data.tar.gz: 184847e1566082599f09efead691839955baca8f6100b0472b4c1a09b880d20089a9982c07a3614e34c6b445594d5ebacda971ba1424d14f2309c6305442fe2d
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, CloudControl and Opperator add-ons. If used within a Rails application, it'll automatically be mounted as a Rails engine at the appropriate paths.
5
+ Rack APIs powered by Grape for managing Heroku, CloudControl and Opperator 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
 
@@ -13,11 +13,16 @@ Add the following to your Gemfile - and take note that we need the git repositor
13
13
  <pre><code>gem 'grape',
14
14
  :git => 'git://github.com/intridea/grape.git',
15
15
  :ref => '212c96cdfb253a59bc93790808c568e559d04468'
16
- gem 'maitre_d', '~> 0.1.2'</code></pre>
16
+ gem 'maitre_d', '~> 0.4.0'</code></pre>
17
17
 
18
18
  h3. With Rails
19
19
 
20
- Because there's a Rails engine as part of Maître d', the API routing is set up automatically. Jump forward to the configuration and listener setup below.
20
+ Add the appropriate Rack apps to your routes file:
21
+
22
+ <pre><code>mount MaitreD::Broadstack::API => '/broadstack'
23
+ mount MaitreD::Heroku::API => '/heroku'
24
+ mount MaitreD::CloudControl::API => '/cloudcontrol'
25
+ mount MaitreD::Opperator::API => '/opperator'</code></pre>
21
26
 
22
27
  h3. Without Rails
23
28
 
@@ -27,13 +32,17 @@ h2. Configuration
27
32
 
28
33
  You'll need to provide Maître d' with the appropriate provider credentials - in a Rails app, this would go in an initializer, but for Rack/Sinatra apps just get the values set before the routing is defined.
29
34
 
30
- <pre><code>MaitreD::Heroku.configure do |config|
35
+ <pre><code>require 'maitre_d/heroku'
36
+
37
+ MaitreD::Heroku.configure do |config|
31
38
  config.id = 'addon-id'
32
39
  config.password = 'random'
33
40
  config.sso_salt = 'gibberish'
34
41
  config.listener = HerokuListener
35
42
  end
36
43
 
44
+ require 'maitre_d/cloud_control'
45
+
37
46
  MaitreD::CloudControl.configure do |config|
38
47
  config.id = 'addon-id'
39
48
  config.password = 'random'
@@ -41,6 +50,8 @@ MaitreD::CloudControl.configure do |config|
41
50
  config.listener = CloudControlListener
42
51
  end
43
52
 
53
+ require 'maitre_d/opperator'
54
+
44
55
  MaitreD::Opperator.configure do |config|
45
56
  config.shared_secret = 'something-special'
46
57
  config.listener = OpperatorListener
@@ -154,4 +165,4 @@ Contributions are very much welcome - but keep in mind the following:
154
165
 
155
166
  h2. Credits
156
167
 
157
- Copyright (c) 2011-2012, Maître d' is developed and maintained by Pat Allan, and is released under the open MIT Licence.
168
+ Copyright (c) 2011-2014, Maître d' is developed and maintained by Pat Allan, and is released under the open MIT Licence.
data/lib/maitre_d.rb CHANGED
@@ -2,10 +2,3 @@ require 'grape'
2
2
 
3
3
  module MaitreD
4
4
  end
5
-
6
- require 'maitre_d/broadstack'
7
- require 'maitre_d/heroku'
8
- require 'maitre_d/cloud_control'
9
- require 'maitre_d/opperator'
10
-
11
- require 'maitre_d/engine' if defined?(Rails)
@@ -1,3 +1,5 @@
1
+ require 'maitre_d/heroku/api_helpers'
2
+
1
3
  module MaitreD::CloudControl::APIHelpers
2
4
  include MaitreD::Heroku::APIHelpers
3
5
 
@@ -1,44 +1,46 @@
1
- module MaitreD::Heroku::APIHelpers
2
- def authenticate!
3
- error!('401 Unauthorized', 401) unless valid_authorization?
4
- end
5
-
6
- def listener
7
- MaitreD::Heroku.listener.new
8
- end
9
-
10
- def provider_id
11
- params[:heroku_id]
12
- end
13
-
14
- def session
15
- env['rack.session']
16
- end
17
-
18
- def valid_timestamp?
19
- params[:timestamp].to_i >= (Time.now - 5*60).to_i
20
- end
21
-
22
- def valid_token?
23
- expected_token == params[:token]
24
- end
25
-
26
- private
27
-
28
- def expected_token
29
- @expected_token ||= Digest::SHA1.hexdigest(
30
- "#{params[:id]}:#{MaitreD::Heroku.sso_salt}:#{params[:timestamp]}"
31
- ).to_s
32
- end
33
-
34
- def valid_authorization?
35
- valid_authorization.strip == env['HTTP_AUTHORIZATION'].strip
36
- end
37
-
38
- def valid_authorization
39
- encoded_authorization = Base64.encode64(
40
- "#{MaitreD::Heroku.id}:#{MaitreD::Heroku.password}"
41
- )
42
- "Basic #{encoded_authorization}"
1
+ module MaitreD::Heroku
2
+ module APIHelpers
3
+ def authenticate!
4
+ error!('401 Unauthorized', 401) unless valid_authorization?
5
+ end
6
+
7
+ def listener
8
+ MaitreD::Heroku.listener.new
9
+ end
10
+
11
+ def provider_id
12
+ params[:heroku_id]
13
+ end
14
+
15
+ def session
16
+ env['rack.session']
17
+ end
18
+
19
+ def valid_timestamp?
20
+ params[:timestamp].to_i >= (Time.now - 5*60).to_i
21
+ end
22
+
23
+ def valid_token?
24
+ expected_token == params[:token]
25
+ end
26
+
27
+ private
28
+
29
+ def expected_token
30
+ @expected_token ||= Digest::SHA1.hexdigest(
31
+ "#{params[:id]}:#{MaitreD::Heroku.sso_salt}:#{params[:timestamp]}"
32
+ ).to_s
33
+ end
34
+
35
+ def valid_authorization?
36
+ valid_authorization.strip == env['HTTP_AUTHORIZATION'].strip
37
+ end
38
+
39
+ def valid_authorization
40
+ encoded_authorization = Base64.encode64(
41
+ "#{MaitreD::Heroku.id}:#{MaitreD::Heroku.password}"
42
+ )
43
+ "Basic #{encoded_authorization}"
44
+ end
43
45
  end
44
46
  end
data/maitre_d.gemspec CHANGED
@@ -3,12 +3,12 @@ $:.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.3.0'
6
+ s.version = '0.4.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'
10
- s.summary = 'Rack API and Rails Engine for Heroku and Opperator add-ons'
11
- s.description = 'A Rack API (through Grape) for Heroku and Opperator add-on providers - which can also be attached as a Rails Engine.'
10
+ s.summary = 'Rack APIs for Heroku add-ons'
11
+ s.description = 'A Rack API (through Grape) for Heroku add-on providers.'
12
12
 
13
13
  s.rubyforge_project = "maitre_d"
14
14
 
@@ -1,3 +1,5 @@
1
+ require 'maitre_d/broadstack'
2
+
1
3
  MaitreD::Broadstack.configure do |config|
2
4
  config.id = 'foo'
3
5
  config.password = 'bar'
@@ -1,3 +1,5 @@
1
+ require 'maitre_d/cloud_control'
2
+
1
3
  MaitreD::CloudControl.configure do |config|
2
4
  config.id = 'baz'
3
5
  config.password = 'qux'
@@ -1,3 +1,5 @@
1
+ require 'maitre_d/heroku'
2
+
1
3
  MaitreD::Heroku.configure do |config|
2
4
  config.id = 'foo'
3
5
  config.password = 'bar'
@@ -1,3 +1,5 @@
1
+ require 'maitre_d/opperator'
2
+
1
3
  MaitreD::Opperator.configure do |config|
2
4
  config.shared_secret = 'something-special'
3
5
  config.listener = OpperatorListener
@@ -1,4 +1,9 @@
1
1
  Rails.application.routes.draw do
2
+ mount MaitreD::Broadstack::API => '/broadstack'
3
+ mount MaitreD::Heroku::API => '/heroku'
4
+ mount MaitreD::CloudControl::API => '/cloudcontrol'
5
+ mount MaitreD::Opperator::API => '/opperator'
6
+
2
7
  class Dashboard
3
8
  def self.call(env)
4
9
  [200, {'Content-Type' => 'text/plain', 'Content-Length' => '9'},
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.3.0
4
+ version: 0.4.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: 2013-07-27 00:00:00.000000000 Z
11
+ date: 2014-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: combustion
@@ -66,8 +66,7 @@ dependencies:
66
66
  - - '='
67
67
  - !ruby/object:Gem::Version
68
68
  version: 2.7.0
69
- description: A Rack API (through Grape) for Heroku and Opperator add-on providers
70
- - which can also be attached as a Rails Engine.
69
+ description: A Rack API (through Grape) for Heroku add-on providers.
71
70
  email:
72
71
  - pat@freelancing-gods.com
73
72
  executables: []
@@ -83,7 +82,6 @@ files:
83
82
  - Rakefile
84
83
  - addon-manifest.json
85
84
  - config.ru
86
- - config/routes.rb
87
85
  - lib/maitre_d.rb
88
86
  - lib/maitre_d/broadstack.rb
89
87
  - lib/maitre_d/broadstack/api.rb
@@ -91,7 +89,6 @@ files:
91
89
  - lib/maitre_d/cloud_control.rb
92
90
  - lib/maitre_d/cloud_control/api.rb
93
91
  - lib/maitre_d/cloud_control/api_helpers.rb
94
- - lib/maitre_d/engine.rb
95
92
  - lib/maitre_d/heroku.rb
96
93
  - lib/maitre_d/heroku/api.rb
97
94
  - lib/maitre_d/heroku/api_helpers.rb
@@ -139,10 +136,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
139
136
  version: '0'
140
137
  requirements: []
141
138
  rubyforge_project: maitre_d
142
- rubygems_version: 2.0.2
139
+ rubygems_version: 2.2.2
143
140
  signing_key:
144
141
  specification_version: 4
145
- summary: Rack API and Rails Engine for Heroku and Opperator add-ons
142
+ summary: Rack APIs for Heroku add-ons
146
143
  test_files:
147
144
  - spec/api/broadstack/provisioning_spec.rb
148
145
  - spec/api/broadstack/single_sign_on_spec.rb
data/config/routes.rb DELETED
@@ -1,6 +0,0 @@
1
- Rails.application.routes.draw do
2
- mount MaitreD::Broadstack::API => '/broadstack'
3
- mount MaitreD::Heroku::API => '/heroku'
4
- mount MaitreD::CloudControl::API => '/cloudcontrol'
5
- mount MaitreD::Opperator::API => '/opperator'
6
- end
@@ -1,3 +0,0 @@
1
- class MaitreD::Engine < Rails::Engine
2
- paths['config'] << 'config'
3
- end