mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #21203 from denniss/issue-21199
Authorization scheme should be case insensitive. Fixes #21199
This commit is contained in:
commit
e69364bc2d
2 changed files with 9 additions and 1 deletions
|
@ -94,7 +94,7 @@ module ActionController
|
||||||
end
|
end
|
||||||
|
|
||||||
def has_basic_credentials?(request)
|
def has_basic_credentials?(request)
|
||||||
request.authorization.present? && (auth_scheme(request) == 'Basic')
|
request.authorization.present? && (auth_scheme(request).downcase == 'basic')
|
||||||
end
|
end
|
||||||
|
|
||||||
def user_name_and_password(request)
|
def user_name_and_password(request)
|
||||||
|
|
|
@ -100,6 +100,14 @@ class HttpBasicAuthenticationTest < ActionController::TestCase
|
||||||
assert_no_match(/\n/, result)
|
assert_no_match(/\n/, result)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "succesful authentication with uppercase authorization scheme" do
|
||||||
|
@request.env['HTTP_AUTHORIZATION'] = "BASIC #{::Base64.encode64("lifo:world")}"
|
||||||
|
get :index
|
||||||
|
|
||||||
|
assert_response :success
|
||||||
|
assert_equal 'Hello Secret', @response.body, 'Authentication failed when authorization scheme BASIC'
|
||||||
|
end
|
||||||
|
|
||||||
test "authentication request without credential" do
|
test "authentication request without credential" do
|
||||||
get :display
|
get :display
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue