File Under: Identity

Be Your Own Open ID Provider

OpenID is a burgeoning standard for identifying and authenticating yourself on the web. You do this by identifying yourself not with a standard username and password, but with a URL. This URL points to a web page that verifies that you are, in fact, you.

A number of third-party sites offer OpenID URLs to their users, including LiveJournal, AOL, and Technorati. But some people do not like to be beholden to third parties for something that may turn out to be a central part of their online identity, and they’d rather host their own.

An easy way to do that is with an open source PHP identity server called phpMyID.


Contents

  1. What You’ll Need
  2. Installing phpMyID
  3. Using It
  4. Further Reading

What You’ll Need

  • A web server running PHP

Installing phpMyID

Download the latest source from http://siege.org/projects/phpMyID/. Create a subdirectory in your web directory called phpmyid. Place the files MyID.config.php and MyID.php in that directory, setting their ownership to the web user, if necessary.

In your web browser, go to http://yourwebserver/phpmyid/MyID.config.php. The page should display.

This is an OpenID server endpoint. For more information, see http://openid.net/



Server: http://yourwebserver/phpmyid/MyID.config.php



Realm: phpMyID



Login

If you click the Login link, it’ll prompt you for a username and password, which you haven’t yet configured yet. To do that, you need to come up with a username and password, then create an MD5 hash of them.


To do this at a Unix command line with OpenSSL, feed the username and password you want to the md5sum utility in the format username:phpMyID:password. Replace “phpMyID” with the realm from above if your realm differed:

echo -n "username:phpMyID:password" | md5sum


The output will be a 32-character hexadecimal hash that looks like:

22a204f0bf622e4a35f3d71304378ca9

You must memorize this — Ha, only kidding. Just copy it and be ready to paste it.

On Windows, feed the same username:phpMyID:password string into the MD5 hasher you’re using.

Now open the file MyID.config.php in a text editor. Near the top are two lines:

    'auth_username' =>  'test',



    'auth_password' =>  '22a204f0bf622e4a35f3d71304378ca9

Replace 'test' with the username you chose, and replace the 32-character hash that’s there with the hash you just generated.

Now when you click Login, enter your new username and password into the prompt. If you did everything correctly, it should tell you “You are logged in as username”.


Using It

Now, to use this as your OpenID, you’ll need a URL that points to it. Choose an HTML page under your control — say, the front page of your site — or create a new one. Add these two lines inside the head of that page:

<link rel="openid.server" href="http://yourwebserver/phpmyid/MyID.config.php">



<link rel="openid.delegate" href="http://yourwebserver/phpmyid/MyID.config.php">


Now, when you want to authenticate, simply give that page’s URL. It’ll prompt you for your username and password and then authenticate you.


Further Reading

For additional details, read the phpMyID README file. This file is also available in the downloaded package.