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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '00328550f86b01c32a92affe4e03732823568896937d4789151bd458ef60d119'
4
- data.tar.gz: 762c0481e463f560f9ac56ef4228d985a01f79c343c341e6cc16dca442c77d41
3
+ metadata.gz: 7149e22dc5b4312e17d2b6c3ba4ca28f66be30dfa279639caa2d44277019e121
4
+ data.tar.gz: eb4361df78b1cace82024b72c67f270f1c93a013f3f21a6a5fbe6b3f9d2aeff1
5
5
  SHA512:
6
- metadata.gz: 0a970d42b7b94aa7d1995b1c4f7e72ba880339efc402fb3e77e8e8e3a18bcb2174dfeea3cb8707270eac99877ef809f6793f3b3f8b94b28087b27e655f020e3a
7
- data.tar.gz: 598365febae878bdb08df3ecaf00f7e894d85ce914664e797c1a8d838091a7f6820575de2e128b84d4e3e20325679a2a58f0fcb99420a04d3672b12170278088
6
+ metadata.gz: 0df7b7e3c90027786a38571116d4c142ccb2bf7a8bcb346893cd5e1f8b3316ecee7facf2d6aa465f444da8d79a4aaf91ca3f164d74c589003648655ab858c2e7
7
+ data.tar.gz: dcc58a8174e38ae47d2af44bed42dd1cea0b4dd9981cdde4a96b1069b5881e2cd34ce367b4fc1367f21798079b157254d4ae341848bcb9cf96ae7f119204a2f5
data/.gitignore CHANGED
@@ -15,3 +15,4 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+ .idea
data/Gemfile CHANGED
@@ -1,7 +1,2 @@
1
1
  source 'https://rubygems.org'
2
-
3
- gem 'activesupport', '~> 4.0'
4
- gem 'rack', '~> 1.6'
5
-
6
- # Specify your gem's dependencies in aptible-auth.gemspec
7
2
  gemspec
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:
@@ -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-aptible', '~> 0.10.0'
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'
@@ -1,4 +1,6 @@
1
1
  require 'oauth2'
2
+ require 'oauth2/response_parser'
3
+ require 'oauth2/strategy/token_exchange'
2
4
 
3
5
  module Aptible
4
6
  module Auth
@@ -1,5 +1,5 @@
1
1
  module Aptible
2
2
  module Auth
3
- VERSION = '1.1.0'.freeze
3
+ VERSION = '1.2.1'.freeze
4
4
  end
5
5
  end
@@ -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.0
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-04-01 00:00:00.000000000 Z
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-aptible
42
+ name: oauth2
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.10.0
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: 0.10.0
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
- rubyforge_project:
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