mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
Add type property to hash algorithms to allow resolving union type implementation
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.',
|
||||
|
||||
@@ -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',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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.',
|
||||
|
||||
@@ -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.',
|
||||
|
||||
@@ -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',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user