signet 0.4.5 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +3 -2
- data/Gemfile.lock +23 -31
- data/README.md +23 -21
- data/lib/signet/oauth_1/client.rb +0 -1
- data/lib/signet/oauth_2/client.rb +13 -3
- data/lib/signet/version.rb +2 -2
- data/spec/signet/oauth_2/client_spec.rb +17 -2
- data/spec/spec_helper.rb +4 -1
- data/tasks/gem.rake +1 -1
- metadata +18 -18
data/Gemfile
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
source
|
1
|
+
source 'https://rubygems.org'
|
2
2
|
|
3
3
|
gem 'addressable', '>= 2.3.1'
|
4
|
-
gem 'faraday', '
|
4
|
+
gem 'faraday', '>= 0.9.0.rc5'
|
5
5
|
gem 'multi_json', '>= 1.0.0'
|
6
6
|
gem 'jwt', '>= 0.1.5'
|
7
7
|
gem 'extlib', '>= 0.9.15'
|
@@ -15,6 +15,7 @@ end
|
|
15
15
|
|
16
16
|
|
17
17
|
group :test, :development do
|
18
|
+
gem 'json', '~> 1.7.7'
|
18
19
|
gem 'rake', '>= 0.9.0'
|
19
20
|
gem 'rspec', '>= 2.11.0'
|
20
21
|
gem 'rcov', '>= 0.9.9', :platform => :mri_18
|
data/Gemfile.lock
CHANGED
@@ -1,48 +1,40 @@
|
|
1
1
|
GEM
|
2
|
-
remote:
|
2
|
+
remote: https://rubygems.org/
|
3
3
|
specs:
|
4
|
-
addressable (2.3.
|
5
|
-
|
6
|
-
diff-lcs (1.1.3)
|
4
|
+
addressable (2.3.4)
|
5
|
+
diff-lcs (1.2.4)
|
7
6
|
extlib (0.9.16)
|
8
|
-
faraday (0.
|
7
|
+
faraday (0.9.0.rc5)
|
9
8
|
multipart-post (~> 1.1)
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
kramdown (0.14.1)
|
16
|
-
launchy (2.1.2)
|
9
|
+
json (1.7.7)
|
10
|
+
jwt (0.1.8)
|
11
|
+
multi_json (>= 1.5)
|
12
|
+
kramdown (1.0.2)
|
13
|
+
launchy (2.3.0)
|
17
14
|
addressable (~> 2.3)
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
spoon (~> 0.0.1)
|
22
|
-
multi_json (1.5.0)
|
23
|
-
multipart-post (1.1.5)
|
24
|
-
rake (10.0.3)
|
15
|
+
multi_json (1.7.3)
|
16
|
+
multipart-post (1.2.0)
|
17
|
+
rake (10.0.4)
|
25
18
|
rcov (1.0.0)
|
26
|
-
rspec (2.
|
27
|
-
rspec-core (~> 2.
|
28
|
-
rspec-expectations (~> 2.
|
29
|
-
rspec-mocks (~> 2.
|
30
|
-
rspec-core (2.
|
31
|
-
rspec-expectations (2.
|
32
|
-
diff-lcs (
|
33
|
-
rspec-mocks (2.
|
34
|
-
|
35
|
-
yard (0.8.3)
|
19
|
+
rspec (2.13.0)
|
20
|
+
rspec-core (~> 2.13.0)
|
21
|
+
rspec-expectations (~> 2.13.0)
|
22
|
+
rspec-mocks (~> 2.13.0)
|
23
|
+
rspec-core (2.13.1)
|
24
|
+
rspec-expectations (2.13.0)
|
25
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
26
|
+
rspec-mocks (2.13.1)
|
27
|
+
yard (0.8.6.1)
|
36
28
|
|
37
29
|
PLATFORMS
|
38
|
-
java
|
39
30
|
ruby
|
40
31
|
|
41
32
|
DEPENDENCIES
|
42
33
|
addressable (>= 2.3.1)
|
43
34
|
extlib (>= 0.9.15)
|
44
|
-
faraday (
|
35
|
+
faraday (>= 0.9.0.rc5)
|
45
36
|
jruby-openssl
|
37
|
+
json (~> 1.7.7)
|
46
38
|
jwt (>= 0.1.5)
|
47
39
|
kramdown
|
48
40
|
launchy (>= 2.1.1)
|
data/README.md
CHANGED
@@ -25,28 +25,30 @@ Signet is an OAuth 1.0 / OAuth 2.0 implementation.
|
|
25
25
|
|
26
26
|
## Example Usage for Google
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
28
|
+
``` ruby
|
29
|
+
require 'signet/oauth_1/client'
|
30
|
+
client = Signet::OAuth1::Client.new(
|
31
|
+
:temporary_credential_uri =>
|
32
|
+
'https://www.google.com/accounts/OAuthGetRequestToken',
|
33
|
+
:authorization_uri =>
|
34
|
+
'https://www.google.com/accounts/OAuthAuthorizeToken',
|
35
|
+
:token_credential_uri =>
|
36
|
+
'https://www.google.com/accounts/OAuthGetAccessToken',
|
37
|
+
:client_credential_key => 'anonymous',
|
38
|
+
:client_credential_secret => 'anonymous'
|
39
|
+
)
|
40
|
+
client.fetch_temporary_credential!(:additional_parameters => {
|
41
|
+
:scope => 'https://mail.google.com/mail/feed/atom'
|
42
|
+
})
|
43
|
+
# Send the user to client.authorization_uri, obtain verifier
|
44
|
+
client.fetch_token_credential!(:verifier => '12345')
|
45
|
+
response = client.fetch_protected_resource(
|
46
|
+
:uri => 'https://mail.google.com/mail/feed/atom'
|
47
|
+
)
|
48
|
+
```
|
47
49
|
|
48
50
|
## Install
|
49
51
|
|
50
|
-
`
|
52
|
+
`gem install signet`
|
51
53
|
|
52
|
-
Be sure `
|
54
|
+
Be sure `https://rubygems.org` is in your gem sources.
|
@@ -12,7 +12,6 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
gem 'faraday', '~> 0.8.1'
|
16
15
|
require 'faraday'
|
17
16
|
#require 'faraday/utils'
|
18
17
|
|
@@ -22,7 +21,6 @@ require 'signet'
|
|
22
21
|
require 'signet/errors'
|
23
22
|
require 'signet/oauth_2'
|
24
23
|
|
25
|
-
gem 'jwt', '~> 0.1.4'
|
26
24
|
require 'jwt'
|
27
25
|
|
28
26
|
module Signet
|
@@ -191,6 +189,8 @@ module Signet
|
|
191
189
|
# The current ID token for this client.
|
192
190
|
# - <code>:expires_in</code> -
|
193
191
|
# The time in seconds until access token expiration.
|
192
|
+
# - <code>:expires_at</code> -
|
193
|
+
# The time as an integer number of seconds since the Epoch
|
194
194
|
# - <code>:issued_at</code> -
|
195
195
|
# The timestamp that the token was issued at.
|
196
196
|
#
|
@@ -209,6 +209,7 @@ module Signet
|
|
209
209
|
|
210
210
|
self.access_token = options["access_token"] if options["access_token"]
|
211
211
|
self.expires_in = options["expires_in"] if options["expires_in"]
|
212
|
+
self.expires_at = options["expires_at"] if options["expires_at"]
|
212
213
|
|
213
214
|
# The refresh token may not be returned in a token response.
|
214
215
|
# In which case, the old one should continue to be used.
|
@@ -720,13 +721,22 @@ module Signet
|
|
720
721
|
#
|
721
722
|
# @return [Integer] The access token lifetime.
|
722
723
|
def expires_at
|
723
|
-
if @
|
724
|
+
if @expires_at
|
725
|
+
@expires_at
|
726
|
+
elsif @issued_at && @expires_in
|
724
727
|
return @issued_at + @expires_in
|
725
728
|
else
|
726
729
|
return nil
|
727
730
|
end
|
728
731
|
end
|
729
732
|
|
733
|
+
##
|
734
|
+
# Limits the lifetime of the access token as number of seconds since
|
735
|
+
# the Epoch
|
736
|
+
def expires_at=(new_expires_at)
|
737
|
+
@expires_at = Time.at new_expires_at
|
738
|
+
end
|
739
|
+
|
730
740
|
##
|
731
741
|
# Returns true if the access token has expired.
|
732
742
|
#
|
data/lib/signet/version.rb
CHANGED
@@ -20,8 +20,6 @@ require 'spec_helper'
|
|
20
20
|
|
21
21
|
require 'signet/oauth_2/client'
|
22
22
|
require 'openssl'
|
23
|
-
|
24
|
-
gem 'jwt', '~> 0.1.4'
|
25
23
|
require 'jwt'
|
26
24
|
|
27
25
|
conn = Faraday.default_connection
|
@@ -352,6 +350,23 @@ describe Signet::OAuth2::Client, 'configured for Google userinfo API' do
|
|
352
350
|
@client.should_not be_expired
|
353
351
|
end
|
354
352
|
|
353
|
+
it 'should allow the expires_at time to be updated' do
|
354
|
+
expires_at = Time.now.round - 100
|
355
|
+
@client.update_token!(
|
356
|
+
:expires_at => expires_at.to_i,
|
357
|
+
:expires_in => nil
|
358
|
+
)
|
359
|
+
@client.expires_at.should == expires_at
|
360
|
+
@client.should be_expired
|
361
|
+
end
|
362
|
+
|
363
|
+
it 'should allow setting expires_at manually' do
|
364
|
+
expires_at = Time.now.round + 100
|
365
|
+
@client.expires_at = expires_at.to_i
|
366
|
+
@client.expires_at.should == expires_at
|
367
|
+
@client.should_not be_expired
|
368
|
+
end
|
369
|
+
|
355
370
|
it 'should raise an error if the authorization endpoint is not secure' do
|
356
371
|
@client.client_id = 'client-12345'
|
357
372
|
@client.client_secret = 'secret-12345'
|
data/spec/spec_helper.rb
CHANGED
data/tasks/gem.rake
CHANGED
@@ -22,7 +22,7 @@ namespace :gem do
|
|
22
22
|
s.rdoc_options.concat ["--main", "README.md"]
|
23
23
|
|
24
24
|
s.add_runtime_dependency("addressable", ">= 2.2.3")
|
25
|
-
s.add_runtime_dependency("faraday", "
|
25
|
+
s.add_runtime_dependency("faraday", ">= 0.9.0.rc5")
|
26
26
|
s.add_runtime_dependency("multi_json", ">= 1.0.0")
|
27
27
|
s.add_runtime_dependency("jwt", ">= 0.1.5")
|
28
28
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: signet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-05-31 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: addressable
|
16
|
-
requirement: &
|
16
|
+
requirement: &70222590324220 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,21 +21,21 @@ dependencies:
|
|
21
21
|
version: 2.2.3
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70222590324220
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: faraday
|
27
|
-
requirement: &
|
27
|
+
requirement: &70222590323640 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
|
-
- -
|
30
|
+
- - ! '>='
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: 0.
|
32
|
+
version: 0.9.0.rc5
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70222590323640
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: multi_json
|
38
|
-
requirement: &
|
38
|
+
requirement: &70222590323140 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 1.0.0
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70222590323140
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: jwt
|
49
|
-
requirement: &
|
49
|
+
requirement: &70222590322620 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 0.1.5
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70222590322620
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rake
|
60
|
-
requirement: &
|
60
|
+
requirement: &70222590322100 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: 0.9.0
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70222590322100
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rspec
|
71
|
-
requirement: &
|
71
|
+
requirement: &70222590321620 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: 2.11.0
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70222590321620
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: launchy
|
82
|
-
requirement: &
|
82
|
+
requirement: &70222590321100 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,7 +87,7 @@ dependencies:
|
|
87
87
|
version: 2.1.1
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *70222590321100
|
91
91
|
description: ! 'Signet is an OAuth 1.0 / OAuth 2.0 implementation.
|
92
92
|
|
93
93
|
'
|