1
0
Fork 0
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:
Sean Griffin 2015-08-11 17:25:00 -06:00
commit e69364bc2d
2 changed files with 9 additions and 1 deletions

View file

@ -94,7 +94,7 @@ module ActionController
end
def has_basic_credentials?(request)
request.authorization.present? && (auth_scheme(request) == 'Basic')
request.authorization.present? && (auth_scheme(request).downcase == 'basic')
end
def user_name_and_password(request)

View file

@ -100,6 +100,14 @@ class HttpBasicAuthenticationTest < ActionController::TestCase
assert_no_match(/\n/, result)
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
get :display