Using the browser for desktop UI

Instance Hunter picture Instance Hunter · Oct 29, 2009 · Viewed 7.5k times · Source

How can I use the browser as a UI for a desktop app? The ways I have come up with so far are...

  1. Use all HTML/Javascript. Problem: Can't access filesystem or just about anything else.
  2. Run a local webserver while the application is in use. Problem: How do I kill it when the user is done? My users are not technical enough to Ctrl+C.
  3. Embed a browser component in a regular GUI. Problem: Embedded browser components tend to be glitchy at best. The support for Javascript/CSS is never as good as it is in a real browser.
  4. ...?

The ideal solution would work with any technology. I know there are options like writing Firefox extensions, but I want to have complete freedom in the backend technology and browser independence.

Answer

SLaks picture SLaks · Oct 29, 2009

Please note that if you choose to run a local webserver, you're creating a security risk.

Any webpage running on the same machine that knows about your app can send requests to your server using Javascript, and you have no simple and reliable way of knowing what the request came from. (Don't trust the referer header)

Google Desktop, which uses a similar approach, has had several real-world vulnerabilities that allow any webpage to read any file on disk.

There are several ways to protect against this; I would recommend requiring each request to have a auth key which is randomly generated per-machine (and expires at some point), which you could put in the source for the actual pages. XHR protection would prevent malicious websites from reading the auth key, rendering them powerless.