Example #1
0
function openid_try($url)
{
    $store = new Auth_OpenID_MySQLStore(theDb());
    $store->createTables();
    $consumer = new Auth_OpenID_Consumer($store);
    $auth_request = $consumer->begin($url);
    if (!$auth_request) {
        $_SESSION["auth_error"] = "Error: not a valid OpenID.";
        header("Location: ./");
    }
    $sreg_request = Auth_OpenID_SRegRequest::build(array('email'), array('nickname', 'fullname'));
    if ($sreg_request) {
        $auth_request->addExtension($sreg_request);
    }
    // Attribute Exchange (Google ignores Simple Registration)
    // See http://code.google.com/apis/accounts/docs/OpenID.html#Parameters for parameters
    $ax = new Auth_OpenID_AX_FetchRequest();
    $ax->add(Auth_OpenID_AX_AttrInfo::make('http://axschema.org/contact/email', 2, 1, 'email'));
    $ax->add(Auth_OpenID_AX_AttrInfo::make('http://axschema.org/namePerson/first', 1, 1, 'firstname'));
    $ax->add(Auth_OpenID_AX_AttrInfo::make('http://axschema.org/namePerson/last', 1, 1, 'lastname'));
    $auth_request->addExtension($ax);
    if ($auth_request->shouldSendRedirect()) {
        $redirect_url = $auth_request->redirectURL(getTrustRoot(), getReturnTo());
        // If the redirect URL can't be built, display an error
        // message.
        if (Auth_OpenID::isFailure($redirect_url)) {
            die("Could not redirect to server: " . $redirect_url->message);
        } else {
            // Send redirect.
            header("Location: " . $redirect_url);
        }
    } else {
        // Generate form markup and render it.
        $form_id = 'openid_message';
        $form_html = $auth_request->htmlMarkup(getTrustRoot(), getReturnTo(), false, array('id' => $form_id));
        // Display an error if the form markup couldn't be generated;
        // otherwise, render the HTML.
        if (Auth_OpenID::isFailure($form_html)) {
            displayError("Could not redirect to server: " . $form_html->message);
        } else {
            print $form_html;
        }
    }
}
Example #2
0
 function WordPressOpenID_Store()
 {
     global $wpdb;
     $table_prefix = isset($wpdb->base_prefix) ? $wpdb->base_prefix : $wpdb->prefix;
     $this->associations_table_name = $table_prefix . 'openid_associations';
     $this->nonces_table_name = $table_prefix . 'openid_nonces';
     $this->identity_table_name = $table_prefix . 'openid_identities';
     $this->comments_table_name = $table_prefix . 'comments';
     $this->usermeta_table_name = $wpdb->prefix . 'usermeta';
     $conn = new WordPressOpenID_Connection($wpdb);
     parent::Auth_OpenID_MySQLStore($conn, $this->associations_table_name, $this->nonces_table_name);
 }
 function test_mysqlstore()
 {
     // If the mysql extension isn't loaded or loadable, succeed
     // because we can't run the test.
     if (!(extension_loaded('mysql') || @dl('mysql.' . PHP_SHLIB_SUFFIX))) {
         print "(not testing MySQL store)";
         $this->pass();
         return;
     }
     require_once 'Auth/OpenID/MySQLStore.php';
     require_once 'DB.php';
     global $_Auth_OpenID_db_test_host;
     $dsn = array('phptype' => 'mysql', 'username' => 'openid_test', 'password' => '', 'hostspec' => $_Auth_OpenID_db_test_host);
     $db =& DB::connect($dsn);
     if (PEAR::isError($db)) {
         print "MySQL database connection failed: " . $db->getMessage();
         $this->pass();
         return;
     }
     $temp_db_name = _Auth_OpenID_getTmpDbName();
     $result = $db->query("CREATE DATABASE {$temp_db_name}");
     if (PEAR::isError($result)) {
         $this->pass("Error creating MySQL temporary database: " . $result->getMessage());
         return;
     }
     $db->query("USE {$temp_db_name}");
     $store = new Auth_OpenID_MySQLStore($db);
     $store->createTables();
     $this->_testStore($store);
     $this->_testNonce($store);
     $this->_testNonceCleanup($store);
     $db->query("DROP DATABASE {$temp_db_name}");
 }
 function OpenStackIdMySQLStore($connection, $associations_table = null, $nonces_table = null)
 {
     parent::__construct($connection, $associations_table, $nonces_table);
     $this->createTables();
 }
function &getStore()
{
    /*
    $store_path = CACHE_DIR.'openid';
    
    if (!file_exists($store_path) && !mkdir($store_path)) 
    {
    	print "Could not create the FileStore directory '$store_path'. ".
    		" Please check the effective permissions.";
    	exit(0);
    }
    
    $obj = new Auth_OpenID_FileStore ($store_path);
    return $obj;
    */
    $connection = new Neuron_Auth_MySQLConnection();
    $obj = new Auth_OpenID_MySQLStore($connection);
    $obj->createTables();
    return $obj;
}