views:

116

answers:

2

i need to provide openid service to users on my domain. They all have unique subdomains such as: abc.example.com and i want them to use abc.example.com as their openid identity...

I read this - https://www.myopenid.com/help#own%5Fdomain - but it looks like its for (a) ONE user and (b) I need to have an existing myopenid/similar account...

phpmyid looks rad, but seems only to work for single users... how i can tweak it to make it run for everyone with a subdomain? Or what else can I do?

+2  A: 

The subdomain is the easy part. For that you'll need "Wildcard DNS" Which essentially creates this DNS record: *.domain.com IN A 10.10.0.1 replacing the domain and IP with yours respectively. Next you'll need to setup whatever webserver to read in wild card domains (this typically works in apache like so: ServerAlias *.domain.com but will depend from webserver to webserver.

On to the last part. phpMyID - it's only for one person's identity. And unfortunately this post is way too small to go into exactly how to do this. These are some snipits and higher level ideas that would probably need to be implemented.

First you'll need to take whatever hard-coded information in the file and move it to a database (username, password, etc) so you can more easily track users. You'll also be forced to track users names using only [A-Za-z0-9_] as &,%,$,#,@,!, ,etc will all break the DNS and the user can't access the Provider anymore.

You will also need to know what the current hostname that is being accessed is:

<?php
$hostname = $_SERVER['SERVER_NAME'];
$username = basename($hostname, ".domain.com"); // Replace .domain.com with your domain
?>

So now that you have a user you can structure the database call to select that users information - then update the once hard coded values of the "one user phpMyID" with the dynamic user data from the database and the script should continue on it's merry way. It's been awhile since I've looked at phpMyID but I assume that's the majority of the idea behind it.

Marco Ceppi
Thanks Marco - am looking into the above!
RubiCon10
I've also been using CommunityID which supports username based URL's out of the box.
Marco Ceppi
I'm admired! Nice usage of `basename`, pretty creative.
Alix Axel