Mozilla Persona Minimum Viable Demo & API Walk-through

What's all this, then?

You are reading the documentation for a web application that provides a minimum viable demo and API walk-through for Mozilla Persona.

The app allows you to sign in and sign out (using Persona) and remembers if you're logged in. That's it. This is why it's a "minimum viable demo": it does the minimum amount of work necessary to demonstrate the usage of the Persona API. The focus is on explaining how to use Persona as a developer.

What is Persona and why should I use it?

Mozilla Persona is a cross-browser single-sign-on system. For users, it envisions a future with no site-specific passwords, since it allows you to log in to any site (that implements Persona) with just one password. For developers, it is a solution that eliminates all the headaches and traps that come with implementing authentication yourself: email verification, password recovery, and, most importantly, security. If your site implements Persona, you won't have to do any of those things yourself. Plus, you will be providing a better user experience for your visitors.

The other thing to know about Persona is that it's made by Mozilla, is completely free, and is entirely open-source. If you use Persona, you're never tied to a particular vendor or implementation.

How does Persona work?

To implement Persona, you don't really need to understand how it works, so this question is beyond the scope of this demo. If you're interested, a half-finished article I wrote addresses this exact question. I would also recommend reading the Persona documentation — specifically, the Protocol Overview.

The demo

The demo is an extremely minimalistic application that consists of one page that lets you log in and log out. The source code is split into two major parts.

  1. The client
  2. The server

You can get the demo from Github:

git clone git://github.com/nmalkin/persona-demo.git

For readability and consistency, both the client and the server are written in literate CoffeeScript. Literate programming is an approach to programming that intersperses code in a narrative that explains it. CoffeeScript is a language that compiles into JavaScript. If you haven't used it before, you'll probably want to check out its documentation or, better yet, look at the compiled JavaScript, which you'll find in the app directory.

Compiling and running

The app is already compiled for you, but if you want to recompile it, you can run make app. (You will need CoffeeScript installed.)

The documentation for the demo is generated by Docco. If you'd like to re-generate it, run make docs.

To run the server, make sure you have node.js, then run:

make run

The server will run, by default, on http://127.0.0.1:8080.

What now?

  1. Read the source/documentation for the client
  2. Read the source/documentation for the server
  3. Look at the JavaScript the source compiles to
  4. Try running the application
  5. Build your own website with Persona!

Getting help

Helpful resources for developing with Persona include:

h