Hi,
I'm facing the same issue, and I thought it was because my
require_user in my application_controller.rb came from the basic HTML
only tutorial, and was this:
def require_user
unless current_user
store_location
flash[:notice] = "You must be logged in to access this page"
redirect_to new_user_session_url
return false
end
end
I would think this ignores the format type of the request and so all
authentication requests are dealt with by redirecting to the html page
at new_user_session_url. However, shouldn't XML requests get back a
401 code with WWW-Authenticate header? The client can then respond by
sending the Authorization header with a re-request. Something similar
to this (return false not needed in latest Rails):
accepts.xml do
headers["WWW-Authenticate"] = %(Basic realm="Web Password")
render :text => "Could't authenticate you", :status => 401
end
What I'm confused about, is the best practice for all this. This
thread is suggesting that authentication happens automatically, but
don't we still have to manually code up the different ways to request
authorization, using a require_user filter (or similar)? I found
nothing via grep to indicate that authlogic has code to do this for
us.
Many thanks,
Si