Changeset 1289

Show
Ignore:
Timestamp:
09/09/07 19:14:26 (1 year ago)
Author:
benoitg
Message:
  • Early OpenID support. The auth server can now be used as an identity provider, with your profile page as the identity URL
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wifidog-auth/CHANGELOG

    r1287 r1289  
    11# $Id$ 
     22007-09-09 Benoit GrĂ©goire  <bock@step.polymtl.ca> 
     3        * Early OpenID support.  The auth server can now be used as an identity provider, with your profile page as the identity URL 
     4         
    252007-09-08 Benoit GrĂ©goire  <bock@step.polymtl.ca> 
    36        * Dependencies installation:  Improve layout, add embryo of unified install sytem (currently works for tarballs).  Improve error output. 
  • trunk/wifidog-auth/wifidog/classes/Authenticator.php

    r1249 r1289  
    122122    /** 
    123123     * Get the login interface 
     124     *  @param string $userData=null Array of contextual data optionally sent to the method. 
     125     *  The function must still function if none of it is present. 
     126     * 
     127     *      * This method understands: 
     128     *  $userData['preSelectedUser'] An optional User object. 
    124129     * @return HTML markup 
    125130     */ 
    126     static public function getLoginUI(
     131    static public function getLoginUI($userData=null
    127132    { 
    128133        require_once('classes/SmartyWifidog.php'); 
     134        $networkUserData = null; 
     135        if(!empty($userData['preSelectedUser'])){ 
     136            $selectedUser=$userData['preSelectedUser']; 
     137            $networkUserData['preSelectedObject']=$selectedUser; 
     138        } 
     139        else { 
     140            $selectedUser=null; 
     141        } 
     142         
    129143        $smarty=SmartyWiFiDog::getObject(); 
    130144        // Set network selector 
    131         $smarty->assign('selectNetworkUI', Network::getSelectUI('auth_source')); 
     145        $smarty->assign('selectNetworkUI', Network::getSelectUI('auth_source', $networkUserData)); 
    132146        // Set user details 
    133         $smarty->assign('username', !empty($username) ? $username : ""); 
     147        $smarty->assign('user_id', $selectedUser ? $selectedUser->getId() : ""); 
     148        $smarty->assign('username', $selectedUser ? $selectedUser->getUsername() : ""); 
    134149 
    135150        // Set error message 
     
    145160     * Process the login interface 
    146161     */ 
    147     static public function processLoginUI(&$errmsg
     162    static public function processLoginUI(&$errmsg = null
    148163    { 
    149164        if (!empty($_REQUEST["login_form_submit"])) { 
    150             if (isset($_REQUEST["username"])) { 
     165                    if (isset($_REQUEST["user_id"])) { 
     166                $username = User::getObject($_REQUEST["user_id"])->getUsername(); 
     167            } 
     168            else if (isset($_REQUEST["username"])) { 
    151169                $username = $_REQUEST["username"]; 
    152170            } 
     
    155173                $password = $_REQUEST["password"]; 
    156174            } 
     175             
    157176            // Authenticating the user through the selected auth source. 
    158177            $network = Network::processSelectUI('auth_source'); 
     
    160179            self::$_loginLastError = $errmsg; 
    161180        } 
    162  
    163  
    164181    } 
    165182    /** 
  • trunk/wifidog-auth/wifidog/classes/User.php

    r1285 r1289  
    161161 
    162162    /** Instantiate a user object 
     163     * @param $url The OpenId url 
     164     * @return a User object, or null if none matched 
     165     */ 
     166    public static function getUserByOpenIdUrl($url) { 
     167        $db = AbstractDb::getObject(); 
     168        $object = null; 
     169 
     170        $url_str = $db->escapeString($url); 
     171        $db->execSqlUniqueRes("SELECT user_id FROM users WHERE open_id_url = '$url_str'", $user_rows, false); 
     172 
     173        if ($user_rows != null) { 
     174            $object = self::getObject($user_rows[0]['user_id']); 
     175        } 
     176        return $object; 
     177    } 
     178    /** Instantiate a user object 
    163179     * @param $email The email of the user 
    164180     * @param $account_origin Network:  The account origin 
     
    293309            $profiles=$this->getAllProfiles(); 
    294310            if($profiles){ 
    295                 $html .= "<a href='".BASE_URL_PATH."profile/?profile_user_id=".$this->getId()."' title='".htmlentities(_("View this user's profile."), ENT_QUOTES)."' class='user_nickname'>"; 
     311                $html .= "<a href='".BASE_URL_PATH."profile/?user_id=".$this->getId()."' title='".htmlentities(_("View this user's profile."), ENT_QUOTES)."' class='user_nickname'>"; 
    296312            } 
    297313            if(empty($nickname)) 
     
    311327    } 
    312328 
     329    function getOpenIdUrl() { 
     330        return $this->_row['open_id_url']; 
     331    } 
     332     
    313333    function getUsername() { 
    314334        return $this->_row['username']; 
  • trunk/wifidog-auth/wifidog/include/schema_validate.php

    r1263 r1289  
    4848 * Define current database schema version 
    4949 */ 
    50 define('REQUIRED_SCHEMA_VERSION', 56); 
     50define('REQUIRED_SCHEMA_VERSION', 57); 
    5151/** Used to test a new shecma version before modyfying the database */ 
    5252define('SCHEMA_UPDATE_TEST_MODE', false); 
     
    12911291        $sql .= "CREATE INDEX idx_connections_timestamp_in ON connections (timestamp_in);\n"; 
    12921292     } 
    1293       
     1293 
     1294     $new_schema_version = 57; 
     1295     if ($schema_version < $new_schema_version && $new_schema_version <= $targetSchema) { 
     1296     printUpdateVersion($new_schema_version); 
     1297     $sql .= "\n\nUPDATE schema_info SET value='$new_schema_version' WHERE tag='schema_version';\n"; 
     1298        $sql .= "ALTER TABLE users ADD COLUMN open_id_url text;\n"; 
     1299        $sql .= "CREATE INDEX idx_users_topen_id_url ON users (open_id_url);\n"; 
     1300     } 
    12941301    /* 
    12951302     $new_schema_version = ; 
  • trunk/wifidog-auth/wifidog/install.php

    r1288 r1289  
    170170'tmp/smarty/templates_c', 
    171171'tmp/smarty/cache', 
     172'tmp/openidserver', 
    172173'lib/simplepie', 
    173174'lib/feedpressreview', 
  • trunk/wifidog-auth/wifidog/profile/index.php

    r1253 r1289  
    6868 * Start general request parameter processing section 
    6969 */ 
    70 if (!empty ($_REQUEST['profile_user_id'])) { 
     70if (!empty ($_REQUEST['user_id'])) { 
    7171    try { 
    72         $profile_user = User :: getObject($_REQUEST['profile_user_id']); 
     72        $profile_user = User :: getObject($_REQUEST['user_id']); 
    7373        if(!empty($profile_user)) { 
    7474                $profiles = $profile_user->getAllProfiles(); 
     
    9797$ui = MainUI::getObject(); 
    9898$ui->setTitle(_("User profile")); 
     99if(Dependency::check('php-openid')){ 
     100    require_once('classes/OpenIdServerWifidog.php'); 
     101$ui->appendHtmlHeadContent("<link rel='openid.server' href='".OpenIdServerWifidog::getOpenIdServerUrl()."' />"); 
     102} 
    99103$ui->setPageName('profile'); 
    100104//$ui->addContent('left_area_middle', $tool_html); 
  • trunk/wifidog-auth/wifidog/templates/classes/Authenticator_getLoginForm.tpl

    r1249 r1289  
    4646 
    4747*} 
    48  
    4948                <h1>{"Login or Signup here"|_}:</h1> 
    50  
    51  
    5249                        <p> 
    5350            {$selectNetworkUI} 
    5451            </p> 
    55  
    56             {"Username (or email)"|_}:<br/> 
    57             <input type="text" name="username" id="form_username" tabindex="1" value="{$username}" size="20" /><br/> 
     52                        {if $user_id} 
     53                            <input type="hidden" name="user_id" id="form_user_id" value="{$user_id}"/> 
     54                        {else} 
     55                {"Username (or email)"|_}:<br/> 
     56                <input type="text" name="username" id="form_username" tabindex="1" value="{$username}" size="20" /><br/> 
     57            {/if} 
    5858            {"Password"|_}:<br/> 
    5959            <input type="password" name="password" id="form_password" tabindex="2" size="20" /><br/>