mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
WIP: Hash rework
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
use Appwrite\Auth\Auth;
|
||||
use Utopia\Config\Config;
|
||||
use Utopia\Database\Database;
|
||||
|
||||
@@ -999,7 +1000,7 @@ $collections = [
|
||||
'size' => 256,
|
||||
'signed' => true,
|
||||
'required' => false,
|
||||
'default' => 'bcrypt',
|
||||
'default' => Auth::DEFAULT_ALGO,
|
||||
'array' => false,
|
||||
'filters' => [],
|
||||
],
|
||||
@@ -1007,10 +1008,10 @@ $collections = [
|
||||
'$id' => 'hashOptions', // Configuration of hashing algorithm
|
||||
'type' => Database::VAR_STRING,
|
||||
'format' => '',
|
||||
'size' => 16384,
|
||||
'size' => 65535,
|
||||
'signed' => true,
|
||||
'required' => false,
|
||||
'default' => '{}',
|
||||
'default' => Auth::DEFAULT_ALGO_OPTIONS,
|
||||
'array' => false,
|
||||
'filters' => ['json'],
|
||||
],
|
||||
|
||||
@@ -50,7 +50,7 @@ App::post('/v1/account')
|
||||
->param('password', '', new Password(), 'User password. Must be at least 8 chars.')
|
||||
->param('name', '', new Text(128), 'User name. Max length: 128 chars.', true)
|
||||
->param('hash', Auth::DEFAULT_ALGO, new WhiteList(\array_keys(Auth::SUPPORTED_ALGOS)), 'Hashing algorithm for password. Allowed values are: \'' . \implode('\', \'', \array_keys(Auth::SUPPORTED_ALGOS)) . '\'. The default value is \'' . Auth::DEFAULT_ALGO . '\'.', true)
|
||||
->param('hashOptions', Auth::DEFAULT_ALGO_OPTIONS, new Text(16384), 'Configuration of hashing algorithm. If left empty, default configuration is used.', true)
|
||||
->param('hashOptions', Auth::DEFAULT_ALGO_OPTIONS, new Assoc(), 'Configuration of hashing algorithm. If left empty, default configuration is used.', true)
|
||||
->inject('request')
|
||||
->inject('response')
|
||||
->inject('project')
|
||||
|
||||
@@ -25,7 +25,7 @@ class Auth
|
||||
];
|
||||
|
||||
const DEFAULT_ALGO = 'argon2';
|
||||
const DEFAULT_ALGO_OPTIONS = ['memory_cost' => 2048, 'time_cost' => 4, 'threads' => 3];
|
||||
const DEFAULT_ALGO_OPTIONS = (object) array('memory_cost' => 2048, 'time_cost' => 4, 'threads' => 3);
|
||||
|
||||
/**
|
||||
* User Roles.
|
||||
|
||||
@@ -5,12 +5,12 @@ namespace Appwrite\Auth\Hash;
|
||||
use Appwrite\Auth\Hash;
|
||||
|
||||
/*
|
||||
* Argon2 accepted options:
|
||||
* PlainText accepted options:
|
||||
* none
|
||||
*
|
||||
* Refference: None. Simple plain text stored.
|
||||
*/
|
||||
class Argon2 extends Hash
|
||||
class PlainText extends Hash
|
||||
{
|
||||
/**
|
||||
* @param string $password Input password to hash
|
||||
|
||||
Reference in New Issue
Block a user