Changeset e17553d in github


Ignore:
Timestamp:
Nov 30, 2010 8:43:04 AM (2 years ago)
Author:
alecpl <alec@…>
Branches:
master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
Children:
489ffbd
Parents:
fd371a51
Message:
  • Add 'login_lc' config option for case-insensitive authentication (#1487113)
  • Make username comparison case sensitive on MySQL
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • CHANGELOG

    rfd371a51 re17553d  
    44- Plugin API: Add 'pass' argument in 'authenticate' hook (#1487134) 
    55- Fix attachments of type message/rfc822 are not listed on attachments list 
     6- Add 'login_lc' config option for case-insensitive authentication (#1487113) 
    67 
    78RELEASE 0.5-BETA 
  • config/main.inc.php.dist

    rfbe24e9 re17553d  
    183183// Allow browser-autocompletion on login form 
    184184$rcmail_config['login_autocomplete'] = false; 
     185 
     186// If users authentication is not case sensitive this must be enabled. 
     187// You can also use it to force conversion of logins to lower case. 
     188$rcmail_config['login_lc'] = false; 
    185189 
    186190// automatically create a new Roundcube user when log-in the first time. 
  • program/include/rcmail.php

    r9016a84 re17553d  
    679679    } 
    680680 
     681    // Convert username to lowercase. If IMAP backend 
     682    // is case-insensitive we need to store always the same username (#1487113) 
     683    if ($config['login_lc']) { 
     684      $username = mb_strtolower($username); 
     685    } 
     686 
    681687    // try to resolve email address from virtuser table 
    682     if (strpos($username, '@')) 
    683       if ($virtuser = rcube_user::email2user($username)) 
    684         $username = $virtuser; 
     688    if (strpos($username, '@') && ($virtuser = rcube_user::email2user($username))) { 
     689      $username = $virtuser; 
     690    } 
    685691 
    686692    // Here we need IDNA ASCII 
     
    705711      // try with lowercase 
    706712      $username_lc = mb_strtolower($username); 
    707       if ($username_lc != $username && ($imap_login = $this->imap->connect($host, $username_lc, $pass, $imap_port, $imap_ssl))) 
    708         $username = $username_lc; 
     713      if ($username_lc != $username) { 
     714        // try to find user record again -> overwrite username 
     715        if (!$user && ($user = rcube_user::query($username_lc, $host))) 
     716          $username_lc = $user->data['username']; 
     717 
     718        if ($imap_login = $this->imap->connect($host, $username_lc, $pass, $imap_port, $imap_ssl)) 
     719          $username = $username_lc; 
     720      } 
    709721    } 
    710722 
  • program/include/rcube_user.php

    r5c461ba re17553d  
    359359        $dbh = rcmail::get_instance()->get_dbh(); 
    360360 
     361        // use BINARY (case-sensitive) comparison on MySQL, other engines are case-sensitive 
     362        $prefix = preg_match('/^mysql/', $dbh->db_provider) ? 'BINARY ' : ''; 
     363 
    361364        // query for matching user name 
    362365        $query = "SELECT * FROM ".get_table_name('users')." WHERE mail_host = ? AND %s = ?"; 
    363         $sql_result = $dbh->query(sprintf($query, 'username'), $host, $user); 
     366 
     367        $sql_result = $dbh->query(sprintf($query, $prefix.'username'), $host, $user); 
    364368 
    365369        // query for matching alias 
    366370        if (!($sql_arr = $dbh->fetch_assoc($sql_result))) { 
    367             $sql_result = $dbh->query(sprintf($query, 'alias'), $host, $user); 
     371            $sql_result = $dbh->query(sprintf($query, $prefix.'alias'), $host, $user); 
    368372            $sql_arr = $dbh->fetch_assoc($sql_result); 
    369373        } 
Note: See TracChangeset for help on using the changeset viewer.