Joseph Smarr - Cross-Site Ajax 1 Cross-Site Ajax Challenges and Techniques for Building Rich Web 2.0 Mashups Joseph Smarr Plaxo, Inc.

Slides:



Advertisements
Similar presentations
Widget Summit: Advanced JavaScript Joseph Smarr Plaxo, Inc. October 16, 2007.
Advertisements

By Loukik Purohit & Rohit Ghatol
® IBM Software Group © 2007 IBM Corporation Accessible Rich Internet Applications and Online Services Rich Schwerdtfeger IBM Distinguished Engineer, Chair.
AJAX Presented by: Dickson Fu Dimas Ariawan Niels Andreassen Ryan Dial Jordan Nielson CMPUT 410 University of Alberta 2006.
Servlets and a little bit of Web Services Russell Beale.
WHAT IS AJAX? Zack Sheppard [zts2101] WHIM April 19, 2011.
Does Ajax suck? CS575 Spring 2007 Chanwit Suebsureekul.
Session Management A290/A590, Fall /25/2014.
More APIs: Web Services CMPT 281. Announcements Project milestone Lab: – Web services examples.
Best and Worst Practices Building RIA from Adobe and Microsoft.
Phu H. Phung Chalmers University of Technology JSTools’ 12 June 13, 2012, Beijing, China Joint work with Lieven Desmet (KU Leuven)
1 Subspace: Secure Cross Domain Communication for Web Mashups Collin Jackson and Helen J. Wang Mamadou H. Diallo.
Subspace: Secure Cross-Domain Communication for Web Mashups Collin Jackson Stanford University Helen J. Wang Microsoft Research ACM WWW, May, 2007 Presenter:
Web Services & Widgets Godmar Back. Mash-Ups Applications that combine information from different sources in one web page Different architectural choices.
Christopher M. Pascucci Basic Structural Concepts of.NET Browser – Server Interaction.
Introduction to InfoSec – Recitation 10 Nir Krakowski (nirkrako at post.tau.ac.il) Itamar Gilad (itamargi at post.tau.ac.il)
Prof. James A. Landay University of Washington Spring 2008 Web Interface Design, Prototyping, and Implementation Rich Internet Applications: AJAX, Server.
JavaScript & jQuery the missing manual Chapter 11
Origins, Cookies and Security – Oh My! John Kemp, Nokia Mobile Solutions.
Step Outside the Box – Part II ColdFusion and Ajax.
Server-side Scripting Powering the webs favourite services.
AJAX Without the “J” George Lawniczak. What is Ajax?
JavaScript, Fourth Edition Chapter 12 Updating Web Pages with AJAX.
Chapter 6 The World Wide Web. Web Pages Each page is an interactive multimedia publication It can include: text, graphics, music and videos Pages are.
November 13, 2008 Ohio Information Security Forum Attack Surface of Web Applications James Walden Northern Kentucky University
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
Krishna Mohan Koyya Glarimy Technology Services
Web Mashups -Nirav Shah.
06/10/2015AJAX 1. 2 Introduction All material from AJAX – what is it? Traditional web pages and operation Examples of AJAX use Creating.
Instructor, Dr. Khalili Bahram Jeevan Kumar Gogineni.
HTML5 Communication. The Setup Somewhere on the web, a server makes a ”service” available, that we wish to use in a web application The service may offer.
Smarten Up Your Address Book with a Plaxo Mashup Presentation to Mashup University Joseph Smarr Plaxo, Inc. July 11, 2006.
OMash: Enabling Secure Web Mashups via Object Abstractions Steven Crites, Francis Hsu, Hao Chen (UC Davis) ACM Conference on Computer and Communications.
Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc.Slide 1.
10/13/2015 ©2006 Scott Miller, University of Victoria 1 Content Serving Static vs. Dynamic Content Web Servers Server Flow Control Rev. 2.0.
Understanding AJAX Hype, Hope, Hurt and Help for the Web MJTS May 4th, 2006 _________________________ Terence Conklin, Conklin Systems
JavaScript – Quiz #9 Lecture Code:
Cross Site Integration “mashups” cross site scripting.
Random Logic l Forum.NET l AJAX Behind the buzz word Forum.NET ● January 23, 2006.
1 Geospatial and Business Intelligence Jean-Sébastien Turcotte Executive VP San Francisco - April 2007 Streamlining web mapping applications.
Lecture 9: AJAX, Javascript review..  AJAX  Synchronous vs. asynchronous browsing.  Refreshing only “part of a page” from a URL.  Frameworks: Prototype,
Ajax. –Asynchronous JavaScript and XML –Umbrella term for technologies that often: Use client-side scripting for layout and formatting Use less than full.
Vaibhav Rastogi and Yi Yang.  SOP is outdated  Netscape introduced this policy when most content on the Internet was static  Differences amongst different.
Web Technologies Lecture 3 Web forms. HTML5 forms A component of a webpage that has form controls – Text fields – Buttons – Checkboxes – Range controls.
Web Security Lesson Summary ●Overview of Web and security vulnerabilities ●Cross Site Scripting ●Cross Site Request Forgery ●SQL Injection.
ICM – API Server & Forms Gary Ratcliffe.
Event Handling & AJAX IT210 Web Systems. Question How do we enable users to dynamically interact with a website? Answer: Use mouse and keyboard to trigger.
CHAPTER 8 AJAX & JSON WHAT IS AJAX? Ajax lets you…
AJAX and REST. Slide 2 What is AJAX? It’s an acronym for Asynchronous JavaScript and XML Although requests need not be asynchronous It’s not really a.
AJAX Use Cases for WSRP Subbu Allamaraju BEA Systems Inc WSRP F2F Meeting, May 2006.
CSRF Attacks Daniel Chen 11/18/15. What is CSRF?  Cross Site Request Forgery (Sea-Surf)  AKA XSRF/ One Click / Sidejacking / Session Riding  Exploits.
Introduction to AJAX Sue Brandreth. What is Ajax?
Web Technology (NCS-504) Prepared By Mr. Abhishek Kesharwani Assistant Professor,UCER Naini,Allahabad.
 AJAX technology  Rich User Experience  Characteristics  Real live examples  JavaScript and AJAX  Web application workflow model – synchronous vs.
COSC 2328 – Web Programming.  PHP is a server scripting language  It’s widely-used and free  It’s an alternative to Microsoft’s ASP and Ruby  PHP.
AJAX CS456 Fall Examples Where is AJAX used? Why do we care?
JavaScript, Sixth Edition Chapter 11 Updating Web Pages with Ajax.
Modern Development Technologies in SharePoint SHAREPOINT SATURDAY OMAHA APRIL, 2016.
WHAT'S THE DIFFERENCE BETWEEN A WEB APPLICATION STREAMING NETWORK AND A CDN? INSTART LOGIC.
NCCUCS 軟體工程概論 Lecture 5: Ajax, Mashups April 29, 2014.
Redmond Protocols Plugfest 2016 Tarun Chopra Accessing APIs through Add-Ins Sr. Escalation Engineer.
Open Solutions for a Changing World™ Eddy Kleinjan Copyright 2005, Data Access WordwideNew Techniques for Building Web Applications June 6-9, 2005 Key.
JavaScript and Ajax (Ajax Tutorial)
Data Virtualization Tutorial… CORS and CIS
Subbu Allamaraju BEA Systems Inc
AJAX.
Session V HTML5 APIs - AJAX & JSON
HTML Level II (CyberAdvantage)
HTML5 AJAX & JSON APIs
JavaScript & jQuery AJAX.
Presentation transcript:

Joseph Smarr - Cross-Site Ajax 1 Cross-Site Ajax Challenges and Techniques for Building Rich Web 2.0 Mashups Joseph Smarr Plaxo, Inc.

Joseph Smarr - Cross-Site Ajax 2 The promise of mashups Create new experiences by combining components from different authors –Each site focuses on what it does best –Can wire up components in a novel way Google maps + Craigslist = HousingMaps Rich interaction often requires talking back and forth between components –House’s address  lat / long  map it

Joseph Smarr - Cross-Site Ajax 3 Talking between web components Normal situation: all on the same web site –Communicate across frames / iframes / popups –Talk to server using AJAX (XMLHttpRequest) Problem: doesn’t work when components live at different domains (mashup situation) –Same-origin policy Can include JavaScript / images from another domain Can’t talk to frame / iframe popup or send an XHR Prevents snooping on secret web pages (e.g. intranet)

Joseph Smarr - Cross-Site Ajax 4 CAN include image / JavaScript / CSS from Domain B CAN send XMLHttpRequest to Domain A CAN talk to other frames / iframes / popups on Domain A CAN'T send XMLHttpRequest to Domain B CAN'T talk to other frames / iframes / popups on Domain B CAN talk to other pages on Domain A CAN’T talk to any page on Domain A Domain B ImageCSSJavaScript XML / Web Page XHR So, how do mashups communicate?

Joseph Smarr - Cross-Site Ajax 5 How do mashups communicate? Often, they don’t (Google maps 1.0) –Single JavaScript  all processing done locally Plotting lat/long or fetching image tiles is deterministic –Can’t get any additional data (e.g. geo-coding) Server-side proxy (HousingMaps, Flickr) –Talk to your server  it talks to the foreign site –Problem: bottleneck; barrier to mass deployment

Joseph Smarr - Cross-Site Ajax 6 Server-side proxy Web Page Domain A Server Domain A Server Domain B

Joseph Smarr - Cross-Site Ajax 7 How do mashups communicate? Often, they don’t (Google maps 1.0) –Single JavaScript  all processing done locally Plotting lat/long or fetching image tiles is deterministic –Can’t get any additional data (e.g. geo-coding) Server-side proxy (HousingMaps, Flickr) –Talk to your server  it talks to the foreign site –Problem: bottleneck; barrier to mass deployment Use flash for cross-domain communication –Can use crossdomain.xml to allow foreign sites –Yahoo maps uses this to do geo-coding

Joseph Smarr - Cross-Site Ajax 8 Flash proxy Web Page Domain A Server Domain B Flash crossdomain.xml

Joseph Smarr - Cross-Site Ajax 9 How do mashups communicate? JSON-P (Script injection + callback) –Dynamically load JavaScript file with data Use DHTML to inject a tag in the document Data is returned in JSON (JavaScript data format) –Clever trick: specify callback function on URL foreign-site.com/json-api.js?callback=myFunc Loads myFunc({ data: “hello” });  round-trip! –Works well in practice, but some drawbacks Limited control vs. XHR (just loads or doesn’t) API provider can return malicious code (e.g. steal cookies)

Joseph Smarr - Cross-Site Ajax 10 JSON-P Web Page Domain A Server Domain B JSON + callback

Joseph Smarr - Cross-Site Ajax 11 Using JSON-P in OO web apps Problem: callback function has to be global –Complex code maintains state / instances –Would like to handle callback with instance function on instantiated object Solution: bind the callback dynamically –Create a globally-unique function name Usually global prefix + auto-incremented counter –Use a closure to call your function in object-scope –Send the global function name as callback  it calls your scoped function

Joseph Smarr - Cross-Site Ajax 12 Dynamically binding a global callback var cbName = 'cb' + JSON.callbackCounter++; var cbFunc = function(jsonData) { myFunc.call(myObj, jsonData); // call bound callback }; JSON.callbacks[cbName] = cbFunc; var globalCallbackName = ‘JSON.callbacks.’ + cbName // url: '/json-api.js?callback=' + globalCallbackName; Used by dojo (ScriptSrcIO), Google Maps 2.5, Plaxo, etc.

Joseph Smarr - Cross-Site Ajax 13 Summary of cross-site techniques so far No cross-site communication –Include partner’s JS file once (can’t talk again) Server-side proxy –Talk on the backend (bottleneck, barrier to adoption) Flash proxy –Talk through cross-domain flash (requires flash) JSON-P –Talk through script-injection with callback (less control, partner could be malicious)

Joseph Smarr - Cross-Site Ajax 14 What about updating another web page? Proxies / JSON-P let you access foreign data –But still can’t touch a foreign frame/iframe/popup Many potential mashups would like to interact with existing web pages –Auto-fill a form with your contact info –Highlight relevant search results / text snippets How can two sites that want to cooperate get around the same-origin policy?

Joseph Smarr - Cross-Site Ajax 15

Joseph Smarr - Cross-Site Ajax 16 What does the partner site have to do? Add the button to your page –Specify the ID of your –Specify the location of your hidden callback page Add a small callback page on your site Full instructions and demo:

Joseph Smarr - Cross-Site Ajax 17 What does Plaxo have to do? Remember: Plaxo filled in a textarea on zazzle! –Need to get around same-origin policy –Without server-side proxy (JS/HTML only) JSON-P won’t solve this problem –Widget popup is hosted by Plaxo and goes thru several steps –Zazzle doesn’t know when to request the contact data Solution: “The JavaScript Wormhole” –Add hidden callback page on zazzle that includes Plaxo script –Plaxo popup loads callback in an iframe when done –Script is dynamically generated, and includes selected data –IFrame is also on zazzle (and has the data), so it can tell parent.opener to fill in the textfield

Joseph Smarr - Cross-Site Ajax 18 zazzle.com/ _this plaxo.com/ab_chooser Iframe: zazzle.com/cb.html  Script: plaxo.com/ab_chooser/abc_comm.jsdyn

Joseph Smarr - Cross-Site Ajax 19 Who’s using the Plaxo widget? See more at Using the widget? Let us know!

Joseph Smarr - Cross-Site Ajax 20 Generalizing the JavaScript Wormhole Site has a generic callback page to give you access –Site tells you the location of their callback page –Callback page loads your domain’s JavaScript JavaScript is dynamically generated to include your data Can pass script url with query args to callback page – /cb.html? –Access query string on cb page with location.search Site can restrict callback page to trusted hosts –Only load script if it’s on a trusted domain –Could further restrict to certain URL prefixes, etc.

Joseph Smarr - Cross-Site Ajax 21 Generalized JavaScript Wormhole var trustedDomains = [ " " ]; function isTrustedDomain(url) { for (var i = 0; i < trustedDomains.length; i++) if (url.indexOf(trustedDomains[i]) == 0) return true; return false; } function doWormhole() { var url = location.search.substr(1); // chop off ? if (isTrustedDomain(url)) { var script = document.createElement('script'); script.type = "text/javascript"; script.src = url; document.getElementsByTagName("head")[0].appendChild(script); } else alert("ignoring untrusted url: " + url); }

Joseph Smarr - Cross-Site Ajax 22 Where do we go from here? Ajax is a “hack” on top of an old platform The platform can evolve

Joseph Smarr - Cross-Site Ajax 23 Where do we go from here? Ajax is a “hack” on top of an old platform The platform is evolving

Joseph Smarr - Cross-Site Ajax 24 Where do we go from here? Ajax is a “hack” on top of an old platform The platform is evolving What platform do we want to build?

Joseph Smarr - Cross-Site Ajax 25 Should we open cross-domain XHR? After all, we can already include foreign JavaScript, image, and CSS files –So why not XML too? (“just another resource file”) HTML looks like XML (esp. XHTML) –Hard to make sure you really meant to serve that page as XML data (cf. js / img / css) Personal / private info more often in XML / HTML –But increasingly a problem with JS too (JSON) Cookies / creds sent with XHR request –Can’t easily distinguish direct vs. XHR access

Joseph Smarr - Cross-Site Ajax 26 Trust relationships between sites Random site accessing this file vs. trusted partner –Flash does this with crossdomain.xml –Web services do this with certs / IP whitelists –JavaScript wormhole does it (sort of) Should a trust relationship exist for mashups? –Want to minimize barriers to adoption / innovation –When sharing user info, should have prior agreement? –How formal / technical should this trust be?

Joseph Smarr - Cross-Site Ajax 27 Restricting access to unauthorized info Restrict XHR to same “internet zone” –So public site can’t access intranet page Don’t send any cookies / credentials via XHR –Practically restricts cross-site comm. to fully public info –Could still send auth info on URL But now other site has it Give other site limited-access token? White-list authorized sites with cross-domain file Return special response headers for public pages –Legacy problem for existing content

Joseph Smarr - Cross-Site Ajax 28 Proposals for better cross-site tools ContextAgnosticXmlHttpRequest (Chris Holland) –Alternative to normal XmlHttpRequest for cross-site –Don’t send/receive any cookie or HTTP auth info –Server must specify X-Allow-Foreign-Hosts in response JSONRequest (Douglas Crockford) –New browser object for cross-site JSON (like XHR) –Allows GET / POST / cancel of JSON request / response –No cookies / auth info sent or received –Requires special headers in request / response

Joseph Smarr - Cross-Site Ajax 29 In conclusion… Cross-site communication is tricky but important –Key enabling technology for building rich mashups –Raises legitimate security issues that can’t be ignored Today: Use server-side proxy or JSON-P –Proxy introduces bottleneck, but provides full access –JSON-P is more scalable, but limited to JSON APIs –JavaScript Wormhole lets you touch foreign pages Keep the discussion of better tools / protocols going! –This problem is here to stay –Browser developers are listening!

Joseph Smarr - Cross-Site Ajax 30 For further reading… Cross-site limitations – – uthor/om/xframe_scripting_security.asphttp://msdn.microsoft.com/library/default.asp?url=/workshop/a uthor/om/xframe_scripting_security.asp FlashXMLHttpRequest – ContextAgnosticXMLHttpRequest – tprequest-informal.htmlhttp://chrisholland.blogspot.com/2005/03/contextagnosticxmlht tprequest-informal.html JSONRequest –