diff --git a/lib/devise/strategies/authenticatable.rb b/lib/devise/strategies/authenticatable.rb index b1062e3a..9108e727 100644 --- a/lib/devise/strategies/authenticatable.rb +++ b/lib/devise/strategies/authenticatable.rb @@ -105,7 +105,7 @@ module Devise # Helper to decode credentials from HTTP. def decode_credentials return [] unless request.authorization && request.authorization =~ /^Basic (.*)/m - ActiveSupport::Base64.decode64($1).split(/:/, 2) + Base64.decode64($1).split(/:/, 2) end # Sets the authentication hash and the password from params_auth_hash or http_auth_hash. diff --git a/test/integration/http_authenticatable_test.rb b/test/integration/http_authenticatable_test.rb index c42abb93..408483d2 100644 --- a/test/integration/http_authenticatable_test.rb +++ b/test/integration/http_authenticatable_test.rb @@ -4,7 +4,7 @@ class HttpAuthenticationTest < ActionController::IntegrationTest test 'handles unverified requests gets rid of caches but continues signed in' do swap UsersController, :allow_forgery_protection => true do create_user - post exhibit_user_url(1), {}, "HTTP_AUTHORIZATION" => "Basic #{ActiveSupport::Base64.encode64("user@test.com:123456")}" + post exhibit_user_url(1), {}, "HTTP_AUTHORIZATION" => "Basic #{Base64.encode64("user@test.com:123456")}" assert warden.authenticated?(:user) assert_equal "User is authenticated", response.body end @@ -74,7 +74,7 @@ class HttpAuthenticationTest < ActionController::IntegrationTest token = "token_containing_so_many_characters_that_the_base64_encoding_will_wrap" user = create_user user.update_attribute :authentication_token, token - get users_path(:format => :xml), {}, "HTTP_AUTHORIZATION" => "Basic #{ActiveSupport::Base64.encode64("#{token}:x")}" + get users_path(:format => :xml), {}, "HTTP_AUTHORIZATION" => "Basic #{Base64.encode64("#{token}:x")}" assert_response :success assert_match "user@test.com", response.body assert warden.authenticated?(:user) @@ -84,14 +84,14 @@ class HttpAuthenticationTest < ActionController::IntegrationTest def sign_in_as_new_user_with_http(username="user@test.com", password="123456") user = create_user - get users_path(:format => :xml), {}, "HTTP_AUTHORIZATION" => "Basic #{ActiveSupport::Base64.encode64("#{username}:#{password}")}" + get users_path(:format => :xml), {}, "HTTP_AUTHORIZATION" => "Basic #{Base64.encode64("#{username}:#{password}")}" user end # Sign in with oauth2 token. This is just to test that it isn't misinterpreted as basic authentication def add_oauth2_header user = create_user - get users_path(:format => :xml), {}, "HTTP_AUTHORIZATION" => "OAuth #{ActiveSupport::Base64.encode64("#{user.email}:123456")}" + get users_path(:format => :xml), {}, "HTTP_AUTHORIZATION" => "OAuth #{Base64.encode64("#{user.email}:123456")}" end end diff --git a/test/integration/token_authenticatable_test.rb b/test/integration/token_authenticatable_test.rb index a6e54f4c..f2ccc8ac 100644 --- a/test/integration/token_authenticatable_test.rb +++ b/test/integration/token_authenticatable_test.rb @@ -125,7 +125,7 @@ class TokenAuthenticationTest < ActionController::IntegrationTest options[:auth_token] ||= user.authentication_token if options[:http_auth] - header = "Basic #{ActiveSupport::Base64.encode64("#{VALID_AUTHENTICATION_TOKEN}:X")}" + header = "Basic #{Base64.encode64("#{VALID_AUTHENTICATION_TOKEN}:X")}" get users_path(:format => :xml), {}, "HTTP_AUTHORIZATION" => header else visit users_path(options[:auth_token_key].to_sym => options[:auth_token])