Skip to content

Commit 564e891

Browse files
author
Heather Harvey
authored
Merge branch '4-stable' into rzhade3/update-migration-docs
2 parents 6809310 + 0e29f8c commit 564e891

File tree

6 files changed

+19
-13
lines changed

6 files changed

+19
-13
lines changed

lib/octokit/client.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -238,11 +238,11 @@ def client_without_redirects(options = {})
238238
conn_opts[:ssl] = { :verify_mode => @ssl_verify_mode } if @ssl_verify_mode
239239
conn = Faraday.new(conn_opts) do |http|
240240
if basic_authenticated?
241-
http.basic_auth(@login, @password)
241+
http.request :basic_auth, @login, @password
242242
elsif token_authenticated?
243-
http.authorization 'token', @access_token
243+
http.request :authorization, 'token', @access_token
244244
elsif bearer_authenticated?
245-
http.authorization 'Bearer', @bearer_token
245+
http.request :authorization, 'Bearer', @bearer_token
246246
end
247247
http.headers['accept'] = options[:accept] if options.key?(:accept)
248248
end

lib/octokit/client/pub_sub_hubbub.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ def pub_sub_hubbub_request(options = {})
9191
conn = Faraday.new(:url => @api_endpoint) do |http|
9292
http.headers[:user_agent] = user_agent
9393
if basic_authenticated?
94-
http.basic_auth(@login, @password)
94+
http.request :basic_auth, @login, @password
9595
elsif token_authenticated?
96-
http.authorization 'token', @access_token
96+
http.request :authorization, 'token', @access_token
9797
end
9898
http.request :url_encoded
9999
http.use Octokit::Response::RaiseError

lib/octokit/connection.rb

+5-5
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,13 @@ def agent
107107
http.headers[:content_type] = "application/json"
108108
http.headers[:user_agent] = user_agent
109109
if basic_authenticated?
110-
http.basic_auth(@login, @password)
110+
http.request :basic_auth, @login, @password
111111
elsif token_authenticated?
112-
http.authorization 'token', @access_token
112+
http.request :authorization, 'token', @access_token
113113
elsif bearer_authenticated?
114-
http.authorization 'Bearer', @bearer_token
114+
http.request :authorization, 'Bearer', @bearer_token
115115
elsif application_authenticated?
116-
http.basic_auth(@client_id, @client_secret)
116+
http.request :basic_auth, @client_id, @client_secret
117117
end
118118
end
119119
end
@@ -176,7 +176,7 @@ def sawyer_options
176176
:links_parser => Sawyer::LinkParsers::Simple.new
177177
}
178178
conn_opts = @connection_options
179-
conn_opts[:builder] = @middleware if @middleware
179+
conn_opts[:builder] = @middleware.dup if @middleware
180180
conn_opts[:proxy] = @proxy if @proxy
181181
if conn_opts[:ssl].nil?
182182
conn_opts[:ssl] = { :verify_mode => @ssl_verify_mode } if @ssl_verify_mode

lib/octokit/middleware/follow_redirects.rb

+4-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,10 @@ def update_env(env, request_body, response)
8686
original_url = env[:url]
8787
env[:url] += safe_escape(response["location"])
8888
unless same_host?(original_url, env[:url])
89-
env[:request_headers].delete("Authorization")
89+
# HACK: Faraday’s Authorization middlewares don’t touch the request if the `Authorization` header is set.
90+
# This is a workaround to drop authentication info.
91+
# See https://github.com/octokit/octokit.rb/pull/1359#issuecomment-925609697
92+
env[:request_headers]["Authorization"] = "dummy"
9093
end
9194

9295
if convert_to_get?(response)

spec/helper.rb

+4-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99
require 'webmock/rspec'
1010
require 'base64'
1111
require 'jwt'
12-
require 'pry-byebug'
12+
# latest version of pry-byebug is not compatible with Ruby 3.2.0
13+
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('3.2.0')
14+
require 'pry-byebug'
15+
end
1316

1417
WebMock.disable_net_connect!()
1518

spec/octokit/client_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@
599599

600600
assert_requested original_request
601601
assert_requested(:get, "https://example.com/bar") { |req|
602-
req.headers["Authorization"].nil?
602+
req.headers["Authorization"] == "dummy"
603603
}
604604
end
605605

0 commit comments

Comments
 (0)