mirror of
https://github.com/moparisthebest/user_sql
synced 2024-11-25 02:22:22 -05:00
Add support for current Redmine system
This commit is contained in:
parent
7af5d1e04a
commit
c70b4f04ef
@ -48,7 +48,7 @@ $cfgClass = $ocVersion >= 7 ? 'section' : 'personalblock';
|
|||||||
?> title="Allow changing passwords. Imposes a security risk as password salts are not recreated"></td></tr>
|
?> title="Allow changing passwords. Imposes a security risk as password salts are not recreated"></td></tr>
|
||||||
<tr><td><label for="sql_column_displayname"><?php echo $l -> t('Real Name Column'); ?></label></td><td><input type="text" id="sql_column_displayname" name="sql_column_displayname" value="<?php echo $_['sql_column_displayname']; ?>" /></td></tr>
|
<tr><td><label for="sql_column_displayname"><?php echo $l -> t('Real Name Column'); ?></label></td><td><input type="text" id="sql_column_displayname" name="sql_column_displayname" value="<?php echo $_['sql_column_displayname']; ?>" /></td></tr>
|
||||||
<tr><td><label for="crypt_type"><?php echo $l -> t('Encryption Type'); ?></label></td>
|
<tr><td><label for="crypt_type"><?php echo $l -> t('Encryption Type'); ?></label></td>
|
||||||
<?php $crypt_types = array('md5' => 'MD5', 'md5crypt' => 'MD5 Crypt', 'cleartext' => 'Cleartext', 'mysql_encrypt' => 'mySQL ENCRYPT()', 'system' => 'System (crypt)', 'mysql_password' => 'mySQL PASSWORD()', 'joomla' => 'Joomla MD5 Encryption', 'joomla2' => 'Joomla > 2.5.18 phpass', 'ssha256' => 'Salted SSHA256'); ?>
|
<?php $crypt_types = array('md5' => 'MD5', 'md5crypt' => 'MD5 Crypt', 'cleartext' => 'Cleartext', 'mysql_encrypt' => 'mySQL ENCRYPT()', 'system' => 'System (crypt)', 'mysql_password' => 'mySQL PASSWORD()', 'joomla' => 'Joomla MD5 Encryption', 'joomla2' => 'Joomla > 2.5.18 phpass', 'ssha256' => 'Salted SSHA256', 'redmine' => 'Redmine'); ?>
|
||||||
<td><select id="crypt_type" name="crypt_type">
|
<td><select id="crypt_type" name="crypt_type">
|
||||||
<?php
|
<?php
|
||||||
foreach ($crypt_types as $driver => $name):
|
foreach ($crypt_types as $driver => $name):
|
||||||
|
28
user_sql.php
28
user_sql.php
@ -183,6 +183,20 @@ class OC_USER_SQL extends OC_User_Backend implements OC_User_Interface
|
|||||||
require_once('PasswordHash.php');
|
require_once('PasswordHash.php');
|
||||||
$hasher = new PasswordHash(10, true);
|
$hasher = new PasswordHash(10, true);
|
||||||
$enc_password = $hasher->HashPassword($password);
|
$enc_password = $hasher->HashPassword($password);
|
||||||
|
}
|
||||||
|
// Redmine stores the salt separatedly, this doesn't play nice with the way
|
||||||
|
// we check passwords
|
||||||
|
elseif($this -> crypt_type == 'redmine')
|
||||||
|
{
|
||||||
|
$query = "SELECT salt FROM $this->sql_table WHERE $this->sql_column_username =:uid;";
|
||||||
|
$res = $this->db->prepare($query);
|
||||||
|
$res->bindparam(":uid", $uid);
|
||||||
|
if(!$res->execute())
|
||||||
|
return false;
|
||||||
|
$salt = $res->fetch();
|
||||||
|
if(!$salt)
|
||||||
|
return false;
|
||||||
|
$enc_password = sha1($salt['salt'].sha1($password));
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
$enc_password = $this -> pacrypt($password, $old_password);
|
$enc_password = $this -> pacrypt($password, $old_password);
|
||||||
@ -250,6 +264,20 @@ class OC_USER_SQL extends OC_User_Backend implements OC_User_Interface
|
|||||||
require_once('PasswordHash.php');
|
require_once('PasswordHash.php');
|
||||||
$hasher = new PasswordHash(10, true);
|
$hasher = new PasswordHash(10, true);
|
||||||
$ret = $hasher -> CheckPassword($password, $row[$this -> sql_column_password]);
|
$ret = $hasher -> CheckPassword($password, $row[$this -> sql_column_password]);
|
||||||
|
}
|
||||||
|
// Redmine stores the salt separatedly, this doesn't play nice with the way
|
||||||
|
// we check passwords
|
||||||
|
elseif($this -> crypt_type == 'redmine')
|
||||||
|
{
|
||||||
|
$query = "SELECT salt FROM $this->sql_table WHERE $this->sql_column_username =:uid;";
|
||||||
|
$res = $this->db->prepare($query);
|
||||||
|
$res->bindparam(":uid", $uid);
|
||||||
|
if(!$res->execute())
|
||||||
|
return false;
|
||||||
|
$salt = $res->fetch();
|
||||||
|
if(!$salt)
|
||||||
|
return false;
|
||||||
|
$ret = sha1($salt['salt'].sha1($password)) == $row[$this->sql_column_password];
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
$ret = $this -> pacrypt($password, $row[$this -> sql_column_password]) == $row[$this -> sql_column_password];
|
$ret = $this -> pacrypt($password, $row[$this -> sql_column_password]) == $row[$this -> sql_column_password];
|
||||||
|
Loading…
Reference in New Issue
Block a user