Ajax Same Origin Policy No More with Firefox 3.5
Firefox 3.5 now allows you to make AJAX Requests, or more correctly XMLHttpRequests cross domain (in other words foo.com can make XHR requests to bar.com). When I heard about this, my first is that they would use the cross-domain.xml file that Flash has supported for years to achieve this. They took a different approach, and use a HTTP header instead, which I think makes more sense.
So how does it work...
When you make a request using the XMLHttpRequest object it sends an Origin header (this is new, I wrote a blog entry about the Origin header as well) which contains the domain of the requesting page. The HTTP Response can send a HTTP header: Access-Control-Allow-Origin: * which means that any domain can access this page. You could also send a response header like this: Access-Control-Allow-Origin: http://example.com which only allows the example.com as an origin. The Access-Control-Allow-Origin header should contain a comma separated list of acceptable domains or a *.
For POST requests, and requests that want to read response headers a HTTP OPTIONS request is made first, that sends headers such as # Access-Control-Request-Method: POST in the request.
You can read more about this feature here
Tweet
add to del.icio.us
| Tags: ajax, firefox, xmlhttprequest, javascript, http
Related Entries
- AJAX on IE - back to the IFRAME - August 17, 2005
- Firefox 3.5 Introduces Origin Header, Security Features - June 30, 2009
- AJAX Presentation Outline - December 13, 2005
- Cross Domain Data Theft using CSS - July 21, 2010
- jQuery UI Sortable Tutorial - January 7, 2010
Trackbacks
Comments
e:g xhrObject.setRequestHeader("Origin","foo.com")
2. For Pre-Flighted requests an OPTIONS request is sent to the server and it responds with headers that indicate who and what is allowed.
CF should handle this so some security checks on referer and requested methods can be returned. But how do you get IIS to pass an OPTIONS method request to CF?
I can't get that to work either, and I've tried all the verb settings in IE and CF is mapped to respond to all-verbs, but no dice...
From firefox I can't access the contents of jsp file on the server due to cross-domain issue. Should I set the header in the jsp file and access the contents as I am doing now... kindly suggest.. I am struggling to solve this problem for long...
Post a Comment
Recent Entries
- Writing Secure CFML cfObjective 2013 Slides
- Upgrading to Java 7 on Linux
- J2EE Sessions in CF10 Uses Secure Cookies
- Learn about ColdFusion Security at cfObjective 2013
- Session Loss and Session Fixation in ColdFusion
- FuseGuard 2.3 Released
- CKEditor Spell Checker Plugin
- Adobe Says Go Ahead and Upgrade your ColdFusion JVM





