Can anyone post simple step by step integration for openid into a site which has a login system already.???
I decided to use php openid 2.1.3 but could get where to start and what to do...
Can anyone post simple step by step integration for openid into a site which has a login system already.???
I decided to use php openid 2.1.3 but could get where to start and what to do...
No, there is no simple guide. There are too many login systems and different implementations to make this simple and straightforward.
For particular scripts, try googling it. For any other scripts, you will have to integrate OpenID into your application. If you use MVC, you're in luck: Have a look at the user model and plug OpenID into it.
I think your best bet is using the OpenID module from the Zend Framework. It can be used on it's own, without having to use the whole framework, and they have a fairly simple explanation on how to use it on their manual pages. It's as simple (if you understand the concept of OpenID) as:
login_page.php:
// Load the library Zend Framework way, or load it yourself...
// Always good to pick apart the library anyway, to see how it works:
Zend_Loader::loadClass('Zend_OpenId');
$consumer = new Zend_OpenId_Consumer();
if(!$consumer->login($_POST['openid_identifier'], 'redirect_to.php'))
{
die('OpenID login failed.');
}
redirect_to.php:
Zend_Loader::loadClass('Zend_OpenId');
$consumer = new Zend_OpenId_Consumer();
if($consumer->verify($_GET, $id))
{
echo htmlspecialchars($id).' is a valid ID.';
}
else
{
// redirect to "login.php?login=failed".
if(!headers_sent())
{
header('HTTP/1.1 307 Temporary Redirect', true, 307);
header('Location: login.php?login=failed');
}
else die('Invalid ID.');
}
It is a lot easier to use than the PHP OpenID Library (php-openid) provided by the OpenID Foundation.
EDIT: *How to implement Zend_OpenId (in response to comment).*
Download the latest Zend Framework, and extract the folder ZendFramework-1.9.2/library/Zend/OpenId
.
There are however a few things you have to do:
[...]/OpenId/Exception.php
from Zend_Exception
to Exception
.Now you can reference the classes by:
require_once '/path/to/OpenId/Consumer.php';
$consumer = new Zend_OpenId_Consumer();
// If you plan on making your own OpenID's, use 'Provider' instead of 'Comsumer'.
require_once '/path/to/OpenId/Provider.php';
$provider = new Zend_OpenId_Provider();
Now, the best advice I can give you though is to read through the manuals! Don't expect it to work first time... Zend's implementation may be easier, but that doesn't stop OpenID being a pain in the ass!
Joseph Smarr of Plaxo has written a nice recipe for OpenID-enabling site a couple of years agon.