mirror of
https://github.com/heartcombo/devise.git
synced 2022-11-09 12:18:31 -05:00
Revert "Only triggers http in failure app if devise.authentication_method is :http."
It has not fixed the problem it was supposed to fix.
This reverts commit 9d1a52978c
.
This commit is contained in:
parent
b2fe7e49fd
commit
fd934f1434
3 changed files with 6 additions and 15 deletions
|
@ -63,7 +63,7 @@ module Devise
|
|||
end
|
||||
|
||||
def http_auth?
|
||||
env["devise.authentication_method"] == :http && request.authorization
|
||||
request.authorization
|
||||
end
|
||||
|
||||
def http_auth_body
|
||||
|
|
|
@ -16,14 +16,13 @@ module Devise
|
|||
|
||||
# Check if this is strategy is valid for http authentication.
|
||||
def valid_for_http_auth?
|
||||
http_authenticatable? && request.authorization &&
|
||||
with_authentication_hash(http_auth_hash) && (env["devise.authentication_method"] = :http)
|
||||
http_authenticatable? && request.authorization && with_authentication_hash(http_auth_hash)
|
||||
end
|
||||
|
||||
# Check if this is strategy is valid for params authentication.
|
||||
def valid_for_params_auth?
|
||||
params_authenticatable? && valid_request? && valid_params? &&
|
||||
with_authentication_hash(params_auth_hash) && (env["devise.authentication_method"] = :params)
|
||||
params_authenticatable? && valid_request? &&
|
||||
valid_params? && with_authentication_hash(params_auth_hash)
|
||||
end
|
||||
|
||||
# Check if the model accepts this strategy as http authenticatable.
|
||||
|
|
|
@ -22,11 +22,8 @@ class FailureTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def call_failure_with_http(env_params={})
|
||||
env = {
|
||||
"HTTP_AUTHORIZATION" => "Basic #{ActiveSupport::Base64.encode64("foo:bar")}",
|
||||
"devise.authentication_method" => :http
|
||||
}
|
||||
call_failure(env.merge!(env_params))
|
||||
env = { "HTTP_AUTHORIZATION" => "Basic #{ActiveSupport::Base64.encode64("foo:bar")}" }
|
||||
call_failure(env_params.merge!(env))
|
||||
end
|
||||
|
||||
context 'When redirecting' do
|
||||
|
@ -72,11 +69,6 @@ class FailureTest < ActiveSupport::TestCase
|
|||
assert_equal 401, @response.first
|
||||
end
|
||||
|
||||
test 'does trigger http authentication if devise.authentication_method is not :http' do
|
||||
call_failure_with_http("devise.authentication_method" => :params)
|
||||
assert_equal 302, @response.first
|
||||
end
|
||||
|
||||
test 'return WWW-authenticate headers' do
|
||||
call_failure_with_http
|
||||
assert_equal 'Basic realm="Application"', @response.second["WWW-Authenticate"]
|
||||
|
|
Loading…
Add table
Reference in a new issue