당신은
cron.yaml
에서 확인 요청이오고 만들기 위해 몇 가지를 확인하실 수 있습니다
...
1) 요청 localhost
에서 오는 것입니다.
2) User-Agent
은 aws-sqsd
을 포함합니다.
3) 요청은 작업자 인스턴스에서만 처리해야합니다.
나는 내 컨트롤러에 이러한 필터를 적용하기 위해 before_action
필터를 사용합니다. 코드는 다음과 같이 보입니다.
##
# Protect against abuse - requests must have the correct "User-Agent" header,
# come from localhost, and will only be handled by worker instances.
before_action :correct_user_agent
before_action :correct_source
before_action :worker_instance
...controller code here...
private
##
# Confirms the correct User-Agent header was sent.
def correct_user_agent
return if request.headers.env["HTTP_USER_AGENT"].include?("aws-sqsd")
head(:forbidden)
end
##
# Confirms the request is coming from localhost.
def correct_source
return if request.local? || Rails.env.development? || Rails.env.test?
head(:forbidden)
end
##
# Don't allow requests to be processed in the production web environment, since
# it has a worker instance associated with it.
def worker_instance
return unless Rails.env.production?
head(:forbidden)
end
분명히 요청이 POST라는 것을 확인할 수 있습니까? –
@DanielRoseman 나는 또한 악의적 인 사용자의 게시를 막고 싶습니다. – Flash