Auth_OpenID_Consumer::begin PHP Метод

begin() публичный Метод

Start the OpenID authentication process. See steps 1-2 in the overview at the top of this file.
public begin ( string $user_url, boolean $anonymous = false ) : Auth_OpenID_AuthRequest
$user_url string Identity URL given by the user. This method performs a textual transformation of the URL to try and make sure it is normalized. For example, a user_url of example.com will be normalized to http://example.com/ normalizing and resolving any redirects the server might issue.
$anonymous boolean True if the OpenID request is to be sent to the server without any identifier information. Use this when you want to transport data but don't want to do OpenID authentication with identifiers.
Результат Auth_OpenID_AuthRequest $auth_request An object containing the discovered information will be returned, with a method for building a redirect URL to the server, as described in step 3 of the overview. This object may also be used to add extension arguments to the request, using its 'addExtensionArg' method.
    function begin($user_url, $anonymous = false)
    {
        $openid_url = $user_url;
        $disco = $this->getDiscoveryObject($this->session, $openid_url, $this->session_key_prefix);
        // Set the 'stale' attribute of the manager.  If discovery
        // fails in a fatal way, the stale flag will cause the manager
        // to be cleaned up next time discovery is attempted.
        $m = $disco->getManager();
        $loader = new Auth_Yadis_ManagerLoader();
        if ($m) {
            if ($m->stale) {
                $disco->destroyManager();
            } else {
                $m->stale = true;
                $disco->session->set($disco->session_key, serialize($loader->toSession($m)));
            }
        }
        $endpoint = $disco->getNextService($this->discoverMethod, $this->consumer->fetcher);
        // Reset the 'stale' attribute of the manager.
        $m = $disco->getManager();
        if ($m) {
            $m->stale = false;
            $disco->session->set($disco->session_key, serialize($loader->toSession($m)));
        }
        if ($endpoint === null) {
            return null;
        } else {
            return $this->beginWithoutDiscovery($endpoint, $anonymous);
        }
    }

Usage Example

Пример #1
0
 static function redir_openidserver($openid_url, $store_path, $wfFlag = 1)
 {
     global $serendipity;
     $path_extra = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'PHP-openid/';
     $path = ini_get('include_path');
     $path = $path_extra . PATH_SEPARATOR . $path;
     ini_set('include_path', $path);
     require_once "Auth/OpenID/Consumer.php";
     require_once "Auth/OpenID/FileStore.php";
     $store = new Auth_OpenID_FileStore($store_path);
     $consumer = new Auth_OpenID_Consumer($store);
     $trust_root = $serendipity['baseURL'];
     switch ($wfFlag) {
         case 1:
             $process_url = $trust_root . 'serendipity_admin.php?serendipity[openidflag]=1';
             break;
         case 3:
             $process_url = $trust_root . 'serendipity_admin.php?serendipity[openidflag]=3' . '&serendipity[adminModule]=event_display&serendipity[adminAction]=profiles';
             break;
         default:
             $process_url = $trust_root . $serendipity['indexFile'] . '?serendipity[subpage]=addopenid&serendipity[openidflag]=2';
     }
     $auth_request = $consumer->begin($openid_url);
     if (!$auth_request) {
         return FALSE;
     }
     $auth_request->addExtensionArg('sreg', 'required', 'fullname');
     $auth_request->addExtensionArg('sreg', 'required', 'email');
     $redirect_url = $auth_request->redirectURL($trust_root, $process_url);
     header('Status: 302 Found');
     header("Location: " . $redirect_url);
     exit;
 }
All Usage Examples Of Auth_OpenID_Consumer::begin