Mozilla Account Manager
17 Aug 2010For some time now, I've been happily using 1Password to manage all of my online accounts. I really like it and recommend it to all of my friends, but I do have a few reservations:
- It uses a proprietary format for storing my account information. (Older versions used the Keychain format.)
- It does not integrate with Mobile Safari or anything that's not a browser (e.g., iTunes). This means browsing on my iPhone or iPad is practically impossible, and my iTunes password has to be easy to type, leaving me vulnerable.
- There's currently no way for developers to make sure their sites support 1Password. Given the way 1Password works, microformats seem like a possible solution.
Earlier this year, I heard about Account Manager, a new effort from Mozilla that aims to help web sites and users connect in a safe and consistent way. In other words, it can potentially make managing passwords online a lot easier, more consistent, and more secure. Furthermore, because it's being developed as an open standard, widespread support is a possibility.
The spec uses MediaWiki, which does not number sections by default. Because all references within the spec use section numbers, you might want to log in and select "auto-number headings" in your preferences. (You can also refer to the table of contents at the top.)
This weekend, I managed to find some time to explore Account Manager a bit. With the help of Dan Mills, I got it working with Firefox 4. He was also kind enough to provide some preview builds for you to use:
- firefox-4.0b4pre.en-US.mac.dmg (Mac)
- firefox-4.0b4pre.en-US.linux-i686.tar.bz2 (Linux)
- firefox-4.0b4pre.en-US.win32.installer.exe (Windows)
If you want to try it out before I give you a quick tour, install one of the Firefox 4 preview builds linked above, and visit my Account Manager demo.
Implementing Account Manager is pretty straightforward. To keep things simple, I'm only going to show you how to implement login and logout. Think of this as two steps:
- Inform the browser whether the user is logged in.
- Inform the browser how to log in and log out.
The first step is accomplished via the X-Account-Management-Status
header. (This is a response header you can set with the header()
function.) Here's an example:
X-Account-Management-Status: active; id="chris"; name="Chris Shiflett"; authmethod="username-password-form"
This header informs the browser that the user is currently logged in as chris
. Instead of active
(logged in), you may specify none
(not logged in) or passive
(remember me). The rest of the header is a semicolon-delimited list of attributes, three of which are currently defined: name
, id
, and authmethod
. There are various options for authmethod
, but I'm only going to be talking about username-password-form
.
Informing the browser how to log in and log out is almost as easy. You indicate these things in an Account Management Control Document (AMCD). You can view my AMCD to get an idea of the format, but because json_encode()
doesn't generate the most readable JSON, I'll share the PHP as well:
<?php
$json = array(
'version' => 1,
'sessionstatus' => array(
'method' => 'GET',
'path' => '/lab/account-manager/status'
),
'auth-methods' => array(
'username-password-form' => array (
'connect' => array(
'method' => 'POST',
'path' => '/lab/account-manager/login',
'params' => array(
'username' => 'username',
'password' => 'password'
)
),
'disconnect' => array(
'method' => 'GET',
'path' => '/lab/account-manager/logout'
)
)
)
);
echo json_encode($json);
?>
Although it's not indicated in the spec yet, sessionstatus
is now required. In a future post, I will discuss this in more detail along with registration and other features.
After you create your own AMCD, specify its location with a Link
header:
Link: <http://shiflett.org/lab/account-manager/amcd>; rel="acct-mgmt"
As a reminder, you can try my demo of Account Manager. I encourage you to use something like Live HTTP Headers, so you can examine the HTTP traffic. If you want to implement Account Manager on your own sites, be prepared to make frequent changes.
Here are a few additional things I noticed:
- Account Manager does not seem to abide by the
Cache-Control
header correctly, which can make development cumbersome. You must restart Firefox for any AMCD change to take effect. (See my comment below for an alternative solution.) - It is not currently possible to protect against CSRF, but there are ongoing discussions about it, so a solution is sure to come in the near future.
- Logging out currently requires the GET request method. As I've discussed before, POST is more appropriate. Because Account Manager provides a consistent interface, the request method you choose to use has no aesthetic implications, so I hope most people will use POST.
Want to participate in a new browser technology that just might prove to be more important than tabs? Install Firefox 4 (Mac, Linux, Windows), read the spec, try my demo, join the mailing list, and most of all, have fun!
There's a lot I did not cover in this post, but I will be blogging more about Account Manager in the near future. One of the missing topics I'm most interested in exploring is how Account Manager can potentially be supported by apps other than Firefox. It's possible that 1Password could continue to be essential, because it could be the app-neutral data store for all of my account data.