2009年2月17日星期二

Flex3+rails2的RequestForgeryProtection问题

话说,按照Flexible rails这个教程,为了预防CSRF攻击,我们开启了ApplicationController中的protect_from_forgery项
问题出来了
[RPC Fault FaultString="HTTP request error" faultCode="Server.Error.Request" faultDetail="Error:[IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2032:Stream Error.URL: http://localhost:3000/bugs/update"].URL: http://localhost:3000/bugs/update"]
at mx.rpc::AbstractInvoker/http://www.adobe:com/2006/flex/mx/internal::faultHandler()
at mx.rpc::Responder/fault()
at mx.rpc::AsyncRequest/fault()
at flash.events::EventDispatcherdispatchEventFunction()
at.flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/redirectEvent()

查看log,发现问题出在authenticity_token上
因为如果由Rails来生成表单,所有用form_for或者form_tag等生成的表单均被隐藏注入一个特别的基于用户session生成的token,在表单被提交时一并将token提交至服务器并接受服务器端的检查。
但是我们在Flex中设计的表单没有包含authenticity_token。
咋办?
网上有人建议改写request_forgery_protection.rb的verified_request?,我认为改写那个方法不如不开启protect_from_forgery。
等待高人来解决此问题

2009年2月13日星期五

Flex 3.0.2的XXX

1377-4861-5964-4149-7405-5440
1377-4965-7922-2026-0118-6904
1377-4265-2531-7733-3832-7505
1377-4164-3292-3871-2072-6426
1377-4160-8078-3708-6370-4578