oauth 0.5.6 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +504 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/CONTRIBUTING.md +40 -0
- data/LICENSE +19 -17
- data/README.md +390 -0
- data/SECURITY.md +26 -0
- data/lib/oauth/client/action_controller_request.rb +23 -21
- data/lib/oauth/client/em_http.rb +99 -99
- data/lib/oauth/client/helper.rb +83 -82
- data/lib/oauth/client/net_http.rb +112 -105
- data/lib/oauth/client.rb +2 -0
- data/lib/oauth/consumer.rb +147 -133
- data/lib/oauth/errors/error.rb +2 -0
- data/lib/oauth/errors/problem.rb +3 -0
- data/lib/oauth/errors/unauthorized.rb +7 -1
- data/lib/oauth/errors.rb +5 -3
- data/lib/oauth/helper.rb +26 -18
- data/lib/oauth/oauth.rb +6 -4
- data/lib/oauth/oauth_test_helper.rb +6 -4
- data/lib/oauth/request_proxy/action_controller_request.rb +49 -71
- data/lib/oauth/request_proxy/action_dispatch_request.rb +8 -4
- data/lib/oauth/request_proxy/base.rb +136 -132
- data/lib/oauth/request_proxy/curb_request.rb +49 -43
- data/lib/oauth/request_proxy/em_http_request.rb +59 -49
- data/lib/oauth/request_proxy/jabber_request.rb +12 -9
- data/lib/oauth/request_proxy/mock_request.rb +5 -3
- data/lib/oauth/request_proxy/net_http.rb +61 -54
- data/lib/oauth/request_proxy/rack_request.rb +35 -31
- data/lib/oauth/request_proxy/rest_client_request.rb +54 -50
- data/lib/oauth/request_proxy/typhoeus_request.rb +51 -45
- data/lib/oauth/request_proxy.rb +7 -4
- data/lib/oauth/server.rb +14 -12
- data/lib/oauth/signature/base.rb +78 -71
- data/lib/oauth/signature/hmac/sha1.rb +16 -10
- data/lib/oauth/signature/hmac/sha256.rb +16 -10
- data/lib/oauth/signature/plaintext.rb +18 -20
- data/lib/oauth/signature/rsa/sha1.rb +46 -38
- data/lib/oauth/signature.rb +8 -5
- data/lib/oauth/token.rb +7 -5
- data/lib/oauth/tokens/access_token.rb +5 -3
- data/lib/oauth/tokens/consumer_token.rb +4 -2
- data/lib/oauth/tokens/request_token.rb +12 -10
- data/lib/oauth/tokens/server_token.rb +2 -1
- data/lib/oauth/tokens/token.rb +2 -0
- data/lib/oauth/version.rb +5 -1
- data/lib/oauth.rb +17 -9
- metadata +105 -98
- data/README.rdoc +0 -88
- data/bin/oauth +0 -11
- data/lib/oauth/cli/authorize_command.rb +0 -71
- data/lib/oauth/cli/base_command.rb +0 -208
- data/lib/oauth/cli/help_command.rb +0 -22
- data/lib/oauth/cli/query_command.rb +0 -25
- data/lib/oauth/cli/sign_command.rb +0 -81
- data/lib/oauth/cli/version_command.rb +0 -7
- data/lib/oauth/cli.rb +0 -56
data/lib/oauth/server.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "oauth/helper"
|
4
|
+
require "oauth/consumer"
|
3
5
|
|
4
6
|
module OAuth
|
5
7
|
# This is mainly used to create consumer credentials and can pretty much be ignored if you want to create your own
|
@@ -8,9 +10,9 @@ module OAuth
|
|
8
10
|
attr_accessor :base_url
|
9
11
|
|
10
12
|
@@server_paths = {
|
11
|
-
:
|
12
|
-
:
|
13
|
-
:
|
13
|
+
request_token_path: "/oauth/request_token",
|
14
|
+
authorize_path: "/oauth/authorize",
|
15
|
+
access_token_path: "/oauth/access_token"
|
14
16
|
}
|
15
17
|
|
16
18
|
# Create a new server instance
|
@@ -23,7 +25,7 @@ module OAuth
|
|
23
25
|
[generate_key(16), generate_key]
|
24
26
|
end
|
25
27
|
|
26
|
-
def generate_consumer_credentials(
|
28
|
+
def generate_consumer_credentials(_params = {})
|
27
29
|
Consumer.new(*generate_credentials)
|
28
30
|
end
|
29
31
|
|
@@ -31,12 +33,12 @@ module OAuth
|
|
31
33
|
def create_consumer
|
32
34
|
creds = generate_credentials
|
33
35
|
Consumer.new(creds[0], creds[1],
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
36
|
+
{
|
37
|
+
site: base_url,
|
38
|
+
request_token_path: request_token_path,
|
39
|
+
authorize_path: authorize_path,
|
40
|
+
access_token_path: access_token_path
|
41
|
+
})
|
40
42
|
end
|
41
43
|
|
42
44
|
def request_token_path
|
data/lib/oauth/signature/base.rb
CHANGED
@@ -1,96 +1,103 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require
|
4
|
-
require
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "oauth/signature"
|
4
|
+
require "oauth/helper"
|
5
|
+
require "oauth/request_proxy/base"
|
6
|
+
require "base64"
|
7
|
+
|
8
|
+
module OAuth
|
9
|
+
module Signature
|
10
|
+
class Base
|
11
|
+
include OAuth::Helper
|
12
|
+
|
13
|
+
attr_accessor :options
|
14
|
+
attr_reader :token_secret, :consumer_secret, :request
|
15
|
+
|
16
|
+
def self.implements(signature_method = nil)
|
17
|
+
return @implements if signature_method.nil?
|
18
|
+
|
19
|
+
@implements = signature_method
|
20
|
+
OAuth::Signature.available_methods[@implements] = self
|
21
|
+
end
|
22
|
+
|
23
|
+
def initialize(request, options = {}, &block)
|
24
|
+
raise TypeError unless request.is_a?(OAuth::RequestProxy::Base)
|
18
25
|
|
19
|
-
|
20
|
-
|
21
|
-
@request = request
|
22
|
-
@options = options
|
26
|
+
@request = request
|
27
|
+
@options = options
|
23
28
|
|
24
|
-
|
29
|
+
## consumer secret was determined beforehand
|
25
30
|
|
26
|
-
|
31
|
+
@consumer_secret = options[:consumer].secret if options[:consumer]
|
27
32
|
|
28
|
-
|
29
|
-
|
33
|
+
# presence of :consumer_secret option will override any Consumer that's provided
|
34
|
+
@consumer_secret = options[:consumer_secret] if options[:consumer_secret]
|
30
35
|
|
31
|
-
|
36
|
+
## token secret was determined beforehand
|
32
37
|
|
33
|
-
|
38
|
+
@token_secret = options[:token].secret if options[:token]
|
34
39
|
|
35
|
-
|
36
|
-
|
40
|
+
# presence of :token_secret option will override any Token that's provided
|
41
|
+
@token_secret = options[:token_secret] if options[:token_secret]
|
37
42
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
43
|
+
# override secrets based on the values returned from the block (if any)
|
44
|
+
if block
|
45
|
+
# consumer secret and token secret need to be looked up based on pieces of the request
|
46
|
+
secrets = yield block.arity == 1 ? request : [token, consumer_key, nonce, request.timestamp]
|
47
|
+
if secrets.is_a?(Array) && secrets.size == 2
|
48
|
+
@token_secret = secrets[0]
|
49
|
+
@consumer_secret = secrets[1]
|
50
|
+
end
|
45
51
|
end
|
46
52
|
end
|
47
|
-
end
|
48
53
|
|
49
|
-
|
50
|
-
|
51
|
-
|
54
|
+
def signature
|
55
|
+
Base64.encode64(digest).chomp.delete("\n")
|
56
|
+
end
|
52
57
|
|
53
|
-
|
54
|
-
|
55
|
-
|
58
|
+
def ==(other)
|
59
|
+
check = signature.bytesize ^ other.bytesize
|
60
|
+
signature.bytes.zip(other.bytes) { |x, y| check |= x ^ y.to_i }
|
61
|
+
check.zero?
|
62
|
+
end
|
56
63
|
|
57
|
-
|
58
|
-
|
59
|
-
|
64
|
+
def verify
|
65
|
+
self == request.signature
|
66
|
+
end
|
60
67
|
|
61
|
-
|
62
|
-
|
63
|
-
|
68
|
+
def signature_base_string
|
69
|
+
request.signature_base_string
|
70
|
+
end
|
64
71
|
|
65
|
-
|
66
|
-
|
67
|
-
|
72
|
+
def body_hash
|
73
|
+
raise_instantiation_error
|
74
|
+
end
|
68
75
|
|
69
|
-
|
76
|
+
private
|
70
77
|
|
71
|
-
|
72
|
-
|
73
|
-
|
78
|
+
def token
|
79
|
+
request.token
|
80
|
+
end
|
74
81
|
|
75
|
-
|
76
|
-
|
77
|
-
|
82
|
+
def consumer_key
|
83
|
+
request.consumer_key
|
84
|
+
end
|
78
85
|
|
79
|
-
|
80
|
-
|
81
|
-
|
86
|
+
def nonce
|
87
|
+
request.nonce
|
88
|
+
end
|
82
89
|
|
83
|
-
|
84
|
-
|
85
|
-
|
90
|
+
def secret
|
91
|
+
"#{escape(consumer_secret)}&#{escape(token_secret)}"
|
92
|
+
end
|
86
93
|
|
87
|
-
|
88
|
-
|
89
|
-
|
94
|
+
def digest
|
95
|
+
raise_instantiation_error
|
96
|
+
end
|
90
97
|
|
91
|
-
|
92
|
-
|
98
|
+
def raise_instantiation_error
|
99
|
+
raise NotImplementedError, "Cannot instantiate #{self.class.name} class directly."
|
100
|
+
end
|
93
101
|
end
|
94
|
-
|
95
102
|
end
|
96
103
|
end
|
@@ -1,17 +1,23 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
class SHA1 < OAuth::Signature::Base
|
5
|
-
implements 'hmac-sha1'
|
3
|
+
require "oauth/signature/base"
|
6
4
|
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
module OAuth
|
6
|
+
module Signature
|
7
|
+
module HMAC
|
8
|
+
class SHA1 < OAuth::Signature::Base
|
9
|
+
implements "hmac-sha1"
|
10
|
+
|
11
|
+
def body_hash
|
12
|
+
Base64.encode64(OpenSSL::Digest.digest("SHA1", request.body || "")).chomp.delete("\n")
|
13
|
+
end
|
10
14
|
|
11
|
-
|
15
|
+
private
|
12
16
|
|
13
|
-
|
14
|
-
|
17
|
+
def digest
|
18
|
+
OpenSSL::HMAC.digest(OpenSSL::Digest.new("sha1"), secret, signature_base_string)
|
19
|
+
end
|
20
|
+
end
|
15
21
|
end
|
16
22
|
end
|
17
23
|
end
|
@@ -1,17 +1,23 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
class SHA256 < OAuth::Signature::Base
|
5
|
-
implements 'hmac-sha256'
|
3
|
+
require "oauth/signature/base"
|
6
4
|
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
module OAuth
|
6
|
+
module Signature
|
7
|
+
module HMAC
|
8
|
+
class SHA256 < OAuth::Signature::Base
|
9
|
+
implements "hmac-sha256"
|
10
|
+
|
11
|
+
def body_hash
|
12
|
+
Base64.encode64(OpenSSL::Digest.digest("SHA256", request.body || "")).chomp.delete("\n")
|
13
|
+
end
|
10
14
|
|
11
|
-
|
15
|
+
private
|
12
16
|
|
13
|
-
|
14
|
-
|
17
|
+
def digest
|
18
|
+
OpenSSL::HMAC.digest(OpenSSL::Digest.new("sha256"), secret, signature_base_string)
|
19
|
+
end
|
20
|
+
end
|
15
21
|
end
|
16
22
|
end
|
17
23
|
end
|
@@ -1,29 +1,27 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
class PLAINTEXT < Base
|
5
|
-
implements 'plaintext'
|
3
|
+
require "oauth/signature/base"
|
6
4
|
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
module OAuth
|
6
|
+
module Signature
|
7
|
+
class PLAINTEXT < Base
|
8
|
+
implements "plaintext"
|
10
9
|
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
def signature
|
11
|
+
signature_base_string
|
12
|
+
end
|
14
13
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
def body_hash
|
20
|
-
nil
|
21
|
-
end
|
14
|
+
def ==(other)
|
15
|
+
signature.to_s == other.to_s
|
16
|
+
end
|
22
17
|
|
23
|
-
|
18
|
+
def signature_base_string
|
19
|
+
secret
|
20
|
+
end
|
24
21
|
|
25
|
-
|
26
|
-
|
22
|
+
def body_hash
|
23
|
+
nil
|
24
|
+
end
|
27
25
|
end
|
28
26
|
end
|
29
27
|
end
|
@@ -1,50 +1,58 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
class SHA1 < OAuth::Signature::Base
|
5
|
-
implements 'rsa-sha1'
|
3
|
+
require "oauth/signature/base"
|
6
4
|
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
module OAuth
|
6
|
+
module Signature
|
7
|
+
module RSA
|
8
|
+
class SHA1 < OAuth::Signature::Base
|
9
|
+
implements "rsa-sha1"
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
consumer_secret.public_key
|
16
|
-
else
|
17
|
-
consumer_secret
|
18
|
-
end
|
19
|
-
end
|
11
|
+
def ==(other)
|
12
|
+
public_key.verify(OpenSSL::Digest.new("SHA1"),
|
13
|
+
Base64.decode64(other.is_a?(Array) ? other.first : other), signature_base_string)
|
14
|
+
end
|
20
15
|
|
21
|
-
|
22
|
-
|
23
|
-
|
16
|
+
def public_key
|
17
|
+
case consumer_secret
|
18
|
+
when String
|
19
|
+
decode_public_key
|
20
|
+
when OpenSSL::X509::Certificate
|
21
|
+
consumer_secret.public_key
|
22
|
+
else
|
23
|
+
consumer_secret
|
24
|
+
end
|
25
|
+
end
|
24
26
|
|
25
|
-
|
27
|
+
def body_hash
|
28
|
+
Base64.encode64(OpenSSL::Digest.digest("SHA1", request.body || "")).chomp.delete("\n")
|
29
|
+
end
|
26
30
|
|
27
|
-
|
28
|
-
case consumer_secret
|
29
|
-
when /-----BEGIN CERTIFICATE-----/
|
30
|
-
OpenSSL::X509::Certificate.new( consumer_secret).public_key
|
31
|
-
else
|
32
|
-
OpenSSL::PKey::RSA.new( consumer_secret)
|
33
|
-
end
|
34
|
-
end
|
31
|
+
private
|
35
32
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
consumer_secret
|
33
|
+
def decode_public_key
|
34
|
+
case consumer_secret
|
35
|
+
when /-----BEGIN CERTIFICATE-----/
|
36
|
+
OpenSSL::X509::Certificate.new(consumer_secret).public_key
|
37
|
+
else
|
38
|
+
OpenSSL::PKey::RSA.new(consumer_secret)
|
39
|
+
end
|
44
40
|
end
|
45
|
-
)
|
46
41
|
|
47
|
-
|
42
|
+
def digest
|
43
|
+
private_key = OpenSSL::PKey::RSA.new(
|
44
|
+
if options[:private_key_file]
|
45
|
+
File.read(options[:private_key_file])
|
46
|
+
elsif options[:private_key]
|
47
|
+
options[:private_key]
|
48
|
+
else
|
49
|
+
consumer_secret
|
50
|
+
end
|
51
|
+
)
|
52
|
+
|
53
|
+
private_key.sign(OpenSSL::Digest.new("SHA1"), signature_base_string)
|
54
|
+
end
|
55
|
+
end
|
48
56
|
end
|
49
57
|
end
|
50
58
|
end
|
data/lib/oauth/signature.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module OAuth
|
2
4
|
module Signature
|
3
5
|
# Returns a list of available signature methods
|
@@ -15,31 +17,32 @@ module OAuth
|
|
15
17
|
((c = request.options[:consumer]) && c.options[:signature_method]) ||
|
16
18
|
"").downcase]
|
17
19
|
raise UnknownSignatureMethod, request.signature_method unless klass
|
20
|
+
|
18
21
|
klass.new(request, options, &block)
|
19
22
|
end
|
20
23
|
|
21
24
|
# Sign a +request+
|
22
25
|
def self.sign(request, options = {}, &block)
|
23
|
-
|
26
|
+
build(request, options, &block).signature
|
24
27
|
end
|
25
28
|
|
26
29
|
# Verify the signature of +request+
|
27
30
|
def self.verify(request, options = {}, &block)
|
28
|
-
|
31
|
+
build(request, options, &block).verify
|
29
32
|
end
|
30
33
|
|
31
34
|
# Create the signature base string for +request+. This string is the normalized parameter information.
|
32
35
|
#
|
33
36
|
# See Also: {OAuth core spec version 1.0, section 9.1.1}[http://oauth.net/core/1.0#rfc.section.9.1.1]
|
34
37
|
def self.signature_base_string(request, options = {}, &block)
|
35
|
-
|
38
|
+
build(request, options, &block).signature_base_string
|
36
39
|
end
|
37
40
|
|
38
41
|
# Create the body hash for a request
|
39
42
|
def self.body_hash(request, options = {}, &block)
|
40
|
-
|
43
|
+
build(request, options, &block).body_hash
|
41
44
|
end
|
42
45
|
|
43
|
-
class UnknownSignatureMethod <
|
46
|
+
class UnknownSignatureMethod < RuntimeError; end
|
44
47
|
end
|
45
48
|
end
|
data/lib/oauth/token.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# this exists for backwards-compatibility
|
2
4
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
5
|
+
require "oauth/tokens/token"
|
6
|
+
require "oauth/tokens/server_token"
|
7
|
+
require "oauth/tokens/consumer_token"
|
8
|
+
require "oauth/tokens/request_token"
|
9
|
+
require "oauth/tokens/access_token"
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module OAuth
|
2
4
|
# The Access Token is used for the actual "real" web service calls that you perform against the server
|
3
5
|
class AccessToken < ConsumerToken
|
@@ -43,7 +45,7 @@ module OAuth
|
|
43
45
|
# @response = @token.post('/people', nil, {'Accept' => 'application/xml' })
|
44
46
|
# @response = @token.post('/people', @person.to_xml, { 'Accept'=>'application/xml', 'Content-Type' => 'application/xml' })
|
45
47
|
#
|
46
|
-
def post(path, body =
|
48
|
+
def post(path, body = "", headers = {})
|
47
49
|
request(:post, path, body, headers)
|
48
50
|
end
|
49
51
|
|
@@ -55,7 +57,7 @@ module OAuth
|
|
55
57
|
# @response = @token.put('/people/123', nil, { 'Accept' => 'application/xml' })
|
56
58
|
# @response = @token.put('/people/123', @person.to_xml, { 'Accept' => 'application/xml', 'Content-Type' => 'application/xml' })
|
57
59
|
#
|
58
|
-
def put(path, body =
|
60
|
+
def put(path, body = "", headers = {})
|
59
61
|
request(:put, path, body, headers)
|
60
62
|
end
|
61
63
|
|
@@ -67,7 +69,7 @@ module OAuth
|
|
67
69
|
# @response = @token.patch('/people/123', nil, { 'Accept' => 'application/xml' })
|
68
70
|
# @response = @token.patch('/people/123', @person.to_xml, { 'Accept' => 'application/xml', 'Content-Type' => 'application/xml' })
|
69
71
|
#
|
70
|
-
def patch(path, body =
|
72
|
+
def patch(path, body = "", headers = {})
|
71
73
|
request(:patch, path, body, headers)
|
72
74
|
end
|
73
75
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module OAuth
|
2
4
|
# Superclass for tokens used by OAuth Clients
|
3
5
|
class ConsumerToken < Token
|
@@ -5,12 +7,12 @@ module OAuth
|
|
5
7
|
attr_reader :response
|
6
8
|
|
7
9
|
def self.from_hash(consumer, hash)
|
8
|
-
token =
|
10
|
+
token = new(consumer, hash[:oauth_token], hash[:oauth_token_secret])
|
9
11
|
token.params = hash
|
10
12
|
token
|
11
13
|
end
|
12
14
|
|
13
|
-
def initialize(consumer, token="", secret="")
|
15
|
+
def initialize(consumer, token = "", secret = "")
|
14
16
|
super(token, secret)
|
15
17
|
@consumer = consumer
|
16
18
|
@params = {}
|
@@ -1,20 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module OAuth
|
2
4
|
# The RequestToken is used for the initial Request.
|
3
5
|
# This is normally created by the Consumer object.
|
4
6
|
class RequestToken < ConsumerToken
|
5
|
-
|
6
7
|
# Generate an authorization URL for user authorization
|
7
8
|
def authorize_url(params = nil)
|
8
|
-
return nil if
|
9
|
+
return nil if token.nil?
|
9
10
|
|
10
|
-
params = (params || {}).merge(:
|
11
|
+
params = (params || {}).merge(oauth_token: token)
|
11
12
|
build_url(consumer.authorize_url, params)
|
12
13
|
end
|
13
14
|
|
14
15
|
def authenticate_url(params = nil)
|
15
|
-
return nil if
|
16
|
+
return nil if token.nil?
|
16
17
|
|
17
|
-
params = (params || {}).merge(:
|
18
|
+
params = (params || {}).merge(oauth_token: token)
|
18
19
|
build_url(consumer.authenticate_url, params)
|
19
20
|
end
|
20
21
|
|
@@ -24,20 +25,21 @@ module OAuth
|
|
24
25
|
|
25
26
|
# exchange for AccessToken on server
|
26
27
|
def get_access_token(options = {}, *arguments)
|
27
|
-
response = consumer.token_request(consumer.http_method,
|
28
|
+
response = consumer.token_request(consumer.http_method,
|
29
|
+
(consumer.access_token_url? ? consumer.access_token_url : consumer.access_token_path), self, options, *arguments)
|
28
30
|
OAuth::AccessToken.from_hash(consumer, response)
|
29
31
|
end
|
30
32
|
|
31
|
-
|
33
|
+
protected
|
32
34
|
|
33
35
|
# construct an authorization or authentication url
|
34
36
|
def build_url(base_url, params)
|
35
37
|
uri = URI.parse(base_url.to_s)
|
36
38
|
queries = {}
|
37
|
-
queries =
|
38
|
-
# TODO doesn't handle array values correctly
|
39
|
+
queries = URI.decode_www_form(uri.query).to_h if uri.query
|
40
|
+
# TODO: doesn't handle array values correctly
|
39
41
|
queries.merge!(params) if params
|
40
|
-
uri.query = URI.encode_www_form(queries)
|
42
|
+
uri.query = URI.encode_www_form(queries) unless queries.empty?
|
41
43
|
uri.to_s
|
42
44
|
end
|
43
45
|
end
|
data/lib/oauth/tokens/token.rb
CHANGED
data/lib/oauth/version.rb
CHANGED
data/lib/oauth.rb
CHANGED
@@ -1,12 +1,20 @@
|
|
1
|
-
|
2
|
-
$LOAD_PATH << root unless $LOAD_PATH.include?(root)
|
1
|
+
# frozen_string_literal: true
|
3
2
|
|
4
|
-
|
3
|
+
# third party gems
|
4
|
+
require "snaky_hash"
|
5
|
+
require "version_gem"
|
5
6
|
|
6
|
-
require
|
7
|
+
require "oauth/version"
|
7
8
|
|
8
|
-
require
|
9
|
-
|
10
|
-
require
|
11
|
-
require
|
12
|
-
require
|
9
|
+
require "oauth/oauth"
|
10
|
+
|
11
|
+
require "oauth/client/helper"
|
12
|
+
require "oauth/signature/plaintext"
|
13
|
+
require "oauth/signature/hmac/sha1"
|
14
|
+
require "oauth/signature/hmac/sha256"
|
15
|
+
require "oauth/signature/rsa/sha1"
|
16
|
+
require "oauth/request_proxy/mock_request"
|
17
|
+
|
18
|
+
OAuth::Version.class_eval do
|
19
|
+
extend VersionGem::Basic
|
20
|
+
end
|