mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-14 12:30:49 +08:00
Challenge-Response Authentication
This commit is contained in:
@@ -61,10 +61,15 @@ class NexusWebUserProvider implements UserProvider
|
||||
*/
|
||||
public function retrieveByCredentials(array $credentials)
|
||||
{
|
||||
if (!empty($credentials['c_secure_uid'])) {
|
||||
$b_id = base64($credentials["c_secure_uid"],false);
|
||||
return $this->query->find($b_id);
|
||||
list($tokenJson, $signature) = explode('.', base64_decode($credentials["c_secure_pass"]));
|
||||
if (empty($tokenJson) || empty($signature)) {
|
||||
return null;
|
||||
}
|
||||
$tokenData = json_decode($tokenJson, true);
|
||||
if (!isset($tokenData['user_id'])) {
|
||||
return null;
|
||||
}
|
||||
return $this->retrieveById($tokenData['user_id']);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,20 +81,9 @@ class NexusWebUserProvider implements UserProvider
|
||||
*/
|
||||
public function validateCredentials(Authenticatable $user, array $credentials)
|
||||
{
|
||||
if ($credentials["c_secure_login"] == base64("yeah")) {
|
||||
/**
|
||||
* Not IP related
|
||||
* @since 1.8.0
|
||||
*/
|
||||
if ($credentials["c_secure_pass"] != md5($user->passhash)) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if ($credentials["c_secure_pass"] !== md5($user->passhash)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
list($tokenJson, $signature) = explode('.', base64_decode($credentials["c_secure_pass"]));
|
||||
$expectedSignature = hash_hmac('sha256', $tokenJson, $user->auth_key);
|
||||
return hash_equals($expectedSignature, $signature);
|
||||
}
|
||||
|
||||
public function rehashPasswordIfRequired(Authenticatable $user, #[\SensitiveParameter] array $credentials, bool $force = false)
|
||||
|
||||
Reference in New Issue
Block a user