WIP: Hash rework

This commit is contained in:
Matej Bačo
2022-05-04 15:00:36 +00:00
parent 55c8caf0cc
commit 7c45ca4d0f
4 changed files with 8 additions and 7 deletions
+4 -3
View File
@@ -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'],
],
+1 -1
View File
@@ -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')
+1 -1
View File
@@ -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.
+2 -2
View File
@@ -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