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 +4 -4
- data/README.textile +16 -5
- data/lib/maitre_d.rb +0 -7
- data/lib/maitre_d/cloud_control/api_helpers.rb +2 -0
- data/lib/maitre_d/heroku/api_helpers.rb +44 -42
- data/maitre_d.gemspec +3 -3
- data/spec/internal/config/initializers/broadstack.rb +2 -0
- data/spec/internal/config/initializers/cloud_control.rb +2 -0
- data/spec/internal/config/initializers/heroku.rb +2 -0
- data/spec/internal/config/initializers/opperator.rb +2 -0
- data/spec/internal/config/routes.rb +5 -0
- metadata +5 -8
- data/config/routes.rb +0 -6
- data/lib/maitre_d/engine.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f3c4e61ea06b3875e6b2a365f0acabad42b242a9
|
4
|
+
data.tar.gz: 3767ddfb5f8b6e7d2f044ba6b978a4a9eb88b58e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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.
|
16
|
+
gem 'maitre_d', '~> 0.4.0'</code></pre>
|
17
17
|
|
18
18
|
h3. With Rails
|
19
19
|
|
20
|
-
|
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>
|
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-
|
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
@@ -1,44 +1,46 @@
|
|
1
|
-
module MaitreD::Heroku
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
valid_authorization
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
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.
|
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
|
11
|
-
s.description = 'A Rack API (through Grape) for Heroku
|
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,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.
|
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:
|
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
|
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.
|
139
|
+
rubygems_version: 2.2.2
|
143
140
|
signing_key:
|
144
141
|
specification_version: 4
|
145
|
-
summary: Rack
|
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
data/lib/maitre_d/engine.rb
DELETED