aptible-auth 1.1.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Gemfile +0 -5
- data/README.md +0 -2
- data/aptible-auth.gemspec +1 -2
- data/lib/aptible/auth/token.rb +2 -0
- data/lib/aptible/auth/version.rb +1 -1
- data/lib/oauth2/response_parser.rb +5 -0
- data/lib/oauth2/strategy/token_exchange.rb +40 -0
- metadata +8 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7149e22dc5b4312e17d2b6c3ba4ca28f66be30dfa279639caa2d44277019e121
|
4
|
+
data.tar.gz: eb4361df78b1cace82024b72c67f270f1c93a013f3f21a6a5fbe6b3f9d2aeff1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0df7b7e3c90027786a38571116d4c142ccb2bf7a8bcb346893cd5e1f8b3316ecee7facf2d6aa465f444da8d79a4aaf91ca3f164d74c589003648655ab858c2e7
|
7
|
+
data.tar.gz: dcc58a8174e38ae47d2af44bed42dd1cea0b4dd9981cdde4a96b1069b5881e2cd34ce367b4fc1367f21798079b157254d4ae341848bcb9cf96ae7f119204a2f5
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -14,8 +14,6 @@ Add the following line to your application's Gemfile.
|
|
14
14
|
|
15
15
|
And then run `bundle install`.
|
16
16
|
|
17
|
-
A forked version of the OAuth2 gem is necessary until [intridea/oauth2#165](https://github.com/intridea/oauth2/pull/165) and [intridea/oauth2#166](https://github.com/intridea/oauth2/pull/166) are merged.
|
18
|
-
|
19
17
|
## Usage
|
20
18
|
|
21
19
|
First, get a token:
|
data/aptible-auth.gemspec
CHANGED
@@ -22,10 +22,9 @@ Gem::Specification.new do |spec|
|
|
22
22
|
|
23
23
|
spec.add_dependency 'aptible-resource', '~> 1.0'
|
24
24
|
spec.add_dependency 'gem_config'
|
25
|
-
spec.add_dependency 'oauth2
|
25
|
+
spec.add_dependency 'oauth2', '~> 1.4'
|
26
26
|
|
27
27
|
spec.add_development_dependency 'aptible-tasks', '>= 0.6.0'
|
28
|
-
spec.add_development_dependency 'bundler', '~> 1.3'
|
29
28
|
spec.add_development_dependency 'pry'
|
30
29
|
spec.add_development_dependency 'rake'
|
31
30
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
data/lib/aptible/auth/token.rb
CHANGED
data/lib/aptible/auth/version.rb
CHANGED
@@ -0,0 +1,5 @@
|
|
1
|
+
# rubocop:disable all
|
2
|
+
# NOTE: This code has been in oauth2 master since 2018 but is awaiting a 2.0 release of oauth2
|
3
|
+
OAuth2::Response.register_parser(:json, ['application/json', 'text/javascript', 'application/hal+json', 'application/vnd.collection+json', 'application/vnd.api+json']) do |body|
|
4
|
+
MultiJson.load(body) rescue body # rubocop:disable RescueModifier
|
5
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# rubocop:disable all
|
2
|
+
module OAuth2
|
3
|
+
module Strategy
|
4
|
+
# The Token Exchange strategy
|
5
|
+
#
|
6
|
+
# @see https://tools.ietf.org/html/draft-ietf-oauth-token-exchange-03#section-4.1
|
7
|
+
class TokenExchange < Base
|
8
|
+
GRANT_TYPE = 'urn:ietf:params:oauth:grant-type:token-exchange'
|
9
|
+
|
10
|
+
# Not used for this strategy
|
11
|
+
#
|
12
|
+
# @raise [NotImplementedError]
|
13
|
+
def authorize_url
|
14
|
+
fail(NotImplementedError, 'The authorization endpoint is not used in this strategy')
|
15
|
+
end
|
16
|
+
|
17
|
+
# Retrieve an access token given the specified End User username and password.
|
18
|
+
#
|
19
|
+
# @param [String] username the End User username
|
20
|
+
# @param [String] password the End User password
|
21
|
+
# @param [Hash] params additional params
|
22
|
+
def get_token(actor_token, actor_token_type, subject_token, subject_token_type, params = {}, opts = {})
|
23
|
+
params = {'grant_type' => GRANT_TYPE,
|
24
|
+
'actor_token' => actor_token,
|
25
|
+
'actor_token_type' => actor_token_type,
|
26
|
+
'subject_token' => subject_token,
|
27
|
+
'subject_token_type' => subject_token_type
|
28
|
+
}.merge(client_params).merge(params)
|
29
|
+
@client.get_token(params, opts)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# Add strategy to OAuth2::Client
|
35
|
+
class Client
|
36
|
+
def token_exchange
|
37
|
+
@token_exchange ||= OAuth2::Strategy::TokenExchange.new(self)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aptible-auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Frank Macreery
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-05-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aptible-resource
|
@@ -39,19 +39,19 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name: oauth2
|
42
|
+
name: oauth2
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: '1.4'
|
48
48
|
type: :runtime
|
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:
|
54
|
+
version: '1.4'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: aptible-tasks
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,20 +66,6 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 0.6.0
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: bundler
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - "~>"
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '1.3'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - "~>"
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '1.3'
|
83
69
|
- !ruby/object:Gem::Dependency
|
84
70
|
name: pry
|
85
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -182,6 +168,8 @@ files:
|
|
182
168
|
- lib/aptible/auth/user.rb
|
183
169
|
- lib/aptible/auth/version.rb
|
184
170
|
- lib/aptible/auth/whitelist_membership.rb
|
171
|
+
- lib/oauth2/response_parser.rb
|
172
|
+
- lib/oauth2/strategy/token_exchange.rb
|
185
173
|
- spec/aptible/auth/agent_spec.rb
|
186
174
|
- spec/aptible/auth/organization_spec.rb
|
187
175
|
- spec/aptible/auth/resource_spec.rb
|
@@ -209,8 +197,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
209
197
|
- !ruby/object:Gem::Version
|
210
198
|
version: '0'
|
211
199
|
requirements: []
|
212
|
-
|
213
|
-
rubygems_version: 2.7.6.2
|
200
|
+
rubygems_version: 3.1.3
|
214
201
|
signing_key:
|
215
202
|
specification_version: 4
|
216
203
|
summary: Ruby client for auth.aptible.com
|