oauth 1.1.7 → 1.1.9
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
- checksums.yaml.gz.sig +0 -0
- data/CHANGELOG.md +170 -5
- data/LICENSE.md +1 -1
- data/README.md +84 -85
- data/lib/oauth/auth_sanitizer.rb +8 -24
- data/lib/oauth/client/action_controller_request.rb +3 -3
- data/lib/oauth/client/em_http.rb +2 -2
- data/lib/oauth/client/helper.rb +3 -3
- data/lib/oauth/client/net_http.rb +1 -1
- data/lib/oauth/consumer.rb +29 -7
- data/lib/oauth/request_proxy/mock_request.rb +1 -1
- data/lib/oauth/server.rb +3 -3
- data/lib/oauth/tokens/access_token.rb +19 -1
- data/lib/oauth/tokens/request_token.rb +1 -1
- data/lib/oauth/version.rb +4 -1
- data/lib/oauth.rb +1 -2
- data/sig/oauth.rbs +32 -0
- data.tar.gz.sig +0 -0
- metadata +117 -61
- metadata.gz.sig +0 -0
- data/CITATION.cff +0 -20
- data/CODE_OF_CONDUCT.md +0 -134
- data/CONTRIBUTING.md +0 -272
- data/FUNDING.md +0 -74
- data/RUBOCOP.md +0 -71
- data/SECURITY.md +0 -21
- data/certs/pboling.pem +0 -27
- data/sig/oauth/consumer.rbs +0 -9
- data/sig/oauth/signature/base.rbs +0 -12
- data/sig/oauth/tokens/token.rbs +0 -8
- data/sig/oauth/version.rbs +0 -6
data/lib/oauth/auth_sanitizer.rb
CHANGED
|
@@ -1,31 +1,15 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require "anonymous_loader"
|
|
4
|
+
|
|
3
5
|
module OAuth
|
|
4
6
|
AUTH_SANITIZER = begin
|
|
5
|
-
auth_sanitizer_requirement = Gem::Requirement.new("~> 0.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
auth_sanitizer_loader_path = File.join(
|
|
14
|
-
auth_sanitizer_spec.full_gem_path,
|
|
15
|
-
"lib/auth_sanitizer/loader.rb",
|
|
16
|
-
)
|
|
17
|
-
unless File.file?(auth_sanitizer_loader_path)
|
|
18
|
-
# :nocov:
|
|
19
|
-
raise LoadError, "oauth requires auth-sanitizer #{auth_sanitizer_requirement}; " \
|
|
20
|
-
"loader not found at #{auth_sanitizer_loader_path}"
|
|
21
|
-
# :nocov:
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
auth_sanitizer_loader_namespace = Module.new
|
|
25
|
-
auth_sanitizer_loader_namespace.module_eval(
|
|
26
|
-
File.read(auth_sanitizer_loader_path),
|
|
27
|
-
auth_sanitizer_loader_path,
|
|
28
|
-
1,
|
|
7
|
+
auth_sanitizer_requirement = Gem::Requirement.new("~> 0.2", ">= 0.2.2")
|
|
8
|
+
auth_sanitizer_loader_namespace = AnonymousLoader.load_path(
|
|
9
|
+
gem_name: "auth-sanitizer",
|
|
10
|
+
require_path: "auth_sanitizer/loader.rb",
|
|
11
|
+
version_requirement: auth_sanitizer_requirement,
|
|
12
|
+
version_file: "auth/sanitizer/version.rb"
|
|
29
13
|
)
|
|
30
14
|
|
|
31
15
|
auth_sanitizer_loader_namespace
|
|
@@ -14,7 +14,7 @@ module ActionController
|
|
|
14
14
|
if defined? ActionDispatch
|
|
15
15
|
def process_with_new_base_test(request, response = nil)
|
|
16
16
|
request.apply_oauth! if request.respond_to?(:apply_oauth!)
|
|
17
|
-
super
|
|
17
|
+
super
|
|
18
18
|
end
|
|
19
19
|
else
|
|
20
20
|
def process_with_oauth(request, response = nil)
|
|
@@ -45,7 +45,7 @@ module ActionController
|
|
|
45
45
|
scheme: "header",
|
|
46
46
|
signature_method: nil,
|
|
47
47
|
nonce: nil,
|
|
48
|
-
timestamp: nil
|
|
48
|
+
timestamp: nil
|
|
49
49
|
}.merge(options)
|
|
50
50
|
end
|
|
51
51
|
|
|
@@ -54,7 +54,7 @@ module ActionController
|
|
|
54
54
|
|
|
55
55
|
@oauth_helper = OAuth::Client::Helper.new(
|
|
56
56
|
self,
|
|
57
|
-
@oauth_options.merge(request_uri: (respond_to?(:fullpath) ? fullpath : request_uri))
|
|
57
|
+
@oauth_options.merge(request_uri: (respond_to?(:fullpath) ? fullpath : request_uri))
|
|
58
58
|
)
|
|
59
59
|
@oauth_helper.amend_user_agent_header(env)
|
|
60
60
|
|
data/lib/oauth/client/em_http.rb
CHANGED
|
@@ -34,7 +34,7 @@ if OAuth::Optional.em_http_available?
|
|
|
34
34
|
scheme: "header",
|
|
35
35
|
signature_method: nil,
|
|
36
36
|
nonce: nil,
|
|
37
|
-
timestamp: nil
|
|
37
|
+
timestamp: nil
|
|
38
38
|
}.merge(options)
|
|
39
39
|
|
|
40
40
|
@oauth_helper = OAuth::Client::Helper.new(self, options)
|
|
@@ -62,7 +62,7 @@ if OAuth::Optional.em_http_available?
|
|
|
62
62
|
scheme: "header",
|
|
63
63
|
signature_method: nil,
|
|
64
64
|
nonce: nil,
|
|
65
|
-
timestamp: nil
|
|
65
|
+
timestamp: nil
|
|
66
66
|
}.merge(options)
|
|
67
67
|
|
|
68
68
|
OAuth::Client::Helper.new(self, options).signature_base_string
|
data/lib/oauth/client/helper.rb
CHANGED
|
@@ -38,7 +38,7 @@ module OAuth
|
|
|
38
38
|
"oauth_nonce" => nonce,
|
|
39
39
|
"oauth_verifier" => options[:oauth_verifier],
|
|
40
40
|
"oauth_version" => options[:oauth_version] || "1.0",
|
|
41
|
-
"oauth_session_handle" => options[:oauth_session_handle]
|
|
41
|
+
"oauth_session_handle" => options[:oauth_session_handle]
|
|
42
42
|
}
|
|
43
43
|
allowed_empty_params = options[:allow_empty_params]
|
|
44
44
|
if allowed_empty_params != true && !allowed_empty_params.is_a?(Array)
|
|
@@ -53,7 +53,7 @@ module OAuth
|
|
|
53
53
|
uri: options[:request_uri],
|
|
54
54
|
consumer: options[:consumer],
|
|
55
55
|
token: options[:token],
|
|
56
|
-
unsigned_parameters: options[:unsigned_parameters]
|
|
56
|
+
unsigned_parameters: options[:unsigned_parameters]
|
|
57
57
|
}.merge(extra_options))
|
|
58
58
|
end
|
|
59
59
|
|
|
@@ -62,7 +62,7 @@ module OAuth
|
|
|
62
62
|
uri: options[:request_uri],
|
|
63
63
|
consumer: options[:consumer],
|
|
64
64
|
token: options[:token],
|
|
65
|
-
parameters: oauth_parameters
|
|
65
|
+
parameters: oauth_parameters
|
|
66
66
|
}.merge(extra_options))
|
|
67
67
|
end
|
|
68
68
|
|
data/lib/oauth/consumer.rb
CHANGED
|
@@ -95,7 +95,15 @@ module OAuth
|
|
|
95
95
|
# attacker-controlled endpoint, so they require explicit opt-in.
|
|
96
96
|
token_request_max_redirects: 10,
|
|
97
97
|
token_request_cross_origin_redirects: false,
|
|
98
|
-
|
|
98
|
+
|
|
99
|
+
# AccessToken service calls (AccessToken#get/#post/...) may target an
|
|
100
|
+
# absolute URI. By default such a call is permitted only when it shares
|
|
101
|
+
# the configured site's origin (scheme, host, and port); a cross-origin
|
|
102
|
+
# absolute URI raises OAuth::Error, since it would send the signed OAuth
|
|
103
|
+
# Authorization header to a different host (credential leak / SSRF). Set
|
|
104
|
+
# this to true to allow calling service endpoints on other origins.
|
|
105
|
+
access_token_cross_origin_requests: false
|
|
106
|
+
}
|
|
99
107
|
)
|
|
100
108
|
|
|
101
109
|
attr_accessor :options, :key, :secret
|
|
@@ -142,6 +150,7 @@ module OAuth
|
|
|
142
150
|
def debug_output
|
|
143
151
|
@debug_output ||= case @options[:debug_output]
|
|
144
152
|
when nil, false
|
|
153
|
+
nil
|
|
145
154
|
when true
|
|
146
155
|
$stdout
|
|
147
156
|
else
|
|
@@ -241,7 +250,7 @@ module OAuth
|
|
|
241
250
|
(request_token_url? ? request_token_url : request_token_path),
|
|
242
251
|
nil,
|
|
243
252
|
request_options,
|
|
244
|
-
*arguments
|
|
253
|
+
*arguments
|
|
245
254
|
)
|
|
246
255
|
end
|
|
247
256
|
OAuth::RequestToken.from_hash(self, response)
|
|
@@ -372,12 +381,25 @@ module OAuth
|
|
|
372
381
|
end
|
|
373
382
|
|
|
374
383
|
def token_request_cross_origin?(current_uri, redirected_uri)
|
|
375
|
-
current_uri
|
|
376
|
-
|
|
377
|
-
|
|
384
|
+
cross_origin?(current_uri, redirected_uri)
|
|
385
|
+
end
|
|
386
|
+
|
|
387
|
+
# Whether the consumer permits AccessToken service calls to an absolute URI
|
|
388
|
+
# whose origin differs from the configured site. Off by default.
|
|
389
|
+
def access_token_cross_origin_requests?
|
|
390
|
+
!!options[:access_token_cross_origin_requests]
|
|
391
|
+
end
|
|
392
|
+
|
|
393
|
+
# True when the two URIs differ in scheme, host, or effective port. Used
|
|
394
|
+
# both for token-request redirect safety and for AccessToken service-call
|
|
395
|
+
# origin checks.
|
|
396
|
+
def cross_origin?(uri_a, uri_b)
|
|
397
|
+
uri_a.scheme.to_s.downcase != uri_b.scheme.to_s.downcase ||
|
|
398
|
+
uri_a.host.to_s.downcase != uri_b.host.to_s.downcase ||
|
|
399
|
+
effective_port(uri_a) != effective_port(uri_b)
|
|
378
400
|
end
|
|
379
401
|
|
|
380
|
-
def
|
|
402
|
+
def effective_port(uri)
|
|
381
403
|
return uri.port if uri.port
|
|
382
404
|
return 443 if uri.scheme == "https"
|
|
383
405
|
|
|
@@ -490,7 +512,7 @@ module OAuth
|
|
|
490
512
|
proxy_uri.host,
|
|
491
513
|
proxy_uri.port,
|
|
492
514
|
proxy_uri.user,
|
|
493
|
-
proxy_uri.password
|
|
515
|
+
proxy_uri.password
|
|
494
516
|
)
|
|
495
517
|
end
|
|
496
518
|
|
data/lib/oauth/server.rb
CHANGED
|
@@ -13,7 +13,7 @@ module OAuth
|
|
|
13
13
|
@@server_paths = {
|
|
14
14
|
request_token_path: "/oauth/request_token",
|
|
15
15
|
authorize_path: "/oauth/authorize",
|
|
16
|
-
access_token_path: "/oauth/access_token"
|
|
16
|
+
access_token_path: "/oauth/access_token"
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
# Create a new server instance
|
|
@@ -40,8 +40,8 @@ module OAuth
|
|
|
40
40
|
site: base_url,
|
|
41
41
|
request_token_path: request_token_path,
|
|
42
42
|
authorize_path: authorize_path,
|
|
43
|
-
access_token_path: access_token_path
|
|
44
|
-
}
|
|
43
|
+
access_token_path: access_token_path
|
|
44
|
+
}
|
|
45
45
|
)
|
|
46
46
|
end
|
|
47
47
|
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require "oauth/errors"
|
|
4
|
+
|
|
3
5
|
module OAuth
|
|
4
6
|
# The Access Token is used for the actual "real" web service calls that you perform against the server
|
|
5
7
|
class AccessToken < ConsumerToken
|
|
@@ -9,9 +11,17 @@ module OAuth
|
|
|
9
11
|
request_uri = URI.parse(path)
|
|
10
12
|
site_uri = consumer.uri
|
|
11
13
|
is_service_uri_different = request_uri.absolute? && request_uri != site_uri
|
|
14
|
+
if is_service_uri_different && consumer.cross_origin?(site_uri, request_uri) &&
|
|
15
|
+
!consumer.access_token_cross_origin_requests?
|
|
16
|
+
raise OAuth::Error,
|
|
17
|
+
"AccessToken request to cross-origin URI #{authority(request_uri)} is not permitted " \
|
|
18
|
+
"(configured site origin is #{authority(site_uri)}). Sending the signed OAuth Authorization " \
|
|
19
|
+
"header to a different origin can leak it or enable SSRF. Set the consumer option " \
|
|
20
|
+
"access_token_cross_origin_requests: true to allow service calls to other origins."
|
|
21
|
+
end
|
|
12
22
|
begin
|
|
13
23
|
consumer.uri(request_uri) if is_service_uri_different
|
|
14
|
-
@response = super
|
|
24
|
+
@response = super
|
|
15
25
|
ensure
|
|
16
26
|
# NOTE: reset for wholesomeness? meaning that we admit only AccessToken service calls may use different URIs?
|
|
17
27
|
# so reset in case consumer is still used for other token-management tasks subsequently?
|
|
@@ -81,5 +91,13 @@ module OAuth
|
|
|
81
91
|
def delete(path, headers = {})
|
|
82
92
|
request(:delete, path, headers)
|
|
83
93
|
end
|
|
94
|
+
|
|
95
|
+
private
|
|
96
|
+
|
|
97
|
+
# scheme://host[:port] for an error message; URI::HTTP/HTTPS always
|
|
98
|
+
# resolve a port, so it renders whenever one is known.
|
|
99
|
+
def authority(uri)
|
|
100
|
+
"#{uri.scheme}://#{uri.host}#{":#{uri.port}" if uri.port}"
|
|
101
|
+
end
|
|
84
102
|
end
|
|
85
103
|
end
|
data/lib/oauth/version.rb
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module OAuth
|
|
4
|
+
# Version namespace for this gem.
|
|
4
5
|
module Version
|
|
5
|
-
|
|
6
|
+
# Current gem version.
|
|
7
|
+
VERSION = "1.1.9"
|
|
6
8
|
end
|
|
9
|
+
# Current gem version exposed at the traditional constant location.
|
|
7
10
|
VERSION = Version::VERSION # Traditional Constant Location
|
|
8
11
|
end
|
data/lib/oauth.rb
CHANGED
|
@@ -3,9 +3,7 @@
|
|
|
3
3
|
# third party gems
|
|
4
4
|
require "snaky_hash"
|
|
5
5
|
require "version_gem"
|
|
6
|
-
require_relative "oauth/version"
|
|
7
6
|
|
|
8
|
-
require "oauth/version"
|
|
9
7
|
require "oauth/auth_sanitizer"
|
|
10
8
|
|
|
11
9
|
require "oauth/oauth"
|
|
@@ -16,6 +14,7 @@ require "oauth/signature/hmac/sha1"
|
|
|
16
14
|
require "oauth/signature/hmac/sha256"
|
|
17
15
|
require "oauth/signature/rsa/sha1"
|
|
18
16
|
require "oauth/request_proxy/mock_request"
|
|
17
|
+
require_relative "oauth/version"
|
|
19
18
|
|
|
20
19
|
OAuth::Version.class_eval do
|
|
21
20
|
extend VersionGem::Basic
|
data/sig/oauth.rbs
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
module OAuth
|
|
2
|
+
class Consumer
|
|
3
|
+
include OAuth::AUTH_SANITIZER::FilteredAttributes
|
|
4
|
+
|
|
5
|
+
attr_accessor options: untyped
|
|
6
|
+
attr_accessor key: untyped
|
|
7
|
+
attr_accessor secret: untyped
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
module Signature
|
|
11
|
+
class Base
|
|
12
|
+
include OAuth::AUTH_SANITIZER::FilteredAttributes
|
|
13
|
+
|
|
14
|
+
attr_accessor options: untyped
|
|
15
|
+
attr_reader token_secret: untyped
|
|
16
|
+
attr_reader consumer_secret: untyped
|
|
17
|
+
attr_reader request: untyped
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
class Token
|
|
22
|
+
include OAuth::AUTH_SANITIZER::FilteredAttributes
|
|
23
|
+
|
|
24
|
+
attr_accessor token: untyped
|
|
25
|
+
attr_accessor secret: untyped
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
module Version
|
|
29
|
+
VERSION: String
|
|
30
|
+
end
|
|
31
|
+
VERSION: String
|
|
32
|
+
end
|
data.tar.gz.sig
CHANGED
|
Binary file
|