Beispiel #1
0
 public static function authenticate($username, $password)
 {
     if (!empty($username) && ($authSource = AuthUserTable::getAuthSource($username))) {
         Console::debug("Found authentication source {$authSource} for {$username}");
         $driverList = array(AuthDriverManager::getDriver($authSource));
     } else {
         // avoid issues with session collision when many users connect from
         // the same computer at the same time with the same browser session !
         if (AuthUserTable::userExists($username)) {
             self::setFailureMessage(get_lang("There is already an account with this username."));
             return false;
         }
         $authSource = null;
         $driverList = AuthDriverManager::getRegisteredDrivers();
     }
     foreach ($driverList as $driver) {
         $driver->setAuthenticationParams($username, $password);
         if ($driver->authenticate()) {
             $uid = AuthUserTable::registered($username, $driver->getAuthSource());
             if ($uid) {
                 if ($driver->userUpdateAllowed()) {
                     $userAttrList = $driver->getFilteredUserData();
                     if (isset($userAttrList['loginName'])) {
                         $newUserName = $userAttrList['loginName'];
                         if (!get_conf('claro_authUsernameCaseSensitive', true)) {
                             $newUsername = strtolower($newUserName);
                             $username = strtolower($username);
                         }
                         // avoid session collisions !
                         if ($username != $newUserName) {
                             Console::error("EXTAUTH ERROR : try to overwrite an existing user {$username} with another one" . var_export($userAttrList, true));
                         } else {
                             AuthUserTable::updateUser($uid, $userAttrList);
                             Console::info("EXTAUTH INFO : update user {$uid} {$username} with " . var_export($userAttrList, true));
                         }
                     } else {
                         Console::error("EXTAUTH ERROR : no loginName given for user {$username} by authSource " . $driver->getAuthSource());
                     }
                 }
                 return Claro_CurrentUser::getInstance($uid, true);
             } elseif ($driver->userRegistrationAllowed()) {
                 // duplicate code here to avoid issue with multiple requests on a busy server !
                 if (AuthUserTable::userExists($username)) {
                     self::setFailureMessage(get_lang("There is already an account with this username."));
                     return false;
                 }
                 $uid = AuthUserTable::createUser($driver->getUserData());
                 return Claro_CurrentUser::getInstance($uid, true);
             }
         } elseif ($authSource) {
             self::setFailureMessage($driver->getFailureMessage());
         }
     }
     // authentication failed
     return false;
 }
Beispiel #2
0
                </label>
            </dt>
            <dd>
                
                <?php 
    if (in_array('authSource', $this->editableFields)) {
        ?>
                
                    <select id="authSourceSelector" name="authSource">
                    
                    <?php 
        $authSourceInOptions = false;
        ?>
                        
                    <?php 
        foreach (AuthDriverManager::getRegisteredDrivers() as $authDriver) {
            ?>
                        
                        <?php 
            if ($authDriver->getAuthSource() == $this->data['authSource']) {
                ?>
                        
                            <option value="<?php 
                echo $authDriver->getAuthSource();
                ?>
" selected="selected">
                                <?php 
                echo $authDriver->getAuthSource();
                ?>
                            </option>