diff --git a/app/controllers/api/users.php b/app/controllers/api/users.php index 407bc1eaab..028c9373ac 100644 --- a/app/controllers/api/users.php +++ b/app/controllers/api/users.php @@ -63,7 +63,7 @@ function createUser(string $hash, mixed $hashOptions, string $userId, ?string $e 'status' => true, 'password' => (!empty($password)) ? ($hash === 'plaintext' ? Auth::passwordHash($password, $hash, $hashOptionsObject) : $password) : null, 'hash' => $hash === 'plaintext' ? Auth::DEFAULT_ALGO : $hash, - 'hashOptions' => $hash === 'plaintext' ? Auth::DEFAULT_ALGO_OPTIONS : $hashOptions, + 'hashOptions' => $hash === 'plaintext' ? Auth::DEFAULT_ALGO_OPTIONS : $hashOptionsObject + ['type' => $hash], 'passwordUpdate' => (!empty($password)) ? DateTime::now() : null, 'registration' => DateTime::now(), 'reset' => false, diff --git a/src/Appwrite/Auth/Auth.php b/src/Appwrite/Auth/Auth.php index dbe74af0d2..cf7acd8750 100644 --- a/src/Appwrite/Auth/Auth.php +++ b/src/Appwrite/Auth/Auth.php @@ -29,7 +29,7 @@ class Auth ]; public const DEFAULT_ALGO = 'argon2'; - public const DEFAULT_ALGO_OPTIONS = ['memoryCost' => 2048, 'timeCost' => 4, 'threads' => 3]; + public const DEFAULT_ALGO_OPTIONS = ['type' => 'argon2', 'memoryCost' => 2048, 'timeCost' => 4, 'threads' => 3]; /** * User Roles. diff --git a/src/Appwrite/Utopia/Response/Model/AlgoArgon2.php b/src/Appwrite/Utopia/Response/Model/AlgoArgon2.php index 2e2575fdef..3e162bb905 100644 --- a/src/Appwrite/Utopia/Response/Model/AlgoArgon2.php +++ b/src/Appwrite/Utopia/Response/Model/AlgoArgon2.php @@ -11,6 +11,12 @@ class AlgoArgon2 extends Model { // No options if imported. If hashed by Appwrite, following configuration is available: $this + ->addRule('type', [ + 'type' => self::TYPE_STRING, + 'description' => 'Algo type.', + 'default' => 'argon2', + 'example' => 'argon2', + ]) ->addRule('memoryCost', [ 'type' => self::TYPE_INTEGER, 'description' => 'Memory used to compute hash.', diff --git a/src/Appwrite/Utopia/Response/Model/AlgoBcrypt.php b/src/Appwrite/Utopia/Response/Model/AlgoBcrypt.php index d8d4cf763b..709dea1a41 100644 --- a/src/Appwrite/Utopia/Response/Model/AlgoBcrypt.php +++ b/src/Appwrite/Utopia/Response/Model/AlgoBcrypt.php @@ -10,6 +10,13 @@ class AlgoBcrypt extends Model public function __construct() { // No options, because this can only be imported, and verifying doesnt require any configuration + $this + ->addRule('type', [ + 'type' => self::TYPE_STRING, + 'description' => 'Algo type.', + 'default' => 'bcrypt', + 'example' => 'bcrypt', + ]); } /** diff --git a/src/Appwrite/Utopia/Response/Model/AlgoMd5.php b/src/Appwrite/Utopia/Response/Model/AlgoMd5.php index fe340f9e90..509ee70c31 100644 --- a/src/Appwrite/Utopia/Response/Model/AlgoMd5.php +++ b/src/Appwrite/Utopia/Response/Model/AlgoMd5.php @@ -10,6 +10,14 @@ class AlgoMd5 extends Model public function __construct() { // No options, because this can only be imported, and verifying doesnt require any configuration + + $this + ->addRule('type', [ + 'type' => self::TYPE_STRING, + 'description' => 'Algo type.', + 'default' => 'md5', + 'example' => 'md5', + ]); } /** diff --git a/src/Appwrite/Utopia/Response/Model/AlgoPhpass.php b/src/Appwrite/Utopia/Response/Model/AlgoPhpass.php index 45e95ccfe5..f16792086e 100644 --- a/src/Appwrite/Utopia/Response/Model/AlgoPhpass.php +++ b/src/Appwrite/Utopia/Response/Model/AlgoPhpass.php @@ -10,6 +10,14 @@ class AlgoPhpass extends Model public function __construct() { // No options, because this can only be imported, and verifying doesnt require any configuration + + $this + ->addRule('type', [ + 'type' => self::TYPE_STRING, + 'description' => 'Algo type.', + 'default' => 'phpass', + 'example' => 'phpass', + ]); } /** diff --git a/src/Appwrite/Utopia/Response/Model/AlgoScrypt.php b/src/Appwrite/Utopia/Response/Model/AlgoScrypt.php index ca3ab3dd70..4dda297d71 100644 --- a/src/Appwrite/Utopia/Response/Model/AlgoScrypt.php +++ b/src/Appwrite/Utopia/Response/Model/AlgoScrypt.php @@ -10,6 +10,12 @@ class AlgoScrypt extends Model public function __construct() { $this + ->addRule('type', [ + 'type' => self::TYPE_STRING, + 'description' => 'Algo type.', + 'default' => 'scrypt', + 'example' => 'scrypt', + ]) ->addRule('costCpu', [ 'type' => self::TYPE_INTEGER, 'description' => 'CPU complexity of computed hash.', diff --git a/src/Appwrite/Utopia/Response/Model/AlgoScryptModified.php b/src/Appwrite/Utopia/Response/Model/AlgoScryptModified.php index eb8e28ee23..40b9df1dad 100644 --- a/src/Appwrite/Utopia/Response/Model/AlgoScryptModified.php +++ b/src/Appwrite/Utopia/Response/Model/AlgoScryptModified.php @@ -10,6 +10,12 @@ class AlgoScryptModified extends Model public function __construct() { $this + ->addRule('type', [ + 'type' => self::TYPE_STRING, + 'description' => 'Algo type.', + 'default' => 'scryptMod', + 'example' => 'scryptMod', + ]) ->addRule('salt', [ 'type' => self::TYPE_STRING, 'description' => 'Salt used to compute hash.', diff --git a/src/Appwrite/Utopia/Response/Model/AlgoSha.php b/src/Appwrite/Utopia/Response/Model/AlgoSha.php index ab83766f8d..2a0893adc4 100644 --- a/src/Appwrite/Utopia/Response/Model/AlgoSha.php +++ b/src/Appwrite/Utopia/Response/Model/AlgoSha.php @@ -10,6 +10,14 @@ class AlgoSha extends Model public function __construct() { // No options, because this can only be imported, and verifying doesnt require any configuration + + $this + ->addRule('type', [ + 'type' => self::TYPE_STRING, + 'description' => 'Algo type.', + 'default' => 'sha', + 'example' => 'sha', + ]); } /**