Come faccio a impedire a Google di causare questo errore durante la scansione del sito? Non sono interessato a disattivare "protect_from_forgery" a meno che non sia sicuro farlo.Googlebot causa una richiesta di origine incrociata (COR) non valida su Rails 4.1
[fyi] method=GET path=/users format=*/* controller=users action=show status=200 duration=690.32 view=428.25 db=253.06 time= host= user= user_agent=Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html) session= params={""}()
[hmm] Security warning: an embedded <script> tag on another site requested protected JavaScript. If you know what you're doing, go ahead and disable forgery protection on this action to permit cross-origin JavaScript embedding. (pid:)
[fyi] method=GET path=/users/123/flag format=*/* controller=users action=flag status=500 error='ActionController::InvalidCrossOriginRequest:Security warning: an embedded <script> tag on another site requested protected JavaScript. If you know what you're doing, go ahead and disable forgery protection on this action to permit cross-origin JavaScript embedding.' duration=26.50 time= host= user= user_agent= session= params= (pid)
[omg] ActionController::InvalidCrossOriginRequest (Security warning: an embedded <script> tag on another site requested protected JavaScript. If you know what you're doing, go ahead and disable forgery protection on this action to permit cross-origin JavaScript embedding.):
actionpack (4.1.4) lib/action_controller/metal/request_forgery_protection.rb:217:in `verify_same_origin_request'
Il regolatore risponde con questo
respond_to do |format|
format.js { render template: 'users/flag', layout: "some_layout" }
end
non sono in grado di ricreare il bug e sembra funzionare bene quando lo faccio attraverso il mio browser
Finora ho guardato le seguenti risorse, ma la maggior parte sembra suggerire una svolta cieca della CSRF o non hanno risposta.
- Using layout specific javascript in comfy leads to InvalidCrossOriginRequest
- Invalid Cross Origin Request After Upgrading to Rails 4.1
- How to avoid ActionController::InvalidCrossOriginRequest exception?
- Googlebot asks for png and then my whole Heroku site crashes. What is going on?
- https://github.com/rails/rails/pull/13345
- http://myownpirateradio.com/tag/rails-authentication-token/
- https://gist.github.com/aishek/8535082
- Why does Google prepend while(1); to their JSON responses?
- http://www.tsheffler.com/blog/?p=428
- http://edgeapi.rubyonrails.org/classes/ActionController/RequestForgeryProtection.html
per chiarire: L'azione deve essere protetto da CSRF, ma voglio impedire a Google di eseguire la scansione o generare un errore di eseguire la scansione della pagina. Cioè). Voglio che gli avvisi di sicurezza falsi positivi vadano via senza compromettere in realtà le mie caratteristiche di sicurezza.
L'ordine è importante qui. format.html dovrebbe venire prima di format.js nel blocco respond_to. – sma
Mi sto imbattendo in questo stesso problema, e la procedura per riprodurre descritta nella soluzione non ha funzionato per me finché non ho cambiato l'intestazione in '-H" Accetta: */* "', a quel punto posso ora riprodurre l'errore. –