mirror of
https://github.com/internetee/registry.git
synced 2025-06-08 05:34:46 +02:00
Return Origin url instead of, as requested by ops
This commit is contained in:
parent
09e0a96b70
commit
966d668ac8
4 changed files with 10 additions and 10 deletions
|
@ -9,7 +9,7 @@ module Api
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_access_control_headers
|
def set_access_control_headers
|
||||||
response.headers['Access-Control-Allow-Origin'] = '*'
|
response.headers['Access-Control-Allow-Origin'] = request.headers['Origin']
|
||||||
response.headers['Access-Control-Allow-Methods'] = 'POST, GET, PUT, PATCH, DELETE, OPTIONS'
|
response.headers['Access-Control-Allow-Methods'] = 'POST, GET, PUT, PATCH, DELETE, OPTIONS'
|
||||||
response.headers['Access-Control-Allow-Headers'] = 'Origin, Content-Type, Accept, ' \
|
response.headers['Access-Control-Allow-Headers'] = 'Origin, Content-Type, Accept, ' \
|
||||||
'Authorization, Token, Auth-Token, '\
|
'Authorization, Token, Auth-Token, '\
|
||||||
|
|
|
@ -29,7 +29,7 @@ module Api
|
||||||
private
|
private
|
||||||
|
|
||||||
def set_cors_header
|
def set_cors_header
|
||||||
response.headers['Access-Control-Allow-Origin'] = '*'
|
response.headers['Access-Control-Allow-Origin'] = request.headers['Origin']
|
||||||
end
|
end
|
||||||
|
|
||||||
def eid_params
|
def eid_params
|
||||||
|
|
|
@ -19,7 +19,7 @@ module Api
|
||||||
private
|
private
|
||||||
|
|
||||||
def set_cors_header
|
def set_cors_header
|
||||||
response.headers['Access-Control-Allow-Origin'] = '*'
|
response.headers['Access-Control-Allow-Origin'] = request.headers['Origin']
|
||||||
end
|
end
|
||||||
|
|
||||||
def bearer_token
|
def bearer_token
|
||||||
|
|
|
@ -2,7 +2,7 @@ require 'test_helper'
|
||||||
|
|
||||||
class RegistrantApiCorsHeadersTest < ApplicationIntegrationTest
|
class RegistrantApiCorsHeadersTest < ApplicationIntegrationTest
|
||||||
def test_returns_200_response_code_for_options_request
|
def test_returns_200_response_code_for_options_request
|
||||||
options '/api/v1/registrant/auth/eid', {}
|
options '/api/v1/registrant/auth/eid', {}, { 'Origin' => 'https://example.com' }
|
||||||
|
|
||||||
assert_equal('200', response.code)
|
assert_equal('200', response.code)
|
||||||
end
|
end
|
||||||
|
@ -10,7 +10,7 @@ class RegistrantApiCorsHeadersTest < ApplicationIntegrationTest
|
||||||
def test_returns_expected_headers_for_options_requests
|
def test_returns_expected_headers_for_options_requests
|
||||||
options '/api/v1/registrant/auth/eid', {}, { 'Origin' => 'https://example.com' }
|
options '/api/v1/registrant/auth/eid', {}, { 'Origin' => 'https://example.com' }
|
||||||
|
|
||||||
assert_equal('*', response.headers['Access-Control-Allow-Origin'])
|
assert_equal('https://example.com', response.headers['Access-Control-Allow-Origin'])
|
||||||
assert_equal('POST, GET, PUT, PATCH, DELETE, OPTIONS',
|
assert_equal('POST, GET, PUT, PATCH, DELETE, OPTIONS',
|
||||||
response.headers['Access-Control-Allow-Methods'])
|
response.headers['Access-Control-Allow-Methods'])
|
||||||
assert_equal('Origin, Content-Type, Accept, Authorization, Token, Auth-Token, Email, ' \
|
assert_equal('Origin, Content-Type, Accept, Authorization, Token, Auth-Token, Email, ' \
|
||||||
|
@ -20,16 +20,16 @@ class RegistrantApiCorsHeadersTest < ApplicationIntegrationTest
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_returns_empty_body
|
def test_returns_empty_body
|
||||||
options '/api/v1/registrant/auth/eid', {}
|
options '/api/v1/registrant/auth/eid', { 'Origin' => 'https://example.com' }
|
||||||
|
|
||||||
assert_equal('', response.body)
|
assert_equal('', response.body)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_it_returns_cors_headers_for_other_requests
|
def test_it_returns_cors_headers_for_other_requests
|
||||||
post '/api/v1/registrant/auth/eid', {}
|
post '/api/v1/registrant/auth/eid', {}, { 'Origin' => 'https://example.com' }
|
||||||
assert_equal('*', response.headers['Access-Control-Allow-Origin'])
|
assert_equal('https://example.com', response.headers['Access-Control-Allow-Origin'])
|
||||||
|
|
||||||
get '/api/v1/registrant/contacts', {}
|
get '/api/v1/registrant/contacts', {}, { 'Origin' => 'https://example.com' }
|
||||||
assert_equal('*', response.headers['Access-Control-Allow-Origin'])
|
assert_equal('https://example.com', response.headers['Access-Control-Allow-Origin'])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue