aptible-auth 1.1.0 → 1.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '00328550f86b01c32a92affe4e03732823568896937d4789151bd458ef60d119'
4
- data.tar.gz: 762c0481e463f560f9ac56ef4228d985a01f79c343c341e6cc16dca442c77d41
3
+ metadata.gz: e3882d6be5ba4b7d248e84a3e6eced0eba7cd6701108ccbc3bd609eddb4cb0bd
4
+ data.tar.gz: 733da04d17bb312b812988ed832426c72f784b6d97a7734f12f1f9cdd0872242
5
5
  SHA512:
6
- metadata.gz: 0a970d42b7b94aa7d1995b1c4f7e72ba880339efc402fb3e77e8e8e3a18bcb2174dfeea3cb8707270eac99877ef809f6793f3b3f8b94b28087b27e655f020e3a
7
- data.tar.gz: 598365febae878bdb08df3ecaf00f7e894d85ce914664e797c1a8d838091a7f6820575de2e128b84d4e3e20325679a2a58f0fcb99420a04d3672b12170278088
6
+ metadata.gz: aa34d5cc0b4f99db2820f52d224b3092732dc93474bb85ec87798572662eefd4c8d4293cd21330a59d32eac560c15547799cce61f18011f0db78615172e8215f
7
+ data.tar.gz: 5bdbbe7bd497e426d9c7535354ed8aa0748e3d64309eb357aacff5d8ff96a9d814933f39ec3353127e8e47d943af7a51d3343e1854ecfa49f47ee3681780e458
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:
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-aptible', '~> 0.10.0'
25
+ spec.add_dependency 'oauth2', '1.4.7'
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'
@@ -0,0 +1,6 @@
1
+ module Aptible
2
+ module Auth
3
+ class ReauthenticateOrganization < Resource
4
+ end
5
+ end
6
+ end
@@ -25,3 +25,4 @@ require 'aptible/auth/user'
25
25
  require 'aptible/auth/ssh_key'
26
26
  require 'aptible/auth/saml_configuration'
27
27
  require 'aptible/auth/whitelist_membership'
28
+ require 'aptible/auth/reauthenticate_organization'
@@ -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.4'.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(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
@@ -0,0 +1,58 @@
1
+ # rubocop:disable all
2
+ require 'oauth2'
3
+ require 'oauth2/strategy/token_exchange'
4
+ RSpec.describe OAuth2::Strategy::TokenExchange do
5
+ let(:client) do
6
+ cli = OAuth2::Client.new('abc', 'def', :site => 'http://api.example.com')
7
+ cli.connection.build do |b|
8
+ b.adapter :test do |stub|
9
+ stub.post('/oauth/token') do |env|
10
+ case @mode
11
+ when 'formencoded'
12
+ [200, {'Content-Type' => 'application/x-www-form-urlencoded'}, 'expires_in=600&access_token=salmon&refresh_token=trout']
13
+ when 'json'
14
+ [200, {'Content-Type' => 'application/json'}, '{"expires_in":600,"access_token":"salmon","refresh_token":"trout"}']
15
+ end
16
+ end
17
+ end
18
+ end
19
+ cli
20
+ end
21
+ subject { client.token_exchange }
22
+
23
+ describe '#authorize_url' do
24
+ it 'raises NotImplementedError' do
25
+ expect { subject.authorize_url }.to raise_error(NotImplementedError)
26
+ end
27
+ end
28
+
29
+ %w(json formencoded).each do |mode|
30
+ describe "#get_token (#{mode})" do
31
+ before do
32
+ @mode = mode
33
+ @access = subject.get_token('actor token', 'actor token type', 'subject token', 'subject token type')
34
+ end
35
+
36
+ it 'returns AccessToken with same Client' do
37
+ expect(@access.client).to eq(client)
38
+ end
39
+
40
+ it 'returns AccessToken with #token' do
41
+ expect(@access.token).to eq('salmon')
42
+ end
43
+
44
+ it 'returns AccessToken with #refresh_token' do
45
+ expect(@access.refresh_token).to eq('trout')
46
+ end
47
+
48
+ it 'returns AccessToken with #expires_in' do
49
+ expect(@access.expires_in).to eq(600)
50
+ end
51
+
52
+ it 'returns AccessToken with #expires_at' do
53
+ expect(@access.expires_at).not_to be_nil
54
+ end
55
+ end
56
+ end
57
+
58
+ 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.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Frank Macreery
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-01 00:00:00.000000000 Z
11
+ date: 2022-02-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.7
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.7
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
@@ -173,6 +159,7 @@ files:
173
159
  - lib/aptible/auth/invitation.rb
174
160
  - lib/aptible/auth/membership.rb
175
161
  - lib/aptible/auth/organization.rb
162
+ - lib/aptible/auth/reauthenticate_organization.rb
176
163
  - lib/aptible/auth/resource.rb
177
164
  - lib/aptible/auth/role.rb
178
165
  - lib/aptible/auth/saml_configuration.rb
@@ -182,19 +169,22 @@ files:
182
169
  - lib/aptible/auth/user.rb
183
170
  - lib/aptible/auth/version.rb
184
171
  - lib/aptible/auth/whitelist_membership.rb
172
+ - lib/oauth2/response_parser.rb
173
+ - lib/oauth2/strategy/token_exchange.rb
185
174
  - spec/aptible/auth/agent_spec.rb
186
175
  - spec/aptible/auth/organization_spec.rb
187
176
  - spec/aptible/auth/resource_spec.rb
188
177
  - spec/aptible/auth/token_spec.rb
189
178
  - spec/aptible/auth/user_spec.rb
190
179
  - spec/aptible/auth_spec.rb
180
+ - spec/oauth2/lib/token_exchange_spec.rb
191
181
  - spec/shared/set_env.rb
192
182
  - spec/spec_helper.rb
193
183
  homepage: https://github.com/aptible/aptible-auth-ruby
194
184
  licenses:
195
185
  - MIT
196
186
  metadata: {}
197
- post_install_message:
187
+ post_install_message:
198
188
  rdoc_options: []
199
189
  require_paths:
200
190
  - lib
@@ -209,9 +199,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
209
199
  - !ruby/object:Gem::Version
210
200
  version: '0'
211
201
  requirements: []
212
- rubyforge_project:
213
- rubygems_version: 2.7.6.2
214
- signing_key:
202
+ rubygems_version: 3.0.3
203
+ signing_key:
215
204
  specification_version: 4
216
205
  summary: Ruby client for auth.aptible.com
217
206
  test_files:
@@ -221,5 +210,6 @@ test_files:
221
210
  - spec/aptible/auth/token_spec.rb
222
211
  - spec/aptible/auth/user_spec.rb
223
212
  - spec/aptible/auth_spec.rb
213
+ - spec/oauth2/lib/token_exchange_spec.rb
224
214
  - spec/shared/set_env.rb
225
215
  - spec/spec_helper.rb