About the Author

Chris Shiflett

Hi, I’m Chris: entrepreneur, community leader, husband, and father. I live and work in Boulder, CO.

All posts for Aug 2010

Mozilla Account Manager

For 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:

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:

  1. Inform the browser whether the user is logged in.
  2. 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:

$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.

PHP Anthem

Yesterday on IRC, Andrei Zmievski mentioned a new song about PHP. Sean Coates linked to a YouTube video with the song, which I then mentioned on Twitter:

PHP finally has an anthem. This is what we’ve been lacking. http://j.mp/PHPanthem /via @coates

If you haven't listened yet, take a moment to do so. There are a few options:

The song is by Lee Fernandes, who goes by @reelfernandes on Twitter. I couldn't find the lyrics online, so I created a new document on TypeWith.me to solicit help. To my delight, prompted by Sean's request, Lee joined and helped us out. :-)

TypeWith.me is made with EtherPad software. Lee thinks it's excellent. If you're sad about yesterday's news about Wave, you should give it a try.

The complete lyrics are below, with some links to add context. Enjoy! :-)

Oh yeah. (Oh yeah.)
(Just one day it just hits you all of a sudden. It's just like...)

Oh yeah, I'm so PHP this year.
Got a mic in the left, and 'n the right, cold beer.
Compile that Apache.
Now we got version 5 and two chicks laid out in the back seat.
Yeah, sometimes the code looks a little trashy.
But, this ain't ColdFusion.
Stop talking sassy, and pull up them panties.

I'm really... I'm just saying; why don't you go check out the API reference docs.
They're really good.
(They are.)

Is it underline or CamelCase?
I can't remember; I've been busy poundin' cakes.
It's what PHP developers do.
We get more booty than you.
Don't be jealous when you smell us; check the Boolean dude, it reads...

(Oh yeah.)
Check the Boolean dude; it reads true.
(Oh yeah.)
PHP gets more booty than you.
(Oh yeah.)
Check the Boolean dude; it reads true.
(Oh yeah.)
PHP gets more booty than you.
(Oh yeah.)
Check the Boolean dude; it reads...

True, PHP gets more booty than you,
but we still keep it clean.
MySQL really real wrappin' all strings.
Filter input like it was a herpes strain.
(You know what I'm saying?)
That's why we got the STD class.
Objects we pass might need to be trashed.
Girl, what you doin'?

Come gunzip this.
Be my witness as I strip this string of all slashes.
Now, I got what I need.
No traversing my filesystem when you ain't supposed to be.
That's how it is rolling with PHP.
All the hot chicks, yeah, they love PHP.
(It's so true.)
(Oh yeah, that's what I'm talking about.)


(Yo, yo, tell 'em about it.)

PHP: Hypertext Preprocessor.
It's real out here.
Somebody better call the mod_security officer.
My concern is for those weak half-assed scripting languages.
The ones that can't hang with us.
It's strange, but they get hanged and remain in dust.
Some aren't quite dead and still remain a pain to us.

PHP's got more muscle.
In a nutshell, nothing's quite like it.

Predicted by the ancient cultures and the psychics.
The ones who dreamt in recursive states.
Whispering premonitions of open source community gates.

(Oh yeah...)


If you're curious to learn more, you're in luck. Sean and Paul Reinheimer will be interviewing Lee for a future episode of Pique Web, their new podcast on PHP and related web technologies.

Oh yeah!