Saturday, June 16, 2012

[Rails] apache authentication filter run twice

as a slight protection for the staging beta phase, I am using a filter
in my application_controller

before_filter :authenticate_apache
...
def authenticate_apache
if Rails.env == "production"
authenticate_or_request_with_http_basic do |user, pass|
["user1", "user2", "user"].include?(user) &&
pass=="staging_password"
end
end
end

..
going to the root page, the authentication is requested as it should
be..
once authenticated the user is on the home page => www.mydomain.com

then when the user request another page by clicking on the menu, the
authentication is requested another time
=> www.mydomain.com/pages/area1
then for any subsequent page request, the authentication is not
anymore requested

any idea why this is running twice ? thanks fro any clue

#FIRST REQUEST
Started GET "/" for 2.12.109.167 at 2012-06-16 13:27:01 +0100
Processing by PagesController#home as HTML
Filter chain halted as :authenticate_apache rendered or redirected
Completed 401 Unauthorized in 1ms (ActiveRecord: 0.0ms)

Started GET "/" for 2.12.109.167 at 2012-06-16 13:27:20 +0100
Processing by PagesController#home as HTML
Rendered pages/home/_slides.html.haml (1.6ms)
...
Completed 200 OK in 87ms (Views: 85.3ms | ActiveRecord: 0.6ms)

# SECOND REQUEST
Started GET "/pages/tourisme" for 2.12.109.167 at 2012-06-16 13:27:38
+0100
Processing by PagesController#tourism as HTML
Filter chain halted as :authenticate_apache rendered or redirected
Completed 401 Unauthorized in 1ms (ActiveRecord: 0.0ms)

Started GET "/pages/tourism" for 2.12.109.167 at 2012-06-16 13:27:44
+0100
Processing by PagesController#tourisme as HTML
Rendered layouts/shared/_player.js.erb (0.3ms)
...
Completed 200 OK in 15ms (Views: 13.9ms | ActiveRecord: 0.6ms)

# SUBSEQUENT REQUESTS
Started GET "/pages/real_estate" for 2.12.109.167 at 2012-06-16
13:27:57 +0100
Processing by PagesController#immobilier as HTML
Rendered layouts/shared/_player.js.erb (0.3ms)
...
Completed 200 OK in 15ms (Views: 13.0ms | ActiveRecord: 0.9ms)

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate