signet 0.6.1 → 0.7.0
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 +4 -4
- data/CHANGELOG.md +7 -0
- data/Gemfile +1 -0
- data/README.md +22 -18
- data/lib/signet/oauth_1.rb +0 -2
- data/lib/signet/oauth_2.rb +0 -1
- data/lib/signet/oauth_2/client.rb +82 -68
- data/lib/signet/version.rb +2 -2
- data/signet.gemspec +0 -1
- data/spec/signet/oauth_1/services/google_spec.rb +6 -3
- data/spec/signet/oauth_2/client_spec.rb +12 -13
- metadata +3 -18
- data/lib/signet/ssl_config.rb +0 -55
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2417aa777b962d91485c42ae04270934ee8e7f90
|
4
|
+
data.tar.gz: 4e4ae9a6cfa21caeb92f4e15d5efb97016fe1e6d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 04a82c96199451572d5a59a3294f05ea728d71a7b4f67ed6116c135c64597ce79545dfa0f356074c443df238dd503fc2953f3ecb571fad3c37bc1fc619f0bdf3
|
7
|
+
data.tar.gz: 210adf33a7fb46b8dd76f1e65e743d67c49cea0b4c44c0b58645b74c84e8f2303ca29936ab3cf421b9f0050abefdaf33f10d90903e0da9e8747ed2ef9880a51b
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
# 0.7
|
2
|
+
* No longer overwrite SSL environment variables.
|
3
|
+
* Tighten up date & URL (de)serialization for OAuth2 client
|
4
|
+
* Allow Hurley as a connection
|
5
|
+
* Add expires_within(sec) method to oauth2 client to facilitate proactive
|
6
|
+
refreshes
|
7
|
+
|
1
8
|
# 0.6.1
|
2
9
|
* Fix language warnings for unused & shadowed variables ((@blowmage)[])
|
3
10
|
* Update SSL cert path for OSX ((@gambaroff)[])
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -25,26 +25,30 @@ Signet is an OAuth 1.0 / OAuth 2.0 implementation.
|
|
25
25
|
|
26
26
|
## Example Usage for Google
|
27
27
|
|
28
|
+
# Initialize the client
|
29
|
+
|
28
30
|
``` ruby
|
29
|
-
require 'signet/
|
30
|
-
client = Signet::
|
31
|
-
:
|
32
|
-
|
33
|
-
:
|
34
|
-
|
35
|
-
:
|
36
|
-
|
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'
|
31
|
+
require 'signet/oauth_2/client'
|
32
|
+
client = Signet::OAuth2::Client.new(
|
33
|
+
:authorization_uri => 'https://accounts.google.com/o/oauth2/auth',
|
34
|
+
:token_credential_uri => 'https://www.googleapis.com/oauth2/v3/token',
|
35
|
+
:client_id => '44410190108-74nkm6jc5e3vvjqis803frkvmu88cu3a.apps.googleusercontent.com',
|
36
|
+
:client_secret => 'X1NUhvO-rQr9sm8uUSMY8i7v',
|
37
|
+
:scope => 'email profile',
|
38
|
+
:redirect_uri => 'https://example.client.com/oauth'
|
47
39
|
)
|
40
|
+
|
41
|
+
# Request an authorization code
|
42
|
+
|
43
|
+
```
|
44
|
+
redirect_to(client.authorization_uri)
|
45
|
+
```
|
46
|
+
|
47
|
+
# Obtain an access token
|
48
|
+
|
49
|
+
```
|
50
|
+
client.code = request.query['code']
|
51
|
+
client.fetch_access_token!
|
48
52
|
```
|
49
53
|
|
50
54
|
## Install
|
data/lib/signet/oauth_1.rb
CHANGED
data/lib/signet/oauth_2.rb
CHANGED
@@ -13,19 +13,19 @@
|
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
15
|
require 'faraday'
|
16
|
-
#require 'faraday/utils'
|
17
|
-
|
18
16
|
require 'stringio'
|
19
17
|
require 'addressable/uri'
|
20
18
|
require 'signet'
|
21
19
|
require 'signet/errors'
|
22
20
|
require 'signet/oauth_2'
|
23
|
-
|
24
21
|
require 'jwt'
|
25
22
|
|
26
23
|
module Signet
|
27
24
|
module OAuth2
|
28
25
|
class Client
|
26
|
+
|
27
|
+
OOB_MODES = %w(urn:ietf:wg:oauth:2.0:oob:auto urn:ietf:wg:oauth:2.0:oob oob)
|
28
|
+
|
29
29
|
##
|
30
30
|
# Creates an OAuth 2.0 client.
|
31
31
|
#
|
@@ -90,20 +90,19 @@ module Signet
|
|
90
90
|
# @see Signet::OAuth2::Client#update!
|
91
91
|
def initialize(options={})
|
92
92
|
@authorization_uri = nil
|
93
|
+
@token_credential_uri = nil
|
93
94
|
@client_id = nil
|
94
95
|
@client_secret = nil
|
95
96
|
@code = nil
|
96
97
|
@expires_at = nil
|
97
98
|
@expires_in = nil
|
98
99
|
@issued_at = nil
|
99
|
-
@issued_at = nil
|
100
100
|
@issuer = nil
|
101
101
|
@password = nil
|
102
102
|
@principal = nil
|
103
103
|
@redirect_uri = nil
|
104
104
|
@scope = nil
|
105
105
|
@state = nil
|
106
|
-
@token_credential_uri = nil
|
107
106
|
@username = nil
|
108
107
|
self.update!(options)
|
109
108
|
end
|
@@ -571,10 +570,10 @@ module Signet
|
|
571
570
|
# Sets the number of seconds assertions are valid for
|
572
571
|
# Used only by the assertion grant type.
|
573
572
|
#
|
574
|
-
# @param [String] new_expiry
|
573
|
+
# @param [Fixnum, String] new_expiry
|
575
574
|
# Assertion expiry, in seconds
|
576
575
|
def expiry=(new_expiry)
|
577
|
-
@expiry = new_expiry
|
576
|
+
@expiry = new_expiry ? new_expiry.to_i : nil
|
578
577
|
end
|
579
578
|
|
580
579
|
|
@@ -723,7 +722,7 @@ module Signet
|
|
723
722
|
##
|
724
723
|
# Returns the lifetime of the access token in seconds.
|
725
724
|
#
|
726
|
-
# @return [
|
725
|
+
# @return [Fixnum] The access token lifetime.
|
727
726
|
def expires_in
|
728
727
|
return @expires_in
|
729
728
|
end
|
@@ -732,21 +731,21 @@ module Signet
|
|
732
731
|
# Sets the lifetime of the access token in seconds. Resets the issued
|
733
732
|
# timestamp.
|
734
733
|
#
|
735
|
-
# @param [String] new_expires_in
|
734
|
+
# @param [String, Fixnum] new_expires_in
|
736
735
|
# The access token lifetime.
|
737
736
|
def expires_in=(new_expires_in)
|
738
737
|
if new_expires_in != nil
|
739
738
|
@expires_in = new_expires_in.to_i
|
740
739
|
@issued_at = Time.now
|
741
740
|
else
|
742
|
-
@expires_in, @issued_at = nil, nil
|
741
|
+
@expires_in, @issued_at, @expires_at = nil, nil, nil
|
743
742
|
end
|
744
743
|
end
|
745
744
|
|
746
745
|
##
|
747
746
|
# Returns the timestamp the access token was issued at.
|
748
747
|
#
|
749
|
-
# @return [
|
748
|
+
# @return [Time] The access token issuance time.
|
750
749
|
def issued_at
|
751
750
|
return @issued_at
|
752
751
|
end
|
@@ -754,16 +753,16 @@ module Signet
|
|
754
753
|
##
|
755
754
|
# Sets the timestamp the access token was issued at.
|
756
755
|
#
|
757
|
-
# @param [String] new_issued_at
|
756
|
+
# @param [String,Fixnum,Time] new_issued_at
|
758
757
|
# The access token issuance time.
|
759
758
|
def issued_at=(new_issued_at)
|
760
|
-
@issued_at = new_issued_at
|
759
|
+
@issued_at = normalize_timestamp(new_issued_at)
|
761
760
|
end
|
762
761
|
|
763
762
|
##
|
764
763
|
# Returns the timestamp the access token will expire at.
|
765
764
|
#
|
766
|
-
# @return [
|
765
|
+
# @return [Time] The access token lifetime.
|
767
766
|
def expires_at
|
768
767
|
if @expires_at
|
769
768
|
@expires_at
|
@@ -777,8 +776,10 @@ module Signet
|
|
777
776
|
##
|
778
777
|
# Limits the lifetime of the access token as number of seconds since
|
779
778
|
# the Epoch
|
779
|
+
# @param [String,Fixnum,Time] new_expires_at
|
780
|
+
# The access token issuance time.
|
780
781
|
def expires_at=(new_expires_at)
|
781
|
-
@expires_at =
|
782
|
+
@expires_at = normalize_timestamp(new_expires_at)
|
782
783
|
end
|
783
784
|
|
784
785
|
##
|
@@ -790,6 +791,18 @@ module Signet
|
|
790
791
|
return self.expires_at != nil && Time.now >= self.expires_at
|
791
792
|
end
|
792
793
|
|
794
|
+
##
|
795
|
+
# Returns true if the access token has expired or expires within
|
796
|
+
# the next n seconds
|
797
|
+
#
|
798
|
+
# @param [Fixnum] sec
|
799
|
+
# Max number of seconds from now where a token is still considered
|
800
|
+
# expired.
|
801
|
+
# @return [TrueClass, FalseClass]
|
802
|
+
# The expiration state of the access token.
|
803
|
+
def expires_within?(sec)
|
804
|
+
return self.expires_at != nil && Time.now >= (self.expires_at - sec)
|
805
|
+
end
|
793
806
|
|
794
807
|
##
|
795
808
|
# Removes all credentials from the client.
|
@@ -869,20 +882,21 @@ module Signet
|
|
869
882
|
# @return [String] A serialized JSON representation of the client.
|
870
883
|
def to_json
|
871
884
|
return MultiJson.dump({
|
872
|
-
'authorization_uri' => self.authorization_uri,
|
873
|
-
'token_credential_uri' => self.token_credential_uri,
|
885
|
+
'authorization_uri' => self.authorization_uri ? self.authorization_uri.to_s : nil,
|
886
|
+
'token_credential_uri' => self.token_credential_uri ? self.token_credential_uri.to_s : nil,
|
874
887
|
'client_id' => self.client_id,
|
875
888
|
'client_secret' => self.client_secret,
|
876
889
|
'scope' => self.scope,
|
877
890
|
'state' => self.state,
|
878
891
|
'code' => self.code,
|
879
|
-
'redirect_uri' => self.redirect_uri,
|
892
|
+
'redirect_uri' => self.redirect_uri ? self.redirect_uri.to_s : nil,
|
880
893
|
'username' => self.username,
|
881
894
|
'password' => self.password,
|
882
895
|
'issuer' => self.issuer,
|
883
896
|
'audience' => self.audience,
|
884
897
|
'person' => self.person,
|
885
898
|
'expiry' => self.expiry,
|
899
|
+
'expires_at' => self.expires_at ? self.expires_at.to_i : nil,
|
886
900
|
'signing_key' => self.signing_key,
|
887
901
|
'refresh_token' => self.refresh_token,
|
888
902
|
'access_token' => self.access_token,
|
@@ -899,16 +913,11 @@ module Signet
|
|
899
913
|
# - <code>:code</code> -
|
900
914
|
# The authorization code.
|
901
915
|
#
|
916
|
+
# @private
|
902
917
|
# @return [Array] The request object.
|
903
918
|
def generate_access_token_request(options={})
|
904
919
|
options = deep_hash_normalize(options)
|
905
920
|
|
906
|
-
if self.token_credential_uri == nil
|
907
|
-
raise ArgumentError, 'Missing token endpoint URI.'
|
908
|
-
end
|
909
|
-
|
910
|
-
options[:connection] ||= Faraday.default_connection
|
911
|
-
method = 'POST'
|
912
921
|
parameters = {"grant_type" => self.grant_type}
|
913
922
|
case self.grant_type
|
914
923
|
when 'authorization_code'
|
@@ -931,48 +940,53 @@ module Signet
|
|
931
940
|
end
|
932
941
|
parameters['client_id'] = self.client_id unless self.client_id.nil?
|
933
942
|
parameters['client_secret'] = self.client_secret unless self.client_secret.nil?
|
934
|
-
|
935
|
-
|
936
|
-
|
937
|
-
|
938
|
-
parameters.merge!(self.additional_parameters.merge(options[:additional_parameters] || {}))
|
939
|
-
return options[:connection].build_request(
|
940
|
-
method.to_s.downcase.to_sym
|
941
|
-
) do |req|
|
942
|
-
req.url(Addressable::URI.parse(
|
943
|
-
self.token_credential_uri
|
944
|
-
).normalize.to_s)
|
945
|
-
req.headers = Faraday::Utils::Headers.new(headers)
|
946
|
-
req.body = Addressable::URI.form_encode(parameters)
|
947
|
-
end
|
943
|
+
parameters['scope'] = options[:scope] if options[:scope]
|
944
|
+
additional = self.additional_parameters.merge(options[:additional_parameters] || {})
|
945
|
+
additional.each { |k, v| parameters[k.to_s] = v }
|
946
|
+
parameters
|
948
947
|
end
|
949
948
|
|
950
949
|
def fetch_access_token(options={})
|
950
|
+
if self.token_credential_uri == nil
|
951
|
+
raise ArgumentError, 'Missing token endpoint URI.'
|
952
|
+
end
|
953
|
+
|
951
954
|
options = deep_hash_normalize(options)
|
952
955
|
|
953
|
-
options[:connection] ||= Faraday.default_connection
|
954
|
-
|
955
|
-
|
956
|
-
|
957
|
-
response =
|
958
|
-
if response.status
|
959
|
-
|
960
|
-
|
961
|
-
|
956
|
+
client = options[:connection] ||= Faraday.default_connection
|
957
|
+
url = Addressable::URI.parse(self.token_credential_uri).normalize.to_s
|
958
|
+
parameters = self.generate_access_token_request(options)
|
959
|
+
|
960
|
+
response = client.post url, parameters
|
961
|
+
if response.respond_to?(:status)
|
962
|
+
# Faraday connection
|
963
|
+
status = response.status.to_i
|
964
|
+
body = response.body
|
965
|
+
content_type = response.headers['Content-type']
|
966
|
+
else
|
967
|
+
# Hurley
|
968
|
+
status = response.status_code.to_i
|
969
|
+
body = response.body
|
970
|
+
content_type = response.header[:content_type]
|
971
|
+
end
|
972
|
+
|
973
|
+
if status == 200
|
974
|
+
return ::Signet::OAuth2.parse_credentials(body, content_type)
|
975
|
+
elsif [400, 401, 403].include?(status)
|
962
976
|
message = 'Authorization failed.'
|
963
|
-
if
|
977
|
+
if body.to_s.strip.length > 0
|
964
978
|
message += " Server message:\n#{response.body.to_s.strip}"
|
965
979
|
end
|
966
980
|
raise ::Signet::AuthorizationError.new(
|
967
|
-
message, :
|
981
|
+
message, :response => response
|
968
982
|
)
|
969
983
|
else
|
970
984
|
message = "Unexpected status code: #{response.status}."
|
971
|
-
if
|
985
|
+
if body.to_s.strip.length > 0
|
972
986
|
message += " Server message:\n#{response.body.to_s.strip}"
|
973
987
|
end
|
974
988
|
raise ::Signet::AuthorizationError.new(
|
975
|
-
message, :
|
989
|
+
message, :response => response
|
976
990
|
)
|
977
991
|
end
|
978
992
|
end
|
@@ -1019,7 +1033,6 @@ module Signet
|
|
1019
1033
|
# The HTTP body for the request.
|
1020
1034
|
# - <code>:realm</code> -
|
1021
1035
|
# The Authorization realm. See RFC 2617.
|
1022
|
-
#
|
1023
1036
|
# @return [Faraday::Request] The request object.
|
1024
1037
|
def generate_authenticated_request(options={})
|
1025
1038
|
options = deep_hash_normalize(options)
|
@@ -1100,16 +1113,6 @@ module Signet
|
|
1100
1113
|
# :uri => 'http://www.example.com/protected/resource'
|
1101
1114
|
# )
|
1102
1115
|
#
|
1103
|
-
# @example
|
1104
|
-
# # Using Typhoeus
|
1105
|
-
# response = client.fetch_protected_resource(
|
1106
|
-
# :request => Typhoeus::Request.new(
|
1107
|
-
# 'http://www.example.com/protected/resource'
|
1108
|
-
# ),
|
1109
|
-
# :adapter => HTTPAdapter::TyphoeusAdapter.new,
|
1110
|
-
# :connection => connection
|
1111
|
-
# )
|
1112
|
-
#
|
1113
1116
|
# @return [Array] The response object.
|
1114
1117
|
def fetch_protected_resource(options={})
|
1115
1118
|
options = deep_hash_normalize(options)
|
@@ -1147,7 +1150,7 @@ module Signet
|
|
1147
1150
|
# Check if the URI is a out-of-band
|
1148
1151
|
# @private
|
1149
1152
|
def uri_is_oob?(uri)
|
1150
|
-
return
|
1153
|
+
return OOB_MODES.include?(uri.to_s)
|
1151
1154
|
end
|
1152
1155
|
|
1153
1156
|
# Convert all keys in this hash (nested) to symbols for uniform retrieval
|
@@ -1160,13 +1163,24 @@ module Signet
|
|
1160
1163
|
end
|
1161
1164
|
|
1162
1165
|
def deep_hash_normalize(old_hash)
|
1163
|
-
|
1166
|
+
sym_hash = {}
|
1167
|
+
old_hash and old_hash.each {|k,v| sym_hash[k.to_sym] = recursive_hash_normalize_keys(v)}
|
1168
|
+
sym_hash
|
1169
|
+
end
|
1164
1170
|
|
1165
|
-
|
1166
|
-
|
1171
|
+
def normalize_timestamp(time)
|
1172
|
+
case time
|
1173
|
+
when NilClass
|
1174
|
+
nil
|
1175
|
+
when Time
|
1176
|
+
time
|
1177
|
+
when String
|
1178
|
+
Time.parse(issued_at)
|
1179
|
+
when Fixnum
|
1180
|
+
Time.at(time)
|
1181
|
+
else
|
1182
|
+
fail "Invalid time value #{time}"
|
1167
1183
|
end
|
1168
|
-
|
1169
|
-
formatted_hash
|
1170
1184
|
end
|
1171
1185
|
end
|
1172
1186
|
end
|
data/lib/signet/version.rb
CHANGED
data/signet.gemspec
CHANGED
@@ -27,7 +27,6 @@ Gem::Specification.new do |s|
|
|
27
27
|
s.add_runtime_dependency 'faraday', '~> 0.9'
|
28
28
|
s.add_runtime_dependency 'multi_json', '~> 1.10'
|
29
29
|
s.add_runtime_dependency 'jwt', '~> 1.5'
|
30
|
-
s.add_runtime_dependency 'extlib', '~> 0.9'
|
31
30
|
|
32
31
|
s.add_development_dependency 'rake', '~> 10.0'
|
33
32
|
s.add_development_dependency 'yard', '~> 0.8'
|
@@ -95,14 +95,16 @@ describe Signet::OAuth1::Client, 'configured for standard Google APIs' do
|
|
95
95
|
end
|
96
96
|
|
97
97
|
it 'should raise an error if the token credentials are bogus' do
|
98
|
-
expect
|
98
|
+
expect do
|
99
|
+
skip 'Need to replace with mocked response as google endpoints no longer use oauth1'
|
99
100
|
@client.token_credential_key = '12345'
|
100
101
|
@client.token_credential_secret = '12345'
|
101
|
-
@client.fetch_protected_resource(
|
102
|
+
res = @client.fetch_protected_resource(
|
102
103
|
:uri =>
|
103
104
|
'https://www.google.com/m8/feeds/'
|
104
105
|
)
|
105
|
-
|
106
|
+
puts "Res = #{res.status}"
|
107
|
+
end.to raise_error(Signet::AuthorizationError)
|
106
108
|
end
|
107
109
|
|
108
110
|
# We have to stub responses for the token credentials
|
@@ -228,6 +230,7 @@ describe Signet::OAuth1::Client, 'configured for two-legged OAuth' do
|
|
228
230
|
end
|
229
231
|
|
230
232
|
it 'should raise an error if the client credentials are bogus' do
|
233
|
+
skip 'Need to replace with mocked response as google endpoints no longer use oauth1'
|
231
234
|
expect(lambda do
|
232
235
|
@client.fetch_protected_resource(
|
233
236
|
:uri =>
|
@@ -263,7 +263,7 @@ describe Signet::OAuth2::Client, 'configured for assertions profile' do
|
|
263
263
|
it 'should send valid access token request' do
|
264
264
|
stubs = Faraday::Adapter::Test::Stubs.new do |stub|
|
265
265
|
stub.post('/o/oauth2/token') do |env|
|
266
|
-
params =
|
266
|
+
params = env[:body]
|
267
267
|
claim, header = JWT.decode(params.assoc("assertion").last, @key.public_key)
|
268
268
|
expect(params.assoc("grant_type")).to eq ['grant_type','urn:ietf:params:oauth:grant-type:jwt-bearer']
|
269
269
|
build_json_response({
|
@@ -370,8 +370,7 @@ describe Signet::OAuth2::Client, 'configured for Google userinfo API' do
|
|
370
370
|
'PEFzc2VydGlvbiBJc3N1ZUluc3RhbnQ9IjIwMTEtMDU'
|
371
371
|
|
372
372
|
request = @client.generate_access_token_request
|
373
|
-
|
374
|
-
expect(params).to include(['assertion', 'PEFzc2VydGlvbiBJc3N1ZUluc3RhbnQ9IjIwMTEtMDU'])
|
373
|
+
expect(request).to include('assertion' => 'PEFzc2VydGlvbiBJc3N1ZUluc3RhbnQ9IjIwMTEtMDU')
|
375
374
|
end
|
376
375
|
|
377
376
|
it 'should allow the token to be updated' do
|
@@ -889,7 +888,7 @@ xwIDAQAB
|
|
889
888
|
-----END PUBLIC KEY-----
|
890
889
|
PUBKEY
|
891
890
|
@client.decoded_id_token(pubkey)
|
892
|
-
end).to raise_error(JWT::
|
891
|
+
end).to raise_error(JWT::VerificationError)
|
893
892
|
stubs.verify_stubbed_calls
|
894
893
|
end
|
895
894
|
end
|
@@ -956,9 +955,9 @@ describe Signet::OAuth2::Client, 'configured with custom parameters' do
|
|
956
955
|
|
957
956
|
it 'should merge new generate_access_token_request custom parameters' do
|
958
957
|
@client.update!(:code=>'12345')
|
959
|
-
|
960
|
-
expect(
|
961
|
-
expect(
|
958
|
+
params = @client.generate_access_token_request(:additional_parameters => {'type' => 'new_type', 'new_param' => 'new_val'})
|
959
|
+
expect(params).to include('type' => 'new_type')
|
960
|
+
expect(params).to include('new_param' => 'new_val')
|
962
961
|
end
|
963
962
|
end
|
964
963
|
|
@@ -1000,9 +999,9 @@ describe Signet::OAuth2::Client, 'configured with custom parameters' do
|
|
1000
999
|
|
1001
1000
|
it 'should merge new generate_access_token_request custom parameters' do
|
1002
1001
|
@client.update!(:code=>'12345')
|
1003
|
-
|
1004
|
-
expect(
|
1005
|
-
expect(
|
1002
|
+
params = @client.generate_access_token_request(:additional_parameters => {'type' => 'new_type', 'new_param' => 'new_val'})
|
1003
|
+
expect(params).to include("type" => "new_type")
|
1004
|
+
expect(params).to include("new_param" => "new_val")
|
1006
1005
|
end
|
1007
1006
|
end
|
1008
1007
|
|
@@ -1049,8 +1048,8 @@ describe Signet::OAuth2::Client, 'configured with custom parameters a la JSON.lo
|
|
1049
1048
|
|
1050
1049
|
it 'should merge new generate_access_token_request custom parameters' do
|
1051
1050
|
@client.update!(:code=>'12345')
|
1052
|
-
|
1053
|
-
expect(
|
1054
|
-
expect(
|
1051
|
+
params = @client.generate_access_token_request(:additional_parameters => {'type' => 'new_type', 'new_param' => 'new_val'})
|
1052
|
+
expect(params).to include("type" => "new_type")
|
1053
|
+
expect(params).to include("new_param" => "new_val")
|
1055
1054
|
end
|
1056
1055
|
end
|
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.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bob Aman
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-06
|
12
|
+
date: 2015-12-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: addressable
|
@@ -67,20 +67,6 @@ dependencies:
|
|
67
67
|
- - "~>"
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '1.5'
|
70
|
-
- !ruby/object:Gem::Dependency
|
71
|
-
name: extlib
|
72
|
-
requirement: !ruby/object:Gem::Requirement
|
73
|
-
requirements:
|
74
|
-
- - "~>"
|
75
|
-
- !ruby/object:Gem::Version
|
76
|
-
version: '0.9'
|
77
|
-
type: :runtime
|
78
|
-
prerelease: false
|
79
|
-
version_requirements: !ruby/object:Gem::Requirement
|
80
|
-
requirements:
|
81
|
-
- - "~>"
|
82
|
-
- !ruby/object:Gem::Version
|
83
|
-
version: '0.9'
|
84
70
|
- !ruby/object:Gem::Dependency
|
85
71
|
name: rake
|
86
72
|
requirement: !ruby/object:Gem::Requirement
|
@@ -193,7 +179,6 @@ files:
|
|
193
179
|
- lib/signet/oauth_1/signature_methods/rsa_sha1.rb
|
194
180
|
- lib/signet/oauth_2.rb
|
195
181
|
- lib/signet/oauth_2/client.rb
|
196
|
-
- lib/signet/ssl_config.rb
|
197
182
|
- lib/signet/version.rb
|
198
183
|
- signet.gemspec
|
199
184
|
- spec/force_compat/digest/hmac.rb
|
@@ -241,7 +226,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
241
226
|
version: 1.3.5
|
242
227
|
requirements: []
|
243
228
|
rubyforge_project:
|
244
|
-
rubygems_version: 2.4.
|
229
|
+
rubygems_version: 2.4.6
|
245
230
|
signing_key:
|
246
231
|
specification_version: 4
|
247
232
|
summary: Signet is an OAuth 1.0 / OAuth 2.0 implementation.
|
data/lib/signet/ssl_config.rb
DELETED
@@ -1,55 +0,0 @@
|
|
1
|
-
if (!ENV['SSL_CERT_FILE'] || !File.exist?(ENV['SSL_CERT_FILE'])) &&
|
2
|
-
(!ENV['SSL_CERT_DIR'] || !File.exist?(ENV['SSL_CERT_DIR']))
|
3
|
-
# Attempt to copy over from other environment variables or well-known
|
4
|
-
# locations. But seriously, just set the environment variables!
|
5
|
-
common_ca_file_locations = [
|
6
|
-
ENV['CA_FILE'],
|
7
|
-
'/usr/local/lib/ssl/certs/ca-certificates.crt',
|
8
|
-
'/usr/local/ssl/certs/ca-certificates.crt',
|
9
|
-
'/usr/local/share/curl/curl-ca-bundle.crt',
|
10
|
-
'/usr/local/etc/openssl/cert.pem',
|
11
|
-
'/opt/local/lib/ssl/certs/ca-certificates.crt',
|
12
|
-
'/opt/local/ssl/certs/ca-certificates.crt',
|
13
|
-
'/opt/local/share/curl/curl-ca-bundle.crt',
|
14
|
-
'/opt/local/etc/openssl/cert.pem',
|
15
|
-
'/usr/lib/ssl/certs/ca-certificates.crt',
|
16
|
-
'/usr/ssl/certs/ca-certificates.crt',
|
17
|
-
'/usr/share/curl/curl-ca-bundle.crt',
|
18
|
-
'/etc/ssl/certs/ca-certificates.crt',
|
19
|
-
'/etc/openssl/cert.pem',
|
20
|
-
'/etc/pki/tls/cert.pem',
|
21
|
-
'/etc/pki/CA/cacert.pem',
|
22
|
-
'C:\Windows\curl-ca-bundle.crt',
|
23
|
-
'C:\Windows\ca-bundle.crt',
|
24
|
-
'C:\Windows\cacert.pem',
|
25
|
-
'./curl-ca-bundle.crt',
|
26
|
-
'./cacert.pem',
|
27
|
-
'~/.cacert.pem'
|
28
|
-
]
|
29
|
-
common_ca_path_locations = [
|
30
|
-
ENV['CA_PATH'],
|
31
|
-
'/usr/local/lib/ssl/certs',
|
32
|
-
'/usr/local/ssl/certs',
|
33
|
-
'/opt/local/lib/ssl/certs',
|
34
|
-
'/opt/local/ssl/certs',
|
35
|
-
'/usr/lib/ssl/certs',
|
36
|
-
'/usr/ssl/certs',
|
37
|
-
'/etc/ssl/certs'
|
38
|
-
]
|
39
|
-
ENV['SSL_CERT_FILE'] = nil
|
40
|
-
ENV['SSL_CERT_DIR'] = nil
|
41
|
-
for location in common_ca_file_locations
|
42
|
-
if location && File.exist?(location)
|
43
|
-
ENV['SSL_CERT_FILE'] = File.expand_path(location)
|
44
|
-
break
|
45
|
-
end
|
46
|
-
end
|
47
|
-
unless ENV['SSL_CERT_FILE']
|
48
|
-
for location in common_ca_path_locations
|
49
|
-
if location && File.exist?(location)
|
50
|
-
ENV['SSL_CERT_DIR'] = File.expand_path(location)
|
51
|
-
break
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|