How to integrate a simple openid with the existing registration system on my site?

Can someone post a simple step-by-step integration for openid on a site that already has a login system?

I decided to use PHP OpenID 2.1.3, but could start and what to do.

+3
source share
3 answers

I think your best bet is to use the OpenID module from the Zend Framework . It can be used on its own, without using the entire structure, and they have a fairly simple explanation of how to use it in the pages of their manual . It is 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.');
 }

, OpenID PHP (php-openid), OpenID Foundation.

EDIT: Zend_OpenId ( ).

Zend Framework ZendFramework-1.9.2/library/Zend/OpenId.

, :

  • , [...]/OpenId/Exception.php Zend_Exception Exception.
  • (, ) .

:

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();

, , ! , ... Zend , OpenID, !

+3

, . , .

Google. OpenID . MVC, : OpenID .

0

OpenID .

0

Source: https://habr.com/ru/post/1717614/


All Articles