2013-09-21 3 views
1

railscast에서이 tutorial 다음에 내 레일 API에 대한 인증을 구현하려고합니다. 나는 블럭 안의 토큰을 검사해야하고 블록이 true를 반환하면 통과해야하는 메소드 authenticate_or_request_with_http_token을 사용하고 있습니다. 그러나, 방금 블록에 진실이라고하더라도 방법은 결코 통과하지 않는다. 나는 레일 4.0authenticate_or_request_with_http_token이 절대 전달되지 않습니다

Filter chain halted as :restrict_access rendered or redirected 

을 사용하고

이 내 코드입니다 : 이것은 내가 로그에서 볼 것입니다 당신은 인증 헤더를 제공해야 백엔드

before_filter :restrict_access 

    def restrict_access 
    authenticate_or_request_with_http_token do |token, options| 
     true 
    end 
    end 

답변

2

. 예 : - 'Authorization'=> "Token token = # {@ token}" 메서드가 헤더를 찾지 못하면 http 상태 403을 반환합니다 : 금지 된 액세스