oauth2-aptible 0.9.4 → 0.9.5

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
  SHA1:
3
- metadata.gz: 3e4cfd03328f7548251940e7f2b052ddd07963c0
4
- data.tar.gz: 066823e26b4a20252effd1c8cca2f64160c1682d
3
+ metadata.gz: c6b1926148110d013c74ebf7d9ecbc0fd41d00bb
4
+ data.tar.gz: 5ba394061da8dbeca872b4678f76f7de8167fe8e
5
5
  SHA512:
6
- metadata.gz: c0ecaa700ac733ec48748abd0c80635de15f8a19b76d5f3736ff70610447f2def9296303ed2cae430e2be9009f732263a0b1d0889bceec8446ab4c6a5f8d519b
7
- data.tar.gz: 807e01a4970da96d7930b50e5ed13c064af0b5fce53b0149853c04f4e01e9758d0b4acbe34ede3fc5b3fa476de570940146ad05cb4e5893684df8ced129ac0ad
6
+ metadata.gz: 61335618b62de6ce94a1bd14dfd1d74b11124bfd7a447c3bee6e4e54346e7c62b4fffe56bf5c31c26a71833ef18369b70b3698c075d08c8f01ac847c94d417a2
7
+ data.tar.gz: 28f32435318e5b48a0d47c5bd6836e3d2a930e06926c3050e153bb1b24c7e07af152cf2f0cc55cc4aa7ac488c070a0147c840b78d88dbe46e19c75a5eee8b3b3
@@ -6,5 +6,6 @@ require 'oauth2/strategy/implicit'
6
6
  require 'oauth2/strategy/password'
7
7
  require 'oauth2/strategy/client_credentials'
8
8
  require 'oauth2/strategy/assertion'
9
+ require 'oauth2/strategy/token_exchange'
9
10
  require 'oauth2/access_token'
10
11
  require 'oauth2/response'
@@ -169,5 +169,9 @@ module OAuth2
169
169
  def assertion
170
170
  @assertion ||= OAuth2::Strategy::Assertion.new(self)
171
171
  end
172
+
173
+ def token_exchange
174
+ @token_exchange ||= OAuth2::Strategy::TokenExchange.new(self)
175
+ end
172
176
  end
173
177
  end
@@ -0,0 +1,32 @@
1
+ module OAuth2
2
+ module Strategy
3
+ # The Token Exchange strategy
4
+ #
5
+ # @see https://tools.ietf.org/html/draft-ietf-oauth-token-exchange-03#section-4.1
6
+ class TokenExchange < Base
7
+ GRANT_TYPE = 'urn:ietf:params:oauth:grant-type:token-exchange'
8
+
9
+ # Not used for this strategy
10
+ #
11
+ # @raise [NotImplementedError]
12
+ def authorize_url
13
+ fail(NotImplementedError, 'The authorization endpoint is not used in this strategy')
14
+ end
15
+
16
+ # Retrieve an access token given the specified End User username and password.
17
+ #
18
+ # @param [String] username the End User username
19
+ # @param [String] password the End User password
20
+ # @param [Hash] params additional params
21
+ def get_token(actor_token, actor_token_type, subject_token, subject_token_type, params = {}, opts = {})
22
+ params = {'grant_type' => GRANT_TYPE,
23
+ 'actor_token' => actor_token,
24
+ 'actor_token_type' => actor_token_type,
25
+ 'subject_token' => subject_token,
26
+ 'subject_token_type' => subject_token_type
27
+ }.merge(client_params).merge(params)
28
+ @client.get_token(params, opts)
29
+ end
30
+ end
31
+ end
32
+ end
@@ -2,7 +2,7 @@ module OAuth2
2
2
  class Version
3
3
  MAJOR = 0
4
4
  MINOR = 9
5
- PATCH = 4
5
+ PATCH = 5
6
6
 
7
7
  class << self
8
8
  # @return [String]
@@ -0,0 +1,58 @@
1
+ require 'helper'
2
+
3
+ describe OAuth2::Strategy::TokenExchange do
4
+ let(:client) do
5
+ cli = OAuth2::Client.new('abc', 'def', :site => 'http://api.example.com')
6
+ cli.connection.build do |b|
7
+ b.adapter :test do |stub|
8
+ stub.post('/oauth/token') do |env|
9
+ case @mode
10
+ when 'formencoded'
11
+ [200, {'Content-Type' => 'application/x-www-form-urlencoded'}, 'expires_in=600&access_token=salmon&refresh_token=trout']
12
+ when 'json'
13
+ [200, {'Content-Type' => 'application/json'}, '{"expires_in":600,"access_token":"salmon","refresh_token":"trout"}']
14
+ end
15
+ end
16
+ end
17
+ end
18
+ cli
19
+ end
20
+ subject { client.token_exchange }
21
+
22
+ describe '#authorize_url' do
23
+ it 'raises NotImplementedError' do
24
+ expect { subject.authorize_url }.to raise_error(NotImplementedError)
25
+ end
26
+ end
27
+
28
+ %w(json formencoded).each do |mode|
29
+ describe "#get_token (#{mode})" do
30
+ before do
31
+ @mode = mode
32
+ @access = subject.get_token('actor token', 'actor token type', 'subject token', 'subject token type')
33
+ end
34
+
35
+ it 'returns AccessToken with same Client' do
36
+ expect(@access.client).to eq(client)
37
+ end
38
+
39
+ it 'returns AccessToken with #token' do
40
+ expect(@access.token).to eq('salmon')
41
+ end
42
+
43
+ it 'returns AccessToken with #refresh_token' do
44
+ expect(@access.refresh_token).to eq('trout')
45
+ end
46
+
47
+ it 'returns AccessToken with #expires_in' do
48
+ expect(@access.expires_in).to eq(600)
49
+ end
50
+
51
+ it 'returns AccessToken with #expires_at' do
52
+ expect(@access.expires_at).not_to be_nil
53
+ end
54
+ end
55
+ end
56
+
57
+ end
58
+
metadata CHANGED
@@ -1,103 +1,103 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oauth2-aptible
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.4
4
+ version: 0.9.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Frank Macreery
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-25 00:00:00.000000000 Z
11
+ date: 2016-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: faraday
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0.8'
34
- - - <
34
+ - - "<"
35
35
  - !ruby/object:Gem::Version
36
36
  version: '0.10'
37
37
  type: :runtime
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
40
40
  requirements:
41
- - - '>='
41
+ - - ">="
42
42
  - !ruby/object:Gem::Version
43
43
  version: '0.8'
44
- - - <
44
+ - - "<"
45
45
  - !ruby/object:Gem::Version
46
46
  version: '0.10'
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: multi_json
49
49
  requirement: !ruby/object:Gem::Requirement
50
50
  requirements:
51
- - - ~>
51
+ - - "~>"
52
52
  - !ruby/object:Gem::Version
53
53
  version: '1.3'
54
54
  type: :runtime
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
- - - ~>
58
+ - - "~>"
59
59
  - !ruby/object:Gem::Version
60
60
  version: '1.3'
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: multi_xml
63
63
  requirement: !ruby/object:Gem::Requirement
64
64
  requirements:
65
- - - ~>
65
+ - - "~>"
66
66
  - !ruby/object:Gem::Version
67
67
  version: '0.5'
68
68
  type: :runtime
69
69
  prerelease: false
70
70
  version_requirements: !ruby/object:Gem::Requirement
71
71
  requirements:
72
- - - ~>
72
+ - - "~>"
73
73
  - !ruby/object:Gem::Version
74
74
  version: '0.5'
75
75
  - !ruby/object:Gem::Dependency
76
76
  name: rack
77
77
  requirement: !ruby/object:Gem::Requirement
78
78
  requirements:
79
- - - ~>
79
+ - - "~>"
80
80
  - !ruby/object:Gem::Version
81
81
  version: '1.2'
82
82
  type: :runtime
83
83
  prerelease: false
84
84
  version_requirements: !ruby/object:Gem::Requirement
85
85
  requirements:
86
- - - ~>
86
+ - - "~>"
87
87
  - !ruby/object:Gem::Version
88
88
  version: '1.2'
89
89
  - !ruby/object:Gem::Dependency
90
90
  name: jwt
91
91
  requirement: !ruby/object:Gem::Requirement
92
92
  requirements:
93
- - - ~>
93
+ - - "~>"
94
94
  - !ruby/object:Gem::Version
95
95
  version: 0.1.8
96
96
  type: :runtime
97
97
  prerelease: false
98
98
  version_requirements: !ruby/object:Gem::Requirement
99
99
  requirements:
100
- - - ~>
100
+ - - "~>"
101
101
  - !ruby/object:Gem::Version
102
102
  version: 0.1.8
103
103
  description: A Ruby wrapper for the OAuth 2.0 protocol built with a similar style
@@ -108,7 +108,7 @@ executables: []
108
108
  extensions: []
109
109
  extra_rdoc_files: []
110
110
  files:
111
- - .document
111
+ - ".document"
112
112
  - CONTRIBUTING.md
113
113
  - LICENSE.md
114
114
  - README.md
@@ -124,6 +124,7 @@ files:
124
124
  - lib/oauth2/strategy/client_credentials.rb
125
125
  - lib/oauth2/strategy/implicit.rb
126
126
  - lib/oauth2/strategy/password.rb
127
+ - lib/oauth2/strategy/token_exchange.rb
127
128
  - lib/oauth2/version.rb
128
129
  - oauth2.gemspec
129
130
  - spec/helper.rb
@@ -136,6 +137,7 @@ files:
136
137
  - spec/oauth2/strategy/client_credentials_spec.rb
137
138
  - spec/oauth2/strategy/implicit_spec.rb
138
139
  - spec/oauth2/strategy/password_spec.rb
140
+ - spec/oauth2/strategy/token_exchange_spec.rb
139
141
  homepage: http://github.com/fancyremarker/oauth2-aptible
140
142
  licenses:
141
143
  - MIT
@@ -146,17 +148,17 @@ require_paths:
146
148
  - lib
147
149
  required_ruby_version: !ruby/object:Gem::Requirement
148
150
  requirements:
149
- - - '>='
151
+ - - ">="
150
152
  - !ruby/object:Gem::Version
151
153
  version: '0'
152
154
  required_rubygems_version: !ruby/object:Gem::Requirement
153
155
  requirements:
154
- - - '>='
156
+ - - ">="
155
157
  - !ruby/object:Gem::Version
156
158
  version: 1.3.5
157
159
  requirements: []
158
160
  rubyforge_project:
159
- rubygems_version: 2.2.2
161
+ rubygems_version: 2.4.5
160
162
  signing_key:
161
163
  specification_version: 4
162
164
  summary: A Ruby wrapper for the OAuth 2.0 protocol.
@@ -171,4 +173,5 @@ test_files:
171
173
  - spec/oauth2/strategy/client_credentials_spec.rb
172
174
  - spec/oauth2/strategy/implicit_spec.rb
173
175
  - spec/oauth2/strategy/password_spec.rb
176
+ - spec/oauth2/strategy/token_exchange_spec.rb
174
177
  has_rdoc: