Rails 2.3 앱에는 기본 HTTP 인증에 의해 보호되는 관리자 섹션이 있습니다. 이는 수년간 우리의 생산 및 스테이징 환경에서 효과가있었습니다. 최근에는 장시간 실행되는 기능 분기를 데모하고 사용자 지정 "재 설계"환경을 사용하여 실행하도록 설정 한 다른 준비 서버를 구별하기위한 새로운 환경을 설정했습니다. 그래서 지금 내 Admin::BaseController
은 다음과 같습니다authenticate_or_request_with_http_basic은 항상 false를 반환합니다.
class Admin::BaseController < ApplicationController
before_filter :verify_access
def verify_access
logger.info "\n\n-- running verify_access filter on #{RAILS_ENV}\n"
if %w(production staging redesign).include?(RAILS_ENV)
logger.info "\n-- should send authentication\n"
authenticate_or_request_with_http_basic("Restricted Access") do |username, password|
logger.info "\nauthentication received: {username}::#{password}\n"
username == 'myusername'
password == 'mypassword'
end
end
end
end
, 새로운 서버는 항상 무단 응답하고 나는 내가 사용하지 않더라도 종료하고 브라우저를 다시하지 않더라도, 어떤 로그인 대화 상자를 제공하지 않습니다 개인 브라우저 세션, URL에 사용자 이름을 지정하더라도 (즉, http://[email protected]/admin
). 그냥 자동으로 루트로 리디렉션하고 쿼리 문자열에 ?unauthorized=true
을 추가합니다.하지만 내 응용 프로그램 코드에는 아무 것도 없습니다.
내가 로그 파일에서 볼 수 있기 때문에 나는 그것이 verify_access 필터를 때리고 알고 크롬의 네트워크 패널에서
Processing Admin::OrdersController#index (for xx.xx.xx.xx at 2014-05-09 05:56:59) [GET]
Parameters: {"action"=>"index", "controller"=>"admin/orders"}
-- running verify_access filter on redesign
-- should send authentication
Filter chain halted as [:verify_access] rendered_or_redirected.
Completed in 25ms (View: 21, DB: 1) | 401 Unauthorized [http://www.mydomain.com/admin/orders]
Processing IndexController#show (for xx.xx.xx.xx at 2014-05-09 05:56:59) [GET]
Parameters: {"action"=>"show", "controller"=>"index", "unauthenticated"=>"true"}
Rendering index/show
Completed in 30ms (View: 27, DB: 3) | 200 OK [http://www.mydomain.com/?unauthenticated=true]
는 관리자 페이지에 대한 요청은 실제로는 302 찾을 받고 있다고 보여줍니다 Rails가 401 Unauthorized를 보내고있는 경우에도 서버로부터 응답을받습니다.
GET /admin/orders HTTP/1.1
Host: www.mydomain.com
Connection: keep-alive
Cache-Control: max-age=0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.116 Safari/537.36
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Cookie: _myapp_session=xxx
HTTP/1.1 302 Found
Content-Type: text/plain
Transfer-Encoding: chunked
Connection: keep-alive
Status: 302
X-Powered-By: Phusion Passenger (mod_rails/mod_rack) 2.2.10
Location: /?unauthenticated=true
Server: nginx/0.7.65 + Phusion Passenger 2.2.10 (mod_rails/mod_rack)
새 서버는 원래 준비 서버의 복제본이므로 아키텍처가 동일하며 모든 요리사 레시피가 사용되었습니다. 여기에 무슨 일이 일어나고 있는지에 대한 아이디어가 있습니까?