faria-launchpad-api 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/LICENSE.txt +1 -1
- data/README.md +12 -13
- data/faria-launchpad-api.gemspec +8 -6
- data/lib/faria/launchpad/api/version.rb +1 -1
- data/lib/faria/launchpad/packet.rb +7 -9
- data/lib/faria/launchpad/service.rb +5 -10
- metadata +70 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 83d8f5483e9d09348b69ee459d246e3097c9cacf
|
4
|
+
data.tar.gz: 6879e2cf106c9fba214e3a3949a06174ecb1ed6e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 34f5889ccc831569547183d3e90f48840308ae0242efc1bc57c63bac5234435fd3e63778b2c8e7add7a07bc232a9d379336fb774b9079cad29aab7815dce56f9
|
7
|
+
data.tar.gz: d0daf6985bad5984e22706d0d2fc7972fd069ba92cc8707341201cff918d81fb970b8d4056da2c691f83743c04b9cf75d622f7d1e5ee224a3ced1fca3ef916fd
|
data/CHANGELOG.md
ADDED
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -61,7 +61,7 @@ kQIDAQAB
|
|
61
61
|
|
62
62
|
#### Serving your public key inside your application
|
63
63
|
|
64
|
-
The LaunchPad spec also requires that your web application serve this public key (text/plaintext) over
|
64
|
+
The LaunchPad spec also requires that your web application serve this public key (text/plaintext) over HTTPS as part of the API your application must furnish to fully support LaunchPad.
|
65
65
|
|
66
66
|
GET https://yourapplication.com/apis/launchpad/pubkey
|
67
67
|
-----BEGIN PUBLIC KEY-----
|
@@ -79,17 +79,17 @@ Here is a quick example. This example presumes you've already generated a 2,048
|
|
79
79
|
|
80
80
|
|
81
81
|
```ruby
|
82
|
-
# fetch the LaunchPad public key
|
83
|
-
|
84
|
-
uri = "https://
|
85
|
-
launchpad_key = Net::HTTP.get_response(URI.parse(
|
82
|
+
# fetch the LaunchPad public key
|
83
|
+
# (you should save it locally rather than constantly fetch it)
|
84
|
+
uri = "https://launchpad.launchpad-staging.managebac.com/api/v1/"
|
85
|
+
launchpad_key = Net::HTTP.get_response(URI.parse(uri + "pubkey")).body
|
86
86
|
local_key = OpenSSL::PKey::RSA.new(File.read("./secure/private_key"))
|
87
87
|
|
88
|
-
|
89
|
-
"https://
|
88
|
+
service = Faria::Launchpad::Service.new(
|
89
|
+
"https://launchpad.launchpad-staging.managebac.com/api/v1/",
|
90
90
|
{
|
91
91
|
keys: { local: local_key, remote: launchpad_key },
|
92
|
-
# the application name and URI issued to you during your
|
92
|
+
# the application name and URI issued to you during your
|
93
93
|
# LaunchPad setup process
|
94
94
|
source: {
|
95
95
|
name: "Acme Widgets, LLC.",
|
@@ -110,7 +110,7 @@ The responses returned will almost always be JSON responses (see [API documentat
|
|
110
110
|
|
111
111
|
### Rails Integration
|
112
112
|
|
113
|
-
There is a module to extend controllers to support easily handling incoming JWE requests and a Rails helper to assist with POSTing signed redirects.
|
113
|
+
There is a module to extend controllers to support easily handling incoming JWE requests and a Rails helper to assist with POSTing signed redirects. Below is a usage example.
|
114
114
|
|
115
115
|
If the URL includes query parameters they will be stripped from the URL and encoded into the JWE as signed parameters.
|
116
116
|
|
@@ -147,12 +147,12 @@ The `SSO` module below is just one example of how you might wrap up all the piec
|
|
147
147
|
class YourController < ActionController::Base
|
148
148
|
include Faria::Launchpad::Controller
|
149
149
|
launchpad_config SSO
|
150
|
-
|
150
|
+
|
151
151
|
def action
|
152
|
-
post_encrypted_redirect_to SSO.client.pairing_request_url,
|
152
|
+
post_encrypted_redirect_to SSO.client.pairing_request_url,
|
153
153
|
params_to_pass
|
154
154
|
end
|
155
|
-
|
155
|
+
|
156
156
|
end
|
157
157
|
```
|
158
158
|
|
@@ -172,4 +172,3 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/eduvo/
|
|
172
172
|
## License
|
173
173
|
|
174
174
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
175
|
-
|
data/faria-launchpad-api.gemspec
CHANGED
@@ -6,8 +6,8 @@ require 'faria/launchpad/api/version'
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "faria-launchpad-api"
|
8
8
|
spec.version = Faria::Launchpad::Api::VERSION
|
9
|
-
spec.authors = ["
|
10
|
-
spec.email = ["
|
9
|
+
spec.authors = ["Faria Education Group"]
|
10
|
+
spec.email = ["rubygems@fariaedu.com"]
|
11
11
|
|
12
12
|
spec.summary = %q{Ruby library to interface with Faria LaunchPad.}
|
13
13
|
spec.description = %q{Ruby library to interface with Faria LaunchPad, including an API client and Rails helpers.}
|
@@ -35,11 +35,13 @@ Gem::Specification.new do |spec|
|
|
35
35
|
spec.add_development_dependency "bundler", "~> 1.11"
|
36
36
|
spec.add_development_dependency "rake", "~> 10.0"
|
37
37
|
spec.add_development_dependency "minitest", "~> 5.0"
|
38
|
+
spec.add_development_dependency "pry", "~> 0.10"
|
39
|
+
spec.add_development_dependency "pry-byebug", "~> 3.4"
|
40
|
+
spec.add_development_dependency "simplecov"
|
41
|
+
spec.add_development_dependency "codeclimate-test-reporter", "~> 1.0.0"
|
38
42
|
|
39
|
-
|
40
|
-
|
41
|
-
spec.add_dependency "jwt", "~> 1.5.4"
|
42
|
-
spec.add_dependency "jwe", "~> 0.1.0"
|
43
|
+
spec.add_dependency "jwt", "1.5.6"
|
44
|
+
spec.add_dependency "jwe", "0.1.1"
|
43
45
|
spec.add_dependency "addressable", "~> 2.4"
|
44
46
|
spec.add_dependency "activesupport"
|
45
47
|
end
|
@@ -23,7 +23,7 @@ module Faria
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
-
# encrypting is done with
|
26
|
+
# encrypting is done with LaunchPad public key
|
27
27
|
# signing is done with local private key
|
28
28
|
|
29
29
|
def self.encrypt(data, options = {}, local_key:, remote_key: )
|
@@ -39,14 +39,14 @@ module Faria
|
|
39
39
|
end
|
40
40
|
|
41
41
|
# for cases where you known in advance the remote key to use (such
|
42
|
-
# as
|
43
|
-
#
|
42
|
+
# as LaunchPad clients which will only be receiving messages from
|
43
|
+
# LaunchPad and therefore will only use it's public key for verifying
|
44
44
|
# signatures
|
45
45
|
def self.decrypt(raw_data, options = {}, local_key:, remote_key: )
|
46
|
-
|
46
|
+
_version, jwe = raw_data.split(";", 2)
|
47
47
|
jwt = JWE.decrypt(jwe, local_key)
|
48
48
|
arr = JWT.decode(jwt, remote_key, true, { :algorithm => 'RS512' })
|
49
|
-
payload,
|
49
|
+
payload, _header = arr
|
50
50
|
|
51
51
|
# validate_expiration will be handled by JWT decode
|
52
52
|
validate_url!(payload, options[:actual_url])
|
@@ -57,14 +57,14 @@ module Faria
|
|
57
57
|
# for cases where the signature key is not known in advance and must
|
58
58
|
# be determined by source information embedded in the JWT header
|
59
59
|
def self.decrypt_variable_key(raw_data, options = {}, local_key:, remote_key_func: )
|
60
|
-
|
60
|
+
_version, jwe = raw_data.split(";", 2)
|
61
61
|
jwt = JWE.decrypt(jwe, local_key)
|
62
62
|
header, payload = JWT::Decode.new(jwt, nil, false, {}).decode_segments[0..1]
|
63
63
|
remote_key = remote_key_func.call(header, payload)
|
64
64
|
fail(MissingRemoteKey) if remote_key.nil?
|
65
65
|
|
66
66
|
arr = JWT.decode(jwt, remote_key, true, { :algorithm => 'RS512' })
|
67
|
-
payload,
|
67
|
+
payload, _header = arr
|
68
68
|
|
69
69
|
# validate_expiration will be handled by JWT decode
|
70
70
|
validate_url!(payload, options[:actual_url])
|
@@ -72,8 +72,6 @@ module Faria
|
|
72
72
|
payload["data"]
|
73
73
|
end
|
74
74
|
|
75
|
-
private
|
76
|
-
|
77
75
|
def self.add_source(packet, source)
|
78
76
|
packet[:faria_source] = source
|
79
77
|
packet
|
@@ -5,8 +5,6 @@ module Faria
|
|
5
5
|
module Launchpad
|
6
6
|
class Service
|
7
7
|
|
8
|
-
LAUNCHPAD_NAME = "Launchpad"
|
9
|
-
|
10
8
|
def self.noauth(endpoint, quiet: false)
|
11
9
|
unless quiet
|
12
10
|
puts "************************************************************************\n" \
|
@@ -82,8 +80,12 @@ module Faria
|
|
82
80
|
patch "identities/#{uuid}", identity: identity_representation
|
83
81
|
end
|
84
82
|
|
83
|
+
def import_identities(api_key, identities)
|
84
|
+
post "identities/import", {school_api_key: api_key, identities: identities}
|
85
|
+
end
|
86
|
+
|
85
87
|
# by_value allows the unique pairing value to be used to perform
|
86
|
-
# queries or updates instead of
|
88
|
+
# queries or updates instead of LaunchPad's internal UUID
|
87
89
|
def show_identity_by_pairing_value(pairing_value)
|
88
90
|
get "identities/by_pairing_value/#{pairing_value}"
|
89
91
|
end
|
@@ -153,11 +155,8 @@ module Faria
|
|
153
155
|
payload = encrypt_payload(params, a)
|
154
156
|
if verb == :get
|
155
157
|
request['Faria-JWE'] = payload
|
156
|
-
debug "Faria-JWE: #{payload}"
|
157
158
|
else
|
158
159
|
request['Content-Type'] = "application/jwe"
|
159
|
-
debug "Content-Type: application/jwe"
|
160
|
-
debug "POST BODY: #{payload}"
|
161
160
|
request.body = payload
|
162
161
|
end
|
163
162
|
http.request request
|
@@ -176,10 +175,6 @@ module Faria
|
|
176
175
|
|
177
176
|
private
|
178
177
|
|
179
|
-
def debug(s)
|
180
|
-
puts s
|
181
|
-
end
|
182
|
-
|
183
178
|
VALID_VERBS = %w(get put patch post get delete)
|
184
179
|
|
185
180
|
# can't guarantee we have Rails or AS so we use eval vs
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: faria-launchpad-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Faria Education Group
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -53,33 +53,89 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '5.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: pry
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
62
|
-
type: :
|
61
|
+
version: '0.10'
|
62
|
+
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: '0.10'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: pry-byebug
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
76
|
-
type: :
|
75
|
+
version: '3.4'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.4'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: simplecov
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: codeclimate-test-reporter
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 1.0.0
|
104
|
+
type: :development
|
77
105
|
prerelease: false
|
78
106
|
version_requirements: !ruby/object:Gem::Requirement
|
79
107
|
requirements:
|
80
108
|
- - "~>"
|
81
109
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
110
|
+
version: 1.0.0
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: jwt
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - '='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 1.5.6
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - '='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 1.5.6
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: jwe
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - '='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 0.1.1
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - '='
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: 0.1.1
|
83
139
|
- !ruby/object:Gem::Dependency
|
84
140
|
name: addressable
|
85
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -111,13 +167,14 @@ dependencies:
|
|
111
167
|
description: Ruby library to interface with Faria LaunchPad, including an API client
|
112
168
|
and Rails helpers.
|
113
169
|
email:
|
114
|
-
-
|
170
|
+
- rubygems@fariaedu.com
|
115
171
|
executables:
|
116
172
|
- console
|
117
173
|
- setup
|
118
174
|
extensions: []
|
119
175
|
extra_rdoc_files: []
|
120
176
|
files:
|
177
|
+
- CHANGELOG.md
|
121
178
|
- Gemfile
|
122
179
|
- LICENSE.txt
|
123
180
|
- README.md
|
@@ -152,7 +209,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
152
209
|
version: '0'
|
153
210
|
requirements: []
|
154
211
|
rubyforge_project:
|
155
|
-
rubygems_version: 2.
|
212
|
+
rubygems_version: 2.6.8
|
156
213
|
signing_key:
|
157
214
|
specification_version: 4
|
158
215
|
summary: Ruby library to interface with Faria LaunchPad.
|