mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
Address password policy review
This commit is contained in:
@@ -37,7 +37,6 @@ const APP_LIMIT_COMPRESSION = 20_000_000; //20MB
|
||||
const APP_LIMIT_ARRAY_PARAMS_SIZE = 100; // Default maximum of how many elements can there be in API parameter that expects array value
|
||||
const APP_LIMIT_ARRAY_LABELS_SIZE = 1000; // Default maximum of how many labels elements can there be in API parameter that expects array value
|
||||
const APP_LIMIT_ARRAY_ELEMENT_SIZE = 4096; // Default maximum length of element in array parameter represented by maximum URL length.
|
||||
const APP_LIMIT_USER_SESSIONS_DEFAULT = 10; // Default maximum sessions allowed per user
|
||||
const APP_LIMIT_SUBQUERY = 1000;
|
||||
const APP_LIMIT_SUBSCRIBERS_SUBQUERY = 1_000_000;
|
||||
const APP_LIMIT_WRITE_RATE_DEFAULT = 60; // Default maximum write rate per rate period
|
||||
|
||||
@@ -80,7 +80,7 @@ class PasswordPolicy extends Password
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->requireSpecialChar && !\preg_match("/[!\"#$%&'()*+,\-.\/:;<=>?@[\\\\\]^_`{|}~]/", $value)) {
|
||||
if ($this->requireSpecialChar && !\preg_match('/[^\p{L}\p{N}\s]/u', $value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ class Create extends Action
|
||||
$auth = Config::getParam('auth', []);
|
||||
$auths = [
|
||||
'limit' => 0,
|
||||
'maxSessions' => \APP_LIMIT_USER_SESSIONS_DEFAULT,
|
||||
'maxSessions' => 0,
|
||||
'passwordPolicy' => [
|
||||
'minLength' => 8,
|
||||
'requireUppercase' => false,
|
||||
|
||||
@@ -523,7 +523,7 @@ class Project extends Model
|
||||
|
||||
$document->setAttribute('authLimit', $authValues['limit'] ?? 0);
|
||||
$document->setAttribute('authDuration', $authValues['duration'] ?? TOKEN_EXPIRATION_LOGIN_LONG);
|
||||
$document->setAttribute('authSessionsLimit', $authValues['maxSessions'] ?? \APP_LIMIT_USER_SESSIONS_DEFAULT);
|
||||
$document->setAttribute('authSessionsLimit', $authValues['maxSessions'] ?? 0);
|
||||
$document->setAttribute('authPasswordHistory', $authValues['passwordHistory'] ?? 0);
|
||||
$document->setAttribute('authPasswordPolicyMinLength', $passwordPolicy['minLength'] ?? 8);
|
||||
$document->setAttribute('authPasswordPolicyRequireUppercase', $passwordPolicy['requireUppercase'] ?? false);
|
||||
|
||||
@@ -31,6 +31,7 @@ class PasswordPolicyTest extends TestCase
|
||||
$this->assertFalse($validator->isValid('PasswordOnly!'));
|
||||
$this->assertFalse($validator->isValid('Password1234'));
|
||||
$this->assertTrue($validator->isValid('Password123!'));
|
||||
$this->assertTrue($validator->isValid('Password123€'));
|
||||
}
|
||||
|
||||
public function testAllowEmpty(): void
|
||||
|
||||
Reference in New Issue
Block a user