mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
Added support for password and old_password encryption mechanisms if you're using MySQL
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.2.2@50283 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
b1480d5a56
commit
b09856545d
@ -648,6 +648,15 @@ class Security extends Controller {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Support for MySQL password() and old_password() functions. These aren't recommended unless you need them,
|
||||||
|
// but can be helpful for migrating legacy user-sets into a SilverStripe application.
|
||||||
|
// Since DB::getConn() doesn't exist yet, we need to look at $databaseConfig. Gack!
|
||||||
|
global $databaseConfig;
|
||||||
|
if($databaseConfig['type'] == 'MySQLDatabase') {
|
||||||
|
$result[] = 'password';
|
||||||
|
$result[] = 'old_password';
|
||||||
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -749,6 +758,17 @@ class Security extends Controller {
|
|||||||
$algorithm = self::$encryptionAlgorithm;
|
$algorithm = self::$encryptionAlgorithm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Support for MySQL password() and old_password() authentication
|
||||||
|
if(strtolower($algorithm) == 'password' || strtolower($algorithm) == 'old_password') {
|
||||||
|
$SQL_password = Convert::raw2sql($password);
|
||||||
|
$enc = DB::query("SELECT $algorithm('$SQL_password')")->value();
|
||||||
|
return array(
|
||||||
|
'password' => $enc,
|
||||||
|
'salt' => null,
|
||||||
|
'algorithm' => $algorithm,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// If no salt was provided but we need one we just generate a random one
|
// If no salt was provided but we need one we just generate a random one
|
||||||
if(strlen(trim($salt)) == 0)
|
if(strlen(trim($salt)) == 0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user