[rubygems/rubygems] Add access control headers for all requests to allow RubyGems.org to render the response

https://github.com/rubygems/rubygems/commit/22b329eb60
This commit is contained in:
Jenny Shen 2023-02-21 12:48:37 -05:00 коммит произвёл Hiroshi SHIBATA
Родитель 353f9adccc
Коммит ef85b6de42
4 изменённых файлов: 9 добавлений и 13 удалений

Просмотреть файл

@ -44,7 +44,6 @@ class Gem::WebauthnListener
end
def access_control_headers
return "" unless add_access_control_headers?
<<~RESPONSE
Access-Control-Allow-Origin: #{host}
Access-Control-Allow-Methods: POST
@ -66,10 +65,6 @@ class Gem::WebauthnListener
raise NotImplementedError
end
def add_access_control_headers?
false
end
def body; end
end
end

Просмотреть файл

@ -7,8 +7,4 @@ class Gem::WebauthnListener::ResponseNoContent < Gem::WebauthnListener::Response
def status
"204 No Content"
end
def add_access_control_headers?
true
end
end

Просмотреть файл

@ -8,10 +8,6 @@ class Gem::WebauthnListener::ResponseOk < Gem::WebauthnListener::Response
"200 OK"
end
def add_access_control_headers?
true
end
def body
"success"
end

Просмотреть файл

@ -57,6 +57,9 @@ class WebauthnListenerResponseTest < Gem::TestCase
expected_payload = <<~RESPONSE
HTTP/1.1 405 Method Not Allowed
Connection: close
Access-Control-Allow-Origin: rubygems.example
Access-Control-Allow-Methods: POST
Access-Control-Allow-Headers: Content-Type, Authorization, x-csrf-token
Allow: GET, OPTIONS
RESPONSE
@ -69,6 +72,9 @@ class WebauthnListenerResponseTest < Gem::TestCase
expected_payload = <<~RESPONSE
HTTP/1.1 404 Not Found
Connection: close
Access-Control-Allow-Origin: rubygems.example
Access-Control-Allow-Methods: POST
Access-Control-Allow-Headers: Content-Type, Authorization, x-csrf-token
RESPONSE
assert_equal expected_payload, payload
@ -80,6 +86,9 @@ class WebauthnListenerResponseTest < Gem::TestCase
expected_payload = <<~RESPONSE
HTTP/1.1 400 Bad Request
Connection: close
Access-Control-Allow-Origin: rubygems.example
Access-Control-Allow-Methods: POST
Access-Control-Allow-Headers: Content-Type, Authorization, x-csrf-token
Content-Type: text/plain
Content-Length: 22