Skip to content

Commit

Permalink
Authorization scheme should be case insensitive. Fixes #21199
Browse files Browse the repository at this point in the history
  • Loading branch information
denniss committed Aug 11, 2015
1 parent 17eb642 commit dec2f52
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Expand Up @@ -94,7 +94,7 @@ def authenticate(request, &login_procedure)
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)
Expand Down
8 changes: 8 additions & 0 deletions actionpack/test/controller/http_basic_authentication_test.rb
Expand Up @@ -100,6 +100,14 @@ def test_encode_credentials_has_no_newline
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

Expand Down

0 comments on commit dec2f52

Please sign in to comment.