diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 68ab657213..a74afaf9f0 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -33,7 +33,7 @@ jobs: id: meta uses: docker/metadata-action@030e881283bb7a6894de51c315a6bfe6a94e05cf # v6.0.0 with: - images: appwrite/cloud + images: appwrite/ce tags: | type=ref,event=tag diff --git a/app/config/sdks.php b/app/config/sdks.php index e29b28690f..f3d89db3c2 100644 --- a/app/config/sdks.php +++ b/app/config/sdks.php @@ -156,6 +156,25 @@ return [ 'gitBranch' => 'dev', 'changelog' => \realpath(__DIR__ . '/../../docs/sdks/react-native/CHANGELOG.md'), ], + [ + 'key' => 'unity', + 'name' => 'Unity', + 'version' => '0.1.0', + 'url' => 'https://github.com/appwrite/sdk-for-unity', + 'package' => 'https://github.com/appwrite/sdk-for-unity', + 'enabled' => true, + 'beta' => true, + 'dev' => true, + 'hidden' => false, + 'family' => APP_SDK_PLATFORM_CLIENT, + 'prism' => 'csharp', + 'source' => \realpath(__DIR__ . '/../sdks/client-unity'), + 'gitUrl' => 'git@github.com:appwrite/sdk-for-unity.git', + 'gitRepoName' => 'sdk-for-unity', + 'gitUserName' => 'appwrite', + 'gitBranch' => 'dev', + 'changelog' => \realpath(__DIR__ . '/../../docs/sdks/unity/CHANGELOG.md'), + ], [ 'key' => 'graphql', 'name' => 'GraphQL', diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index 789fce6d71..74501671ad 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -7,6 +7,7 @@ use Appwrite\Auth\Phrase; use Appwrite\Auth\Validator\Password; use Appwrite\Auth\Validator\PasswordDictionary; use Appwrite\Auth\Validator\PasswordHistory; +use Appwrite\Auth\Validator\PasswordStrength; use Appwrite\Auth\Validator\PersonalData; use Appwrite\Auth\Validator\Phone; use Appwrite\Bus\Events\SessionCreated; @@ -71,6 +72,7 @@ use Utopia\Platform\Enum; use Utopia\Storage\Validator\FileName; use Utopia\System\System; use Utopia\Validator; +use Utopia\Validator\AllOf; use Utopia\Validator\ArrayList; use Utopia\Validator\Assoc; use Utopia\Validator\Boolean; @@ -255,7 +257,7 @@ Http::post('/v1/account') ->label('abuse-limit', 10) ->param('userId', '', fn (Database $dbForProject) => new CustomId(false, $dbForProject->getAdapter()->getMaxUIDLength()), 'User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can\'t start with a special char. Max length is 36 chars.', false, ['dbForProject']) ->param('email', '', new EmailValidator(), 'User email.') - ->param('password', '', fn ($project, $passwordsDictionary) => new PasswordDictionary($passwordsDictionary, $project->getAttribute('auths', [])['passwordDictionary'] ?? false), 'New user password. Must be between 8 and 256 chars.', false, ['project', 'passwordsDictionary']) + ->param('password', '', fn ($project, $passwordsDictionary) => new AllOf([new PasswordStrength($project->getAttribute('auths', [])['passwordStrength'] ?? []), new PasswordDictionary($passwordsDictionary, enabled: $project->getAttribute('auths', [])['passwordDictionary'] ?? false)], Validator::TYPE_STRING), 'New user password. Must be between 8 and 256 chars.', false, ['project', 'passwordsDictionary']) ->param('name', '', new Text(128), 'User name. Max length: 128 chars.', true) ->inject('request') ->inject('response') @@ -3271,8 +3273,8 @@ Http::patch('/v1/account/password') contentType: ContentType::JSON )) ->label('abuse-limit', 10) - ->param('password', '', fn ($project, $passwordsDictionary) => new PasswordDictionary($passwordsDictionary, $project->getAttribute('auths', [])['passwordDictionary'] ?? false), 'New user password. Must be at least 8 chars.', false, ['project', 'passwordsDictionary']) - ->param('oldPassword', '', new Password(), 'Current user password. Must be at least 8 chars.', true) + ->param('password', '', fn ($project, $passwordsDictionary) => new AllOf([new PasswordStrength($project->getAttribute('auths', [])['passwordStrength'] ?? []), new PasswordDictionary($passwordsDictionary, enabled: $project->getAttribute('auths', [])['passwordDictionary'] ?? false)], Validator::TYPE_STRING), 'New user password. Must be at least 8 chars.', false, ['project', 'passwordsDictionary']) + ->param('oldPassword', '', new Text(256, 0), 'Current user password. Max length: 256 chars.', true) ->inject('response') ->inject('user') ->inject('project') @@ -3888,7 +3890,7 @@ Http::put('/v1/account/recovery') ->label('abuse-key', 'url:{url},userId:{param-userId}') ->param('userId', '', fn (Database $dbForProject) => new UID($dbForProject->getAdapter()->getMaxUIDLength()), 'User ID.', false, ['dbForProject']) ->param('secret', '', new Text(256), 'Valid reset token.') - ->param('password', '', fn ($project, $passwordsDictionary) => new PasswordDictionary($passwordsDictionary, $project->getAttribute('auths', [])['passwordDictionary'] ?? false), 'New user password. Must be between 8 and 256 chars.', false, ['project', 'passwordsDictionary']) + ->param('password', '', fn ($project, $passwordsDictionary) => new AllOf([new PasswordStrength($project->getAttribute('auths', [])['passwordStrength'] ?? []), new PasswordDictionary($passwordsDictionary, enabled: $project->getAttribute('auths', [])['passwordDictionary'] ?? false)], Validator::TYPE_STRING), 'New user password. Must be between 8 and 256 chars.', false, ['project', 'passwordsDictionary']) ->inject('response') ->inject('user') ->inject('dbForProject') diff --git a/app/controllers/api/users.php b/app/controllers/api/users.php index 19cff6aa01..d2db2fc69e 100644 --- a/app/controllers/api/users.php +++ b/app/controllers/api/users.php @@ -6,6 +6,7 @@ use Appwrite\Auth\MFA\Type\TOTP; use Appwrite\Auth\Validator\Password; use Appwrite\Auth\Validator\PasswordDictionary; use Appwrite\Auth\Validator\PasswordHistory; +use Appwrite\Auth\Validator\PasswordStrength; use Appwrite\Auth\Validator\PersonalData; use Appwrite\Auth\Validator\Phone; use Appwrite\Deletes\Identities as DeleteIdentities; @@ -65,6 +66,8 @@ use Utopia\Http\Http; use Utopia\Locale\Locale; use Utopia\Platform\Enum; use Utopia\System\System; +use Utopia\Validator; +use Utopia\Validator\AllOf; use Utopia\Validator\ArrayList; use Utopia\Validator\Assoc; use Utopia\Validator\Boolean; @@ -280,7 +283,7 @@ Http::post('/v1/users') ->param('userId', '', fn (Database $dbForProject) => new CustomId(false, $dbForProject->getAdapter()->getMaxUIDLength()), 'User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can\'t start with a special char. Max length is 36 chars.', false, ['dbForProject']) ->param('email', null, new Nullable(new EmailValidator()), 'User email.', true) ->param('phone', null, new Nullable(new Phone()), 'Phone number. Format this number with a leading \'+\' and a country code, e.g., +16175551212.', true) - ->param('password', '', fn ($project, $passwordsDictionary) => new PasswordDictionary($passwordsDictionary, $project->getAttribute('auths', [])['passwordDictionary'] ?? false), 'Plain text user password. Must be at least 8 chars.', true, ['project', 'passwordsDictionary']) + ->param('password', '', fn ($project, $passwordsDictionary) => new AllOf([new PasswordStrength($project->getAttribute('auths', [])['passwordStrength'] ?? []), new PasswordDictionary($passwordsDictionary, enabled: $project->getAttribute('auths', [])['passwordDictionary'] ?? false)], Validator::TYPE_STRING), 'Plain text user password. Must be at least 8 chars.', true, ['project', 'passwordsDictionary']) ->param('name', '', new Text(128), 'User name. Max length: 128 chars.', true) ->inject('response') ->inject('project') @@ -1431,7 +1434,7 @@ Http::patch('/v1/users/:userId/password') ] )) ->param('userId', '', fn (Database $dbForProject) => new UID($dbForProject->getAdapter()->getMaxUIDLength()), 'User ID.', false, ['dbForProject']) - ->param('password', '', fn ($project, $passwordsDictionary) => new PasswordDictionary($passwordsDictionary, enabled: $project->getAttribute('auths', [])['passwordDictionary'] ?? false, allowEmpty: true), 'New user password. Must be at least 8 chars.', false, ['project', 'passwordsDictionary']) + ->param('password', '', fn ($project, $passwordsDictionary) => new AllOf([new PasswordStrength($project->getAttribute('auths', [])['passwordStrength'] ?? [], allowEmpty: true), new PasswordDictionary($passwordsDictionary, enabled: $project->getAttribute('auths', [])['passwordDictionary'] ?? false, allowEmpty: true)], Validator::TYPE_STRING), 'New user password. Must be at least 8 chars.', false, ['project', 'passwordsDictionary']) ->inject('response') ->inject('project') ->inject('dbForProject') diff --git a/app/init/models.php b/app/init/models.php index 08ebc3af23..d0f665bb4e 100644 --- a/app/init/models.php +++ b/app/init/models.php @@ -168,6 +168,7 @@ use Appwrite\Utopia\Response\Model\PolicyMembershipPrivacy; use Appwrite\Utopia\Response\Model\PolicyPasswordDictionary; use Appwrite\Utopia\Response\Model\PolicyPasswordHistory; use Appwrite\Utopia\Response\Model\PolicyPasswordPersonalData; +use Appwrite\Utopia\Response\Model\PolicyPasswordStrength; use Appwrite\Utopia\Response\Model\PolicySessionAlert; use Appwrite\Utopia\Response\Model\PolicySessionDuration; use Appwrite\Utopia\Response\Model\PolicySessionInvalidation; @@ -460,6 +461,7 @@ Response::setModel(new OAuth2Microsoft()); Response::setModel(new OAuth2ProviderList()); Response::setModel(new PolicyPasswordDictionary()); Response::setModel(new PolicyPasswordHistory()); +Response::setModel(new PolicyPasswordStrength()); Response::setModel(new PolicyPasswordPersonalData()); Response::setModel(new PolicySessionAlert()); Response::setModel(new PolicySessionDuration()); diff --git a/composer.lock b/composer.lock index 69c82d96d9..eb74739408 100644 --- a/composer.lock +++ b/composer.lock @@ -8,16 +8,16 @@ "packages": [ { "name": "adhocore/jwt", - "version": "1.1.3", + "version": "v1.1.4", "source": { "type": "git", "url": "https://github.com/adhocore/php-jwt.git", - "reference": "ad417603d9d45578b6af2089ad5b78f101c82367" + "reference": "b7055ae9024a6627f19f9873b5db19b0f1dcc4e7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/adhocore/php-jwt/zipball/ad417603d9d45578b6af2089ad5b78f101c82367", - "reference": "ad417603d9d45578b6af2089ad5b78f101c82367", + "url": "https://api.github.com/repos/adhocore/php-jwt/zipball/b7055ae9024a6627f19f9873b5db19b0f1dcc4e7", + "reference": "b7055ae9024a6627f19f9873b5db19b0f1dcc4e7", "shasum": "" }, "require": { @@ -53,7 +53,7 @@ ], "support": { "issues": "https://github.com/adhocore/php-jwt/issues", - "source": "https://github.com/adhocore/php-jwt/tree/1.1.3" + "source": "https://github.com/adhocore/php-jwt/tree/v1.1.4" }, "funding": [ { @@ -65,7 +65,7 @@ "type": "github" } ], - "time": "2025-02-18T01:00:50+00:00" + "time": "2026-05-30T07:58:15+00:00" }, { "name": "appwrite/appwrite", @@ -2571,16 +2571,16 @@ }, { "name": "spomky-labs/otphp", - "version": "11.4.2", + "version": "11.4.3", "source": { "type": "git", "url": "https://github.com/Spomky-Labs/otphp.git", - "reference": "2a1b503fd1c1a5c751ab3c5cd37f2d2d26ab74ad" + "reference": "46663316285bf1f001a31584213b327494b00ae7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Spomky-Labs/otphp/zipball/2a1b503fd1c1a5c751ab3c5cd37f2d2d26ab74ad", - "reference": "2a1b503fd1c1a5c751ab3c5cd37f2d2d26ab74ad", + "url": "https://api.github.com/repos/Spomky-Labs/otphp/zipball/46663316285bf1f001a31584213b327494b00ae7", + "reference": "46663316285bf1f001a31584213b327494b00ae7", "shasum": "" }, "require": { @@ -2625,7 +2625,7 @@ ], "support": { "issues": "https://github.com/Spomky-Labs/otphp/issues", - "source": "https://github.com/Spomky-Labs/otphp/tree/11.4.2" + "source": "https://github.com/Spomky-Labs/otphp/tree/11.4.3" }, "funding": [ { @@ -2637,7 +2637,7 @@ "type": "patreon" } ], - "time": "2026-01-23T10:53:01+00:00" + "time": "2026-05-31T12:42:43+00:00" }, { "name": "symfony/deprecation-contracts", @@ -3510,16 +3510,16 @@ }, { "name": "utopia-php/audit", - "version": "2.4.1", + "version": "2.4.2", "source": { "type": "git", "url": "https://github.com/utopia-php/audit.git", - "reference": "eddd79d93f23ed2851c0df2b1e2e2dfb25ba06c6" + "reference": "6f15caaac5455c98cec06e02fe8da3af9477ff38" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/audit/zipball/eddd79d93f23ed2851c0df2b1e2e2dfb25ba06c6", - "reference": "eddd79d93f23ed2851c0df2b1e2e2dfb25ba06c6", + "url": "https://api.github.com/repos/utopia-php/audit/zipball/6f15caaac5455c98cec06e02fe8da3af9477ff38", + "reference": "6f15caaac5455c98cec06e02fe8da3af9477ff38", "shasum": "" }, "require": { @@ -3554,26 +3554,27 @@ ], "support": { "issues": "https://github.com/utopia-php/audit/issues", - "source": "https://github.com/utopia-php/audit/tree/2.4.1" + "source": "https://github.com/utopia-php/audit/tree/2.4.2" }, - "time": "2026-05-20T06:25:45+00:00" + "time": "2026-06-03T03:42:22+00:00" }, { "name": "utopia-php/auth", - "version": "0.5.0", + "version": "0.5.1", "source": { "type": "git", "url": "https://github.com/utopia-php/auth.git", - "reference": "5ad0ded3a79f153ee904b97b49f8dfe4669e4fd0" + "reference": "9245a6342ed94f00425aef6963a32b8af9b0dc9d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/auth/zipball/5ad0ded3a79f153ee904b97b49f8dfe4669e4fd0", - "reference": "5ad0ded3a79f153ee904b97b49f8dfe4669e4fd0", + "url": "https://api.github.com/repos/utopia-php/auth/zipball/9245a6342ed94f00425aef6963a32b8af9b0dc9d", + "reference": "9245a6342ed94f00425aef6963a32b8af9b0dc9d", "shasum": "" }, "require": { "ext-hash": "*", + "ext-openssl": "*", "ext-scrypt": "*", "ext-sodium": "*", "php": ">=8.0" @@ -3609,9 +3610,9 @@ ], "support": { "issues": "https://github.com/utopia-php/auth/issues", - "source": "https://github.com/utopia-php/auth/tree/0.5.0" + "source": "https://github.com/utopia-php/auth/tree/0.5.1" }, - "time": "2025-10-29T07:11:43+00:00" + "time": "2026-05-30T12:21:17+00:00" }, { "name": "utopia-php/cache", @@ -5401,16 +5402,16 @@ }, { "name": "utopia-php/vcs", - "version": "4.2.0", + "version": "4.2.1", "source": { "type": "git", "url": "https://github.com/utopia-php/vcs.git", - "reference": "49d7751f0ae94634b00057177d9823928f6777c6" + "reference": "59b64833fafb6c6e88c1eff8545e4e6adb8f5993" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/vcs/zipball/49d7751f0ae94634b00057177d9823928f6777c6", - "reference": "49d7751f0ae94634b00057177d9823928f6777c6", + "url": "https://api.github.com/repos/utopia-php/vcs/zipball/59b64833fafb6c6e88c1eff8545e4e6adb8f5993", + "reference": "59b64833fafb6c6e88c1eff8545e4e6adb8f5993", "shasum": "" }, "require": { @@ -5444,9 +5445,9 @@ ], "support": { "issues": "https://github.com/utopia-php/vcs/issues", - "source": "https://github.com/utopia-php/vcs/tree/4.2.0" + "source": "https://github.com/utopia-php/vcs/tree/4.2.1" }, - "time": "2026-05-17T15:58:27+00:00" + "time": "2026-05-29T10:47:49+00:00" }, { "name": "utopia-php/websocket", @@ -5639,16 +5640,16 @@ "packages-dev": [ { "name": "appwrite/sdk-generator", - "version": "1.31.8", + "version": "1.32.0", "source": { "type": "git", "url": "https://github.com/appwrite/sdk-generator.git", - "reference": "3bc6c697e60807dd036b5c02c66d03183afad79f" + "reference": "7ec48fd30746e9fbc3a9bd7d3af8052acf400ff8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/3bc6c697e60807dd036b5c02c66d03183afad79f", - "reference": "3bc6c697e60807dd036b5c02c66d03183afad79f", + "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/7ec48fd30746e9fbc3a9bd7d3af8052acf400ff8", + "reference": "7ec48fd30746e9fbc3a9bd7d3af8052acf400ff8", "shasum": "" }, "require": { @@ -5684,9 +5685,9 @@ "description": "Appwrite PHP library for generating API SDKs for multiple programming languages and platforms", "support": { "issues": "https://github.com/appwrite/sdk-generator/issues", - "source": "https://github.com/appwrite/sdk-generator/tree/1.31.8" + "source": "https://github.com/appwrite/sdk-generator/tree/1.32.0" }, - "time": "2026-05-28T05:01:17+00:00" + "time": "2026-06-03T08:49:57+00:00" }, { "name": "brianium/paratest", @@ -6395,11 +6396,11 @@ }, { "name": "phpstan/phpstan", - "version": "2.1.55", + "version": "2.2.1", "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/9eaac3826ed5e9b8427350a43cac825eeca3f566", - "reference": "9eaac3826ed5e9b8427350a43cac825eeca3f566", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/dea9c8f2d25cc849391042b71e429c1a4bf82660", + "reference": "dea9c8f2d25cc849391042b71e429c1a4bf82660", "shasum": "" }, "require": { @@ -6422,6 +6423,17 @@ "license": [ "MIT" ], + "authors": [ + { + "name": "Ondřej Mirtes" + }, + { + "name": "Markus Staab" + }, + { + "name": "Vincent Langlet" + } + ], "description": "PHPStan - PHP Static Analysis Tool", "keywords": [ "dev", @@ -6444,20 +6456,20 @@ "type": "github" } ], - "time": "2026-05-18T11:57:34+00:00" + "time": "2026-05-28T14:44:12+00:00" }, { "name": "phpunit/php-code-coverage", - "version": "12.5.6", + "version": "12.5.7", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "876099a072646c7745f673d7aeab5382c4439691" + "reference": "186dab580576598076de6818596d12b61801880e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/876099a072646c7745f673d7aeab5382c4439691", - "reference": "876099a072646c7745f673d7aeab5382c4439691", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/186dab580576598076de6818596d12b61801880e", + "reference": "186dab580576598076de6818596d12b61801880e", "shasum": "" }, "require": { @@ -6468,13 +6480,13 @@ "php": ">=8.3", "phpunit/php-text-template": "^5.0", "sebastian/complexity": "^5.0", - "sebastian/environment": "^8.0.3", - "sebastian/lines-of-code": "^4.0", + "sebastian/environment": "^8.1.2", + "sebastian/lines-of-code": "^4.0.1", "sebastian/version": "^6.0", "theseer/tokenizer": "^2.0.1" }, "require-dev": { - "phpunit/phpunit": "^12.5.1" + "phpunit/phpunit": "^12.5.28" }, "suggest": { "ext-pcov": "PHP extension that provides line coverage", @@ -6512,7 +6524,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/12.5.6" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/12.5.7" }, "funding": [ { @@ -6532,7 +6544,7 @@ "type": "tidelift" } ], - "time": "2026-04-15T08:23:17+00:00" + "time": "2026-06-01T13:24:19+00:00" }, { "name": "phpunit/php-file-iterator", @@ -6793,16 +6805,16 @@ }, { "name": "phpunit/phpunit", - "version": "12.5.25", + "version": "12.5.28", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "792c2980442dfce319226b88fa845b8b6de3b333" + "reference": "5895d05f5bf421ed230fbd76e1277e4b8955def4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/792c2980442dfce319226b88fa845b8b6de3b333", - "reference": "792c2980442dfce319226b88fa845b8b6de3b333", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/5895d05f5bf421ed230fbd76e1277e4b8955def4", + "reference": "5895d05f5bf421ed230fbd76e1277e4b8955def4", "shasum": "" }, "require": { @@ -6821,15 +6833,15 @@ "phpunit/php-invoker": "^6.0.0", "phpunit/php-text-template": "^5.0.0", "phpunit/php-timer": "^8.0.0", - "sebastian/cli-parser": "^4.2.0", - "sebastian/comparator": "^7.1.6", + "sebastian/cli-parser": "^4.2.1", + "sebastian/comparator": "^7.1.8", "sebastian/diff": "^7.0.0", - "sebastian/environment": "^8.1.0", - "sebastian/exporter": "^7.0.2", + "sebastian/environment": "^8.1.2", + "sebastian/exporter": "^7.0.3", "sebastian/global-state": "^8.0.2", "sebastian/object-enumerator": "^7.0.0", "sebastian/recursion-context": "^7.0.1", - "sebastian/type": "^6.0.3", + "sebastian/type": "^6.0.4", "sebastian/version": "^6.0.0", "staabm/side-effects-detector": "^1.0.5" }, @@ -6871,7 +6883,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/12.5.25" + "source": "https://github.com/sebastianbergmann/phpunit/tree/12.5.28" }, "funding": [ { @@ -6879,7 +6891,7 @@ "type": "other" } ], - "time": "2026-05-13T03:56:57+00:00" + "time": "2026-05-27T14:01:10+00:00" }, { "name": "sebastian/cli-parser", @@ -6952,16 +6964,16 @@ }, { "name": "sebastian/comparator", - "version": "7.1.6", + "version": "7.1.8", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "c769009dee98f494e0edc3fd4f4087501688f11e" + "reference": "7c65c1e79836812819705b473a90c12399542485" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/c769009dee98f494e0edc3fd4f4087501688f11e", - "reference": "c769009dee98f494e0edc3fd4f4087501688f11e", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/7c65c1e79836812819705b473a90c12399542485", + "reference": "7c65c1e79836812819705b473a90c12399542485", "shasum": "" }, "require": { @@ -6969,10 +6981,10 @@ "ext-mbstring": "*", "php": ">=8.3", "sebastian/diff": "^7.0", - "sebastian/exporter": "^7.0" + "sebastian/exporter": "^7.0.3" }, "require-dev": { - "phpunit/phpunit": "^12.2" + "phpunit/phpunit": "^12.5.25" }, "suggest": { "ext-bcmath": "For comparing BcMath\\Number objects" @@ -7020,7 +7032,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/comparator/issues", "security": "https://github.com/sebastianbergmann/comparator/security/policy", - "source": "https://github.com/sebastianbergmann/comparator/tree/7.1.6" + "source": "https://github.com/sebastianbergmann/comparator/tree/7.1.8" }, "funding": [ { @@ -7040,7 +7052,7 @@ "type": "tidelift" } ], - "time": "2026-04-14T08:23:15+00:00" + "time": "2026-05-21T04:45:25+00:00" }, { "name": "sebastian/complexity", @@ -7169,23 +7181,23 @@ }, { "name": "sebastian/environment", - "version": "8.1.0", + "version": "8.1.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "b121608b28a13f721e76ffbbd386d08eff58f3f6" + "reference": "9d32c685773823b1983e256ae4ecd48a10d6e439" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/b121608b28a13f721e76ffbbd386d08eff58f3f6", - "reference": "b121608b28a13f721e76ffbbd386d08eff58f3f6", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/9d32c685773823b1983e256ae4ecd48a10d6e439", + "reference": "9d32c685773823b1983e256ae4ecd48a10d6e439", "shasum": "" }, "require": { "php": ">=8.3" }, "require-dev": { - "phpunit/phpunit": "^12.0" + "phpunit/phpunit": "^12.5.26" }, "suggest": { "ext-posix": "*" @@ -7221,7 +7233,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/environment/issues", "security": "https://github.com/sebastianbergmann/environment/security/policy", - "source": "https://github.com/sebastianbergmann/environment/tree/8.1.0" + "source": "https://github.com/sebastianbergmann/environment/tree/8.1.2" }, "funding": [ { @@ -7241,7 +7253,7 @@ "type": "tidelift" } ], - "time": "2026-04-15T12:13:01+00:00" + "time": "2026-05-25T13:40:20+00:00" }, { "name": "sebastian/exporter", @@ -7335,26 +7347,26 @@ }, { "name": "sebastian/global-state", - "version": "8.0.2", + "version": "8.0.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "ef1377171613d09edd25b7816f05be8313f9115d" + "reference": "b164d3274d6537ab462591c5755f76a8f5b1aae9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/ef1377171613d09edd25b7816f05be8313f9115d", - "reference": "ef1377171613d09edd25b7816f05be8313f9115d", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/b164d3274d6537ab462591c5755f76a8f5b1aae9", + "reference": "b164d3274d6537ab462591c5755f76a8f5b1aae9", "shasum": "" }, "require": { "php": ">=8.3", "sebastian/object-reflector": "^5.0", - "sebastian/recursion-context": "^7.0" + "sebastian/recursion-context": "^7.0.1" }, "require-dev": { "ext-dom": "*", - "phpunit/phpunit": "^12.0" + "phpunit/phpunit": "^12.5.28" }, "type": "library", "extra": { @@ -7385,7 +7397,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/global-state/issues", "security": "https://github.com/sebastianbergmann/global-state/security/policy", - "source": "https://github.com/sebastianbergmann/global-state/tree/8.0.2" + "source": "https://github.com/sebastianbergmann/global-state/tree/8.0.3" }, "funding": [ { @@ -7405,7 +7417,7 @@ "type": "tidelift" } ], - "time": "2025-08-29T11:29:25+00:00" + "time": "2026-06-01T15:10:33+00:00" }, { "name": "sebastian/lines-of-code", @@ -7876,23 +7888,29 @@ }, { "name": "symfony/console", - "version": "v8.0.11", + "version": "v8.1.0", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "3156577f46a38aa1b9323aad223de7a9cd426782" + "reference": "f5a856c6ecb56b3c21ed94a5b7bf940d857d110a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/3156577f46a38aa1b9323aad223de7a9cd426782", - "reference": "3156577f46a38aa1b9323aad223de7a9cd426782", + "url": "https://api.github.com/repos/symfony/console/zipball/f5a856c6ecb56b3c21ed94a5b7bf940d857d110a", + "reference": "f5a856c6ecb56b3c21ed94a5b7bf940d857d110a", "shasum": "" }, "require": { - "php": ">=8.4", + "php": ">=8.4.1", + "symfony/deprecation-contracts": "^2.5|^3", "symfony/polyfill-mbstring": "^1.0", + "symfony/polyfill-php85": "^1.32", "symfony/service-contracts": "^2.5|^3", - "symfony/string": "^7.4|^8.0" + "symfony/string": "^7.4.6|^8.0.6" + }, + "conflict": { + "symfony/dependency-injection": "<8.1", + "symfony/event-dispatcher": "<8.1" }, "provide": { "psr/log-implementation": "1.0|2.0|3.0" @@ -7900,14 +7918,18 @@ "require-dev": { "psr/log": "^1|^2|^3", "symfony/config": "^7.4|^8.0", - "symfony/dependency-injection": "^7.4|^8.0", - "symfony/event-dispatcher": "^7.4|^8.0", + "symfony/dependency-injection": "^8.1", + "symfony/event-dispatcher": "^8.1", + "symfony/filesystem": "^7.4|^8.0", "symfony/http-foundation": "^7.4|^8.0", "symfony/http-kernel": "^7.4|^8.0", "symfony/lock": "^7.4|^8.0", "symfony/messenger": "^7.4|^8.0", + "symfony/mime": "^7.4|^8.0", "symfony/process": "^7.4|^8.0", "symfony/stopwatch": "^7.4|^8.0", + "symfony/uid": "^7.4|^8.0", + "symfony/validator": "^7.4|^8.0", "symfony/var-dumper": "^7.4|^8.0" }, "type": "library", @@ -7942,7 +7964,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v8.0.11" + "source": "https://github.com/symfony/console/tree/v8.1.0" }, "funding": [ { @@ -7962,7 +7984,7 @@ "type": "tidelift" } ], - "time": "2026-05-13T12:07:53+00:00" + "time": "2026-05-29T05:06:50+00:00" }, { "name": "symfony/polyfill-ctype", @@ -8049,16 +8071,16 @@ }, { "name": "symfony/polyfill-intl-grapheme", - "version": "v1.37.0", + "version": "v1.38.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-grapheme.git", - "reference": "4864388bfbd3001ce88e234fab652acd91fdc57e" + "reference": "e9247d281d694a5120554d9afaf54e070e88a603" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/4864388bfbd3001ce88e234fab652acd91fdc57e", - "reference": "4864388bfbd3001ce88e234fab652acd91fdc57e", + "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/e9247d281d694a5120554d9afaf54e070e88a603", + "reference": "e9247d281d694a5120554d9afaf54e070e88a603", "shasum": "" }, "require": { @@ -8107,7 +8129,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.37.0" + "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.38.1" }, "funding": [ { @@ -8127,20 +8149,20 @@ "type": "tidelift" } ], - "time": "2026-04-26T13:13:48+00:00" + "time": "2026-05-26T05:58:03+00:00" }, { "name": "symfony/polyfill-intl-normalizer", - "version": "v1.37.0", + "version": "v1.38.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-normalizer.git", - "reference": "3833d7255cc303546435cb650316bff708a1c75c" + "reference": "2d446c214bdbe5b71bde5011b060a05fece3ae6b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/3833d7255cc303546435cb650316bff708a1c75c", - "reference": "3833d7255cc303546435cb650316bff708a1c75c", + "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/2d446c214bdbe5b71bde5011b060a05fece3ae6b", + "reference": "2d446c214bdbe5b71bde5011b060a05fece3ae6b", "shasum": "" }, "require": { @@ -8192,7 +8214,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.37.0" + "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.38.0" }, "funding": [ { @@ -8212,24 +8234,24 @@ "type": "tidelift" } ], - "time": "2024-09-09T11:45:10+00:00" + "time": "2026-05-25T13:48:31+00:00" }, { "name": "symfony/process", - "version": "v8.0.11", + "version": "v8.1.0", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "26d89e459f037d2873300605d0a07e7a8ef84db0" + "reference": "c4a9e58f235a6bf7f97ffbfedae2687353ac79e5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/26d89e459f037d2873300605d0a07e7a8ef84db0", - "reference": "26d89e459f037d2873300605d0a07e7a8ef84db0", + "url": "https://api.github.com/repos/symfony/process/zipball/c4a9e58f235a6bf7f97ffbfedae2687353ac79e5", + "reference": "c4a9e58f235a6bf7f97ffbfedae2687353ac79e5", "shasum": "" }, "require": { - "php": ">=8.4" + "php": ">=8.4.1" }, "type": "library", "autoload": { @@ -8257,7 +8279,7 @@ "description": "Executes commands in sub-processes", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/process/tree/v8.0.11" + "source": "https://github.com/symfony/process/tree/v8.1.0" }, "funding": [ { @@ -8277,24 +8299,24 @@ "type": "tidelift" } ], - "time": "2026-05-11T16:56:32+00:00" + "time": "2026-05-29T05:06:50+00:00" }, { "name": "symfony/string", - "version": "v8.0.11", + "version": "v8.1.0", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "39be2ad058a3c0bd558edca23e65f009865d75ff" + "reference": "afd5944f4005862d961efb85c8bbd5c523c4e3c9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/39be2ad058a3c0bd558edca23e65f009865d75ff", - "reference": "39be2ad058a3c0bd558edca23e65f009865d75ff", + "url": "https://api.github.com/repos/symfony/string/zipball/afd5944f4005862d961efb85c8bbd5c523c4e3c9", + "reference": "afd5944f4005862d961efb85c8bbd5c523c4e3c9", "shasum": "" }, "require": { - "php": ">=8.4", + "php": ">=8.4.1", "symfony/polyfill-ctype": "^1.8", "symfony/polyfill-intl-grapheme": "^1.33", "symfony/polyfill-intl-normalizer": "^1.0", @@ -8347,7 +8369,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v8.0.11" + "source": "https://github.com/symfony/string/tree/v8.1.0" }, "funding": [ { @@ -8367,7 +8389,7 @@ "type": "tidelift" } ], - "time": "2026-05-13T12:07:53+00:00" + "time": "2026-05-29T05:06:50+00:00" }, { "name": "textalk/websocket", @@ -8470,16 +8492,16 @@ }, { "name": "twig/twig", - "version": "v3.27.0", + "version": "v3.27.1", "source": { "type": "git", "url": "https://github.com/twigphp/Twig.git", - "reference": "04ae1bfe9463c816cf72ca0abe7eae2c77a9a9ed" + "reference": "ae2071bffb38f04847fc0864d730c94b9cb8ab74" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/04ae1bfe9463c816cf72ca0abe7eae2c77a9a9ed", - "reference": "04ae1bfe9463c816cf72ca0abe7eae2c77a9a9ed", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/ae2071bffb38f04847fc0864d730c94b9cb8ab74", + "reference": "ae2071bffb38f04847fc0864d730c94b9cb8ab74", "shasum": "" }, "require": { @@ -8534,7 +8556,7 @@ ], "support": { "issues": "https://github.com/twigphp/Twig/issues", - "source": "https://github.com/twigphp/Twig/tree/v3.27.0" + "source": "https://github.com/twigphp/Twig/tree/v3.27.1" }, "funding": [ { @@ -8546,7 +8568,7 @@ "type": "tidelift" } ], - "time": "2026-05-27T13:05:51+00:00" + "time": "2026-05-30T17:09:26+00:00" } ], "aliases": [], diff --git a/docker-compose.yml b/docker-compose.yml index 90bea1dc5d..2907ab864f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1383,7 +1383,11 @@ services: timeout: 5s retries: 10 start_period: 10s - command: "postgres" + command: > + postgres + -c fsync=off + -c synchronous_commit=off + -c full_page_writes=off appwrite-embedding: image: appwrite/embedding:0.1.0 diff --git a/docs/sdks/unity/CHANGELOG.md b/docs/sdks/unity/CHANGELOG.md new file mode 100644 index 0000000000..bbfc68354e --- /dev/null +++ b/docs/sdks/unity/CHANGELOG.md @@ -0,0 +1,5 @@ +# Change Log + +## 0.1.0 + +* Initial release diff --git a/src/Appwrite/Auth/Validator/PasswordStrength.php b/src/Appwrite/Auth/Validator/PasswordStrength.php new file mode 100644 index 0000000000..a9772cbd22 --- /dev/null +++ b/src/Appwrite/Auth/Validator/PasswordStrength.php @@ -0,0 +1,89 @@ +min = $policy['min'] ?? 8; + $this->uppercase = $policy['uppercase'] ?? false; + $this->lowercase = $policy['lowercase'] ?? false; + $this->number = $policy['number'] ?? false; + $this->symbols = $policy['symbols'] ?? false; + } + + public function getDescription(): string + { + $requirements = [ + 'between ' . $this->min . ' and 256 characters long', + ]; + + if ($this->uppercase) { + $requirements[] = 'include an uppercase letter'; + } + + if ($this->lowercase) { + $requirements[] = 'include a lowercase letter'; + } + + if ($this->number) { + $requirements[] = 'include a number'; + } + + if ($this->symbols) { + $requirements[] = 'include a symbol'; + } + + return 'Password must be ' . \implode(', ', $requirements) . '.'; + } + + /** + * @param mixed $value + */ + public function isValid($value): bool + { + if (!parent::isValid($value)) { + return false; + } + + if ($this->allowEmpty && \strlen($value) === 0) { + return true; + } + + if (\strlen($value) < $this->min) { + return false; + } + + if ($this->uppercase && !\preg_match('/[A-Z]/', $value)) { + return false; + } + + if ($this->lowercase && !\preg_match('/[a-z]/', $value)) { + return false; + } + + if ($this->number && !\preg_match('/\d/', $value)) { + return false; + } + + if ($this->symbols && !\preg_match('/[^\p{L}\p{N}\s]/u', $value)) { + return false; + } + + return true; + } +} diff --git a/src/Appwrite/Platform/Modules/Project/Http/Project/Policies/Get.php b/src/Appwrite/Platform/Modules/Project/Http/Project/Policies/Get.php index c0c247936d..feb1c1f263 100644 --- a/src/Appwrite/Platform/Modules/Project/Http/Project/Policies/Get.php +++ b/src/Appwrite/Platform/Modules/Project/Http/Project/Policies/Get.php @@ -77,6 +77,7 @@ class Get extends Action return [ 'password-dictionary' => Response::MODEL_POLICY_PASSWORD_DICTIONARY, 'password-history' => Response::MODEL_POLICY_PASSWORD_HISTORY, + 'password-strength' => Response::MODEL_POLICY_PASSWORD_STRENGTH, 'password-personal-data' => Response::MODEL_POLICY_PASSWORD_PERSONAL_DATA, 'session-alert' => Response::MODEL_POLICY_SESSION_ALERT, 'session-duration' => Response::MODEL_POLICY_SESSION_DURATION, @@ -109,6 +110,18 @@ class Get extends Action ]), Response::MODEL_POLICY_PASSWORD_HISTORY, ], + 'password-strength' => [ + new Document(\array_merge([ + 'min' => 8, + 'uppercase' => false, + 'lowercase' => false, + 'number' => false, + 'symbols' => false, + ], $auths['passwordStrength'] ?? [], [ + '$id' => 'password-strength', + ])), + Response::MODEL_POLICY_PASSWORD_STRENGTH, + ], 'password-personal-data' => [ new Document([ '$id' => 'password-personal-data', diff --git a/src/Appwrite/Platform/Modules/Project/Http/Project/Policies/PasswordStrength/Update.php b/src/Appwrite/Platform/Modules/Project/Http/Project/Policies/PasswordStrength/Update.php new file mode 100644 index 0000000000..3fbcbe8b30 --- /dev/null +++ b/src/Appwrite/Platform/Modules/Project/Http/Project/Policies/PasswordStrength/Update.php @@ -0,0 +1,115 @@ +setHttpMethod(Action::HTTP_REQUEST_METHOD_PATCH) + ->setHttpPath('/v1/project/policies/password-strength') + ->desc('Update password strength policy') + ->groups(['api', 'project']) + ->label('scope', ['policies.write', 'project.policies.write']) + ->label('event', 'projects.[projectId].policies.[policy].update') + ->label('audits.event', 'projects.[projectId].policies.[policy].update') + ->label('audits.resource', 'project/{response.$id}') + ->label('sdk', new Method( + namespace: 'project', + group: 'policies', + name: 'updatePasswordStrengthPolicy', + description: <<<'EOT' + Update the password strength requirements for users in the project. + EOT, + auth: [AuthType::ADMIN, AuthType::KEY], + responses: [ + new SDKResponse( + code: Response::STATUS_CODE_OK, + model: Response::MODEL_POLICY_PASSWORD_STRENGTH, + ), + ], + )) + ->param('min', null, new Range(8, 256), 'Minimum password length. Value must be between 8 and 256. Default is 8.', optional: true) + ->param('uppercase', null, new Boolean(), 'Whether passwords must include at least one uppercase letter.', optional: true) + ->param('lowercase', null, new Boolean(), 'Whether passwords must include at least one lowercase letter.', optional: true) + ->param('number', null, new Boolean(), 'Whether passwords must include at least one number.', optional: true) + ->param('symbols', null, new Boolean(), 'Whether passwords must include at least one symbol.', optional: true) + ->inject('response') + ->inject('dbForPlatform') + ->inject('project') + ->inject('authorization') + ->inject('queueForEvents') + ->callback($this->action(...)); + } + + public function action( + ?int $min, + ?bool $uppercase, + ?bool $lowercase, + ?bool $number, + ?bool $symbols, + Response $response, + Database $dbForPlatform, + Document $project, + Authorization $authorization, + Event $queueForEvents, + ): void { + $auths = $project->getAttribute('auths', []); + $auths['passwordStrength'] = \array_merge([ + 'min' => 8, + 'uppercase' => false, + 'lowercase' => false, + 'number' => false, + 'symbols' => false, + ], $auths['passwordStrength'] ?? []); + + if ($min !== null) { + $auths['passwordStrength']['min'] = $min; + } + if ($uppercase !== null) { + $auths['passwordStrength']['uppercase'] = $uppercase; + } + if ($lowercase !== null) { + $auths['passwordStrength']['lowercase'] = $lowercase; + } + if ($number !== null) { + $auths['passwordStrength']['number'] = $number; + } + if ($symbols !== null) { + $auths['passwordStrength']['symbols'] = $symbols; + } + + $project = $authorization->skip(fn () => $dbForPlatform->updateDocument('projects', $project->getId(), new Document([ + 'auths' => $auths, + ]))); + + $queueForEvents + ->setParam('projectId', $project->getId()) + ->setParam('policy', 'password-strength'); + + $response->dynamic(new Document(\array_merge($auths['passwordStrength'], [ + '$id' => 'password-strength', + ])), Response::MODEL_POLICY_PASSWORD_STRENGTH); + } +} diff --git a/src/Appwrite/Platform/Modules/Project/Http/Project/Policies/XList.php b/src/Appwrite/Platform/Modules/Project/Http/Project/Policies/XList.php index 7057803c8a..0c74b86547 100644 --- a/src/Appwrite/Platform/Modules/Project/Http/Project/Policies/XList.php +++ b/src/Appwrite/Platform/Modules/Project/Http/Project/Policies/XList.php @@ -103,6 +103,15 @@ class XList extends Action '$id' => 'password-history', 'total' => $auths['passwordHistory'] ?? 0, ]), + new Document(\array_merge([ + 'min' => 8, + 'uppercase' => false, + 'lowercase' => false, + 'number' => false, + 'symbols' => false, + ], $auths['passwordStrength'] ?? [], [ + '$id' => 'password-strength', + ])), new Document([ '$id' => 'password-personal-data', 'enabled' => $auths['personalDataCheck'] ?? false, diff --git a/src/Appwrite/Platform/Modules/Project/Services/Http.php b/src/Appwrite/Platform/Modules/Project/Services/Http.php index 3fe9f63d9e..a8eec3abd0 100644 --- a/src/Appwrite/Platform/Modules/Project/Services/Http.php +++ b/src/Appwrite/Platform/Modules/Project/Services/Http.php @@ -80,6 +80,7 @@ use Appwrite\Platform\Modules\Project\Http\Project\Policies\MembershipPrivacy\Up use Appwrite\Platform\Modules\Project\Http\Project\Policies\PasswordDictionary\Update as UpdatePasswordDictionaryPolicy; use Appwrite\Platform\Modules\Project\Http\Project\Policies\PasswordHistory\Update as UpdatePasswordHistoryPolicy; use Appwrite\Platform\Modules\Project\Http\Project\Policies\PasswordPersonalData\Update as UpdatePasswordPersonalDataPolicy; +use Appwrite\Platform\Modules\Project\Http\Project\Policies\PasswordStrength\Update as UpdatePasswordStrengthPolicy; use Appwrite\Platform\Modules\Project\Http\Project\Policies\SessionAlert\Update as UpdateSessionAlertPolicy; use Appwrite\Platform\Modules\Project\Http\Project\Policies\SessionDuration\Update as UpdateSessionDurationPolicy; use Appwrite\Platform\Modules\Project\Http\Project\Policies\SessionInvalidation\Update as UpdateSessionInvalidationPolicy; @@ -168,6 +169,7 @@ class Http extends Service $this->addAction(UpdateMembershipPrivacyPolicy::getName(), new UpdateMembershipPrivacyPolicy()); $this->addAction(UpdatePasswordDictionaryPolicy::getName(), new UpdatePasswordDictionaryPolicy()); $this->addAction(UpdatePasswordHistoryPolicy::getName(), new UpdatePasswordHistoryPolicy()); + $this->addAction(UpdatePasswordStrengthPolicy::getName(), new UpdatePasswordStrengthPolicy()); $this->addAction(UpdatePasswordPersonalDataPolicy::getName(), new UpdatePasswordPersonalDataPolicy()); $this->addAction(UpdateSessionAlertPolicy::getName(), new UpdateSessionAlertPolicy()); $this->addAction(UpdateSessionDurationPolicy::getName(), new UpdateSessionDurationPolicy()); diff --git a/src/Appwrite/Platform/Modules/Projects/Http/Projects/Create.php b/src/Appwrite/Platform/Modules/Projects/Http/Projects/Create.php index 9204f99d67..1560788d09 100644 --- a/src/Appwrite/Platform/Modules/Projects/Http/Projects/Create.php +++ b/src/Appwrite/Platform/Modules/Projects/Http/Projects/Create.php @@ -83,6 +83,13 @@ class Create extends Action $auths = [ 'limit' => 0, 'maxSessions' => 0, + 'passwordStrength' => [ + 'min' => 8, + 'uppercase' => false, + 'lowercase' => false, + 'number' => false, + 'symbols' => false, + ], 'passwordHistory' => 0, 'passwordDictionary' => false, 'duration' => TOKEN_EXPIRATION_LOGIN_LONG, diff --git a/src/Appwrite/Platform/Tasks/SDKs.php b/src/Appwrite/Platform/Tasks/SDKs.php index 5d52d905f6..69e1828a66 100644 --- a/src/Appwrite/Platform/Tasks/SDKs.php +++ b/src/Appwrite/Platform/Tasks/SDKs.php @@ -24,6 +24,7 @@ use Appwrite\SDK\Language\REST; use Appwrite\SDK\Language\Ruby; use Appwrite\SDK\Language\Rust; use Appwrite\SDK\Language\Swift; +use Appwrite\SDK\Language\Unity; use Appwrite\SDK\Language\Web; use Appwrite\SDK\SDK; use Appwrite\Spec\StaticSpec; @@ -431,6 +432,11 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND $cover = ''; $config = new DotNet(); break; + case 'unity': + $cover = ''; + $config = new Unity(); + $config->setPackageName('io.appwrite.unity'); + break; case 'android': $config = new Android(); break; diff --git a/src/Appwrite/Platform/Tasks/Specs.php b/src/Appwrite/Platform/Tasks/Specs.php index c8120bd017..8717ae742e 100644 --- a/src/Appwrite/Platform/Tasks/Specs.php +++ b/src/Appwrite/Platform/Tasks/Specs.php @@ -139,6 +139,12 @@ class Specs extends Action 'description' => 'Your project ID', 'in' => 'header', ], + 'ProjectQuery' => [ + 'type' => 'apiKey', + 'name' => 'project', + 'description' => 'Your project ID', + 'in' => 'query', + ], 'JWT' => [ 'type' => 'apiKey', 'name' => 'X-Appwrite-JWT', @@ -195,6 +201,12 @@ class Specs extends Action 'description' => 'Your project ID', 'in' => 'header', ], + 'ProjectQuery' => [ + 'type' => 'apiKey', + 'name' => 'project', + 'description' => 'Your project ID', + 'in' => 'query', + ], 'Key' => [ 'type' => 'apiKey', 'name' => 'X-Appwrite-Key', @@ -263,6 +275,12 @@ class Specs extends Action 'description' => 'Your project ID', 'in' => 'header', ], + 'ProjectQuery' => [ + 'type' => 'apiKey', + 'name' => 'project', + 'description' => 'Your project ID', + 'in' => 'query', + ], 'Key' => [ 'type' => 'apiKey', 'name' => 'X-Appwrite-Key', diff --git a/src/Appwrite/SDK/Method.php b/src/Appwrite/SDK/Method.php index c74406b2a6..5f6ccf9a0f 100644 --- a/src/Appwrite/SDK/Method.php +++ b/src/Appwrite/SDK/Method.php @@ -32,6 +32,7 @@ class Method * @param array $additionalParameters * @param string $desc * @param bool $public Whether this method should be rendered on the website/documentation + * @param string $projectAuth Project authentication security scheme to use in specs */ public function __construct( protected string $namespace, @@ -49,12 +50,17 @@ class Method protected array $parameters = [], protected array $additionalParameters = [], protected string $desc = '', - protected bool $public = true + protected bool $public = true, + protected string $projectAuth = 'Project' ) { $this->validateMethod($name, $namespace); $this->validateAuthTypes($auth); $this->validateDesc($description); + if (!\in_array($projectAuth, ['Project', 'ProjectQuery'], true)) { + self::$errors[] = "Error with {$this->getRouteName()} method: Invalid project auth scheme"; + } + foreach ($responses as $response) { $this->validateResponseModel($response->getModel()); $this->validateNoContent($response); @@ -223,6 +229,11 @@ class Method return $this->additionalParameters; } + public function getProjectAuth(): string + { + return $this->projectAuth; + } + public function setNamespace(string $namespace): self { $this->namespace = $namespace; diff --git a/src/Appwrite/SDK/Specification/Format/OpenAPI3.php b/src/Appwrite/SDK/Specification/Format/OpenAPI3.php index 8d07938bc8..dfa38b0bf5 100644 --- a/src/Appwrite/SDK/Specification/Format/OpenAPI3.php +++ b/src/Appwrite/SDK/Specification/Format/OpenAPI3.php @@ -85,6 +85,10 @@ class OpenAPI3 extends Format $output['components']['securitySchemes']['Project']['x-appwrite'] = ['demo' => '']; } + if (isset($output['components']['securitySchemes']['ProjectQuery'])) { + $output['components']['securitySchemes']['ProjectQuery']['x-appwrite'] = ['demo' => '']; + } + if (isset($output['components']['securitySchemes']['Key'])) { $output['components']['securitySchemes']['Key']['x-appwrite'] = ['demo' => '']; } @@ -184,7 +188,7 @@ class OpenAPI3 extends Format continue; } - $methodSecurities = ['Project' => []]; + $methodSecurities = [$methodObj->getProjectAuth() => []]; foreach ($methodObj->getAuth() as $security) { if (\array_key_exists($security->value, $this->keys)) { $methodSecurities[$security->value] = []; @@ -370,7 +374,7 @@ class OpenAPI3 extends Format } if (!empty($scope)) { - $securities = ['Project' => []]; + $securities = [$sdk->getProjectAuth() => []]; foreach ($sdk->getAuth() as $security) { /** @var AuthType $security */ diff --git a/src/Appwrite/SDK/Specification/Format/Swagger2.php b/src/Appwrite/SDK/Specification/Format/Swagger2.php index 9265e1ec60..20b1fb9b94 100644 --- a/src/Appwrite/SDK/Specification/Format/Swagger2.php +++ b/src/Appwrite/SDK/Specification/Format/Swagger2.php @@ -74,6 +74,10 @@ class Swagger2 extends Format $output['securityDefinitions']['Project']['x-appwrite'] = ['demo' => '']; } + if (isset($output['securityDefinitions']['ProjectQuery'])) { + $output['securityDefinitions']['ProjectQuery']['x-appwrite'] = ['demo' => '']; + } + if (isset($output['securityDefinitions']['Key'])) { $output['securityDefinitions']['Key']['x-appwrite'] = ['demo' => '']; } @@ -184,7 +188,7 @@ class Swagger2 extends Format continue; } - $methodSecurities = ['Project' => []]; + $methodSecurities = [$methodObj->getProjectAuth() => []]; foreach ($methodObj->getAuth() as $security) { /** @var AuthType $security */ if (\array_key_exists($security->value, $this->keys)) { @@ -361,7 +365,7 @@ class Swagger2 extends Format } if (!empty($scope)) { - $securities = ['Project' => []]; + $securities = [$sdk->getProjectAuth() => []]; foreach ($sdk->getAuth() as $security) { if (\array_key_exists($security->value, $this->keys)) { diff --git a/src/Appwrite/Utopia/Response.php b/src/Appwrite/Utopia/Response.php index c8b573fc49..d6b57990a4 100644 --- a/src/Appwrite/Utopia/Response.php +++ b/src/Appwrite/Utopia/Response.php @@ -267,6 +267,7 @@ class Response extends SwooleResponse public const MODEL_POLICY_LIST = 'policyList'; public const MODEL_POLICY_PASSWORD_DICTIONARY = 'policyPasswordDictionary'; public const MODEL_POLICY_PASSWORD_HISTORY = 'policyPasswordHistory'; + public const MODEL_POLICY_PASSWORD_STRENGTH = 'policyPasswordStrength'; public const MODEL_POLICY_PASSWORD_PERSONAL_DATA = 'policyPasswordPersonalData'; public const MODEL_POLICY_SESSION_ALERT = 'policySessionAlert'; public const MODEL_POLICY_SESSION_DURATION = 'policySessionDuration'; diff --git a/src/Appwrite/Utopia/Response/Model/PolicyList.php b/src/Appwrite/Utopia/Response/Model/PolicyList.php index 11704cdbff..0c61f15097 100644 --- a/src/Appwrite/Utopia/Response/Model/PolicyList.php +++ b/src/Appwrite/Utopia/Response/Model/PolicyList.php @@ -14,7 +14,7 @@ class PolicyList extends Model 'type' => self::TYPE_INTEGER, 'description' => 'Total number of policies in the given project.', 'default' => 0, - 'example' => 9, + 'example' => 10, ]) ->addRule('policies', [ 'type' => $this->getPolicyModels(), @@ -32,6 +32,7 @@ class PolicyList extends Model return [ Response::MODEL_POLICY_PASSWORD_DICTIONARY, Response::MODEL_POLICY_PASSWORD_HISTORY, + Response::MODEL_POLICY_PASSWORD_STRENGTH, Response::MODEL_POLICY_PASSWORD_PERSONAL_DATA, Response::MODEL_POLICY_SESSION_ALERT, Response::MODEL_POLICY_SESSION_DURATION, diff --git a/src/Appwrite/Utopia/Response/Model/PolicyPasswordStrength.php b/src/Appwrite/Utopia/Response/Model/PolicyPasswordStrength.php new file mode 100644 index 0000000000..2a56cfa7e9 --- /dev/null +++ b/src/Appwrite/Utopia/Response/Model/PolicyPasswordStrength.php @@ -0,0 +1,59 @@ + 'password-strength', + ]; + + public function __construct() + { + parent::__construct(); + + $this + ->addRule('min', [ + 'type' => self::TYPE_INTEGER, + 'description' => 'Minimum password length required for user passwords.', + 'default' => 8, + 'example' => 12, + ]) + ->addRule('uppercase', [ + 'type' => self::TYPE_BOOLEAN, + 'description' => 'Whether passwords must include at least one uppercase letter.', + 'default' => false, + 'example' => true, + ]) + ->addRule('lowercase', [ + 'type' => self::TYPE_BOOLEAN, + 'description' => 'Whether passwords must include at least one lowercase letter.', + 'default' => false, + 'example' => true, + ]) + ->addRule('number', [ + 'type' => self::TYPE_BOOLEAN, + 'description' => 'Whether passwords must include at least one number.', + 'default' => false, + 'example' => true, + ]) + ->addRule('symbols', [ + 'type' => self::TYPE_BOOLEAN, + 'description' => 'Whether passwords must include at least one symbol.', + 'default' => false, + 'example' => true, + ]); + } + + public function getName(): string + { + return 'Policy Password Strength'; + } + + public function getType(): string + { + return Response::MODEL_POLICY_PASSWORD_STRENGTH; + } +} diff --git a/tests/e2e/Services/Project/PoliciesBase.php b/tests/e2e/Services/Project/PoliciesBase.php index 71fc85919f..e92335a61c 100644 --- a/tests/e2e/Services/Project/PoliciesBase.php +++ b/tests/e2e/Services/Project/PoliciesBase.php @@ -15,6 +15,7 @@ trait PoliciesBase return [ 'password-dictionary' => ['enabled'], 'password-history' => ['total'], + 'password-strength' => ['min', 'uppercase', 'lowercase', 'number', 'symbols'], 'password-personal-data' => ['enabled'], 'session-alert' => ['enabled'], 'session-duration' => ['duration'], @@ -66,6 +67,13 @@ trait PoliciesBase { $this->updatePasswordDictionaryPolicy(true); $this->updatePasswordHistoryPolicy(5); + $this->updatePasswordStrengthPolicy([ + 'min' => 12, + 'uppercase' => true, + 'lowercase' => true, + 'number' => true, + 'symbols' => true, + ]); $this->updateSessionDurationPolicy(3600); $this->updateMembershipPrivacyPolicy([ 'userId' => true, @@ -77,6 +85,7 @@ trait PoliciesBase $passwordDictionary = $this->getPolicy('password-dictionary'); $passwordHistory = $this->getPolicy('password-history'); + $passwordStrength = $this->getPolicy('password-strength'); $sessionDuration = $this->getPolicy('session-duration'); $membershipPrivacy = $this->getPolicy('membership-privacy'); @@ -86,6 +95,13 @@ trait PoliciesBase $this->assertSame(200, $passwordHistory['headers']['status-code']); $this->assertSame(5, $passwordHistory['body']['total']); + $this->assertSame(200, $passwordStrength['headers']['status-code']); + $this->assertSame(12, $passwordStrength['body']['min']); + $this->assertSame(true, $passwordStrength['body']['uppercase']); + $this->assertSame(true, $passwordStrength['body']['lowercase']); + $this->assertSame(true, $passwordStrength['body']['number']); + $this->assertSame(true, $passwordStrength['body']['symbols']); + $this->assertSame(200, $sessionDuration['headers']['status-code']); $this->assertSame(3600, $sessionDuration['body']['duration']); @@ -99,6 +115,7 @@ trait PoliciesBase // Cleanup $this->updatePasswordDictionaryPolicy(false); $this->updatePasswordHistoryPolicy(null); + $this->resetPasswordStrengthPolicy(); $this->updateSessionDurationPolicy(31536000); $this->updateMembershipPrivacyPolicy([ 'userId' => false, @@ -180,6 +197,13 @@ trait PoliciesBase { $this->updatePasswordDictionaryPolicy(true); $this->updatePasswordHistoryPolicy(5); + $this->updatePasswordStrengthPolicy([ + 'min' => 12, + 'uppercase' => true, + 'lowercase' => true, + 'number' => true, + 'symbols' => true, + ]); $this->updateSessionDurationPolicy(3600); $this->updateMembershipPrivacyPolicy([ 'userId' => true, @@ -200,6 +224,11 @@ trait PoliciesBase $this->assertSame(true, $byId['password-dictionary']['enabled']); $this->assertSame(5, $byId['password-history']['total']); + $this->assertSame(12, $byId['password-strength']['min']); + $this->assertSame(true, $byId['password-strength']['uppercase']); + $this->assertSame(true, $byId['password-strength']['lowercase']); + $this->assertSame(true, $byId['password-strength']['number']); + $this->assertSame(true, $byId['password-strength']['symbols']); $this->assertSame(3600, $byId['session-duration']['duration']); $this->assertSame(true, $byId['membership-privacy']['userId']); $this->assertSame(true, $byId['membership-privacy']['userEmail']); @@ -210,6 +239,7 @@ trait PoliciesBase // Cleanup $this->updatePasswordDictionaryPolicy(false); $this->updatePasswordHistoryPolicy(null); + $this->resetPasswordStrengthPolicy(); $this->updateSessionDurationPolicy(31536000); $this->updateMembershipPrivacyPolicy([ 'userId' => false, @@ -435,6 +465,112 @@ trait PoliciesBase $this->assertSame(401, $response['headers']['status-code']); } + // ========================================================================= + // Password Strength + // ========================================================================= + + public function testUpdatePasswordStrengthPolicy(): void + { + $response = $this->updatePasswordStrengthPolicy([ + 'min' => 12, + 'uppercase' => true, + 'lowercase' => true, + 'number' => true, + 'symbols' => true, + ]); + + $this->assertSame(200, $response['headers']['status-code']); + $this->assertSame('password-strength', $response['body']['$id']); + $this->assertSame(12, $response['body']['min']); + $this->assertSame(true, $response['body']['uppercase']); + $this->assertSame(true, $response['body']['lowercase']); + $this->assertSame(true, $response['body']['number']); + $this->assertSame(true, $response['body']['symbols']); + + $policy = $this->getPolicy('password-strength'); + $this->assertSame(200, $policy['headers']['status-code']); + $this->assertSame(12, $policy['body']['min']); + $this->assertSame(true, $policy['body']['uppercase']); + $this->assertSame(true, $policy['body']['lowercase']); + $this->assertSame(true, $policy['body']['number']); + $this->assertSame(true, $policy['body']['symbols']); + + // Cleanup + $this->resetPasswordStrengthPolicy(); + } + + public function testUpdatePasswordStrengthPolicyOptionPreservesOtherOptions(): void + { + $response = $this->updatePasswordStrengthPolicy([ + 'min' => 12, + 'uppercase' => true, + 'lowercase' => true, + 'number' => true, + 'symbols' => true, + ]); + + $this->assertSame(200, $response['headers']['status-code']); + + $response = $this->updatePasswordStrengthPolicy([ + 'lowercase' => false, + ]); + + $this->assertSame(200, $response['headers']['status-code']); + $this->assertSame(12, $response['body']['min']); + $this->assertSame(true, $response['body']['uppercase']); + $this->assertSame(false, $response['body']['lowercase']); + $this->assertSame(true, $response['body']['number']); + $this->assertSame(true, $response['body']['symbols']); + + // Cleanup + $this->resetPasswordStrengthPolicy(); + } + + public function testUpdatePasswordStrengthPolicyMin(): void + { + $response = $this->updatePasswordStrengthPolicy([ + 'min' => 8, + ]); + + $this->assertSame(200, $response['headers']['status-code']); + $this->assertSame(8, $response['body']['min']); + + // Cleanup + $this->resetPasswordStrengthPolicy(); + } + + public function testUpdatePasswordStrengthPolicyBelowMin(): void + { + $response = $this->client->call(Client::METHOD_PATCH, '/project/policies/password-strength', $this->buildHeaders(), [ + 'min' => 7, + ]); + + $this->assertSame(400, $response['headers']['status-code']); + } + + public function testUpdatePasswordStrengthPolicyEmptyBody(): void + { + $this->resetPasswordStrengthPolicy(); + + $response = $this->client->call(Client::METHOD_PATCH, '/project/policies/password-strength', $this->buildHeaders(), []); + + $this->assertSame(200, $response['headers']['status-code']); + $this->assertSame(8, $response['body']['min']); + $this->assertSame(false, $response['body']['uppercase']); + $this->assertSame(false, $response['body']['lowercase']); + $this->assertSame(false, $response['body']['number']); + $this->assertSame(false, $response['body']['symbols']); + } + + public function testUpdatePasswordStrengthPolicyWithoutAuth(): void + { + $response = $this->updatePasswordStrengthPolicy([ + 'min' => 12, + ], false); + + $this->assertSame(401, $response['headers']['status-code']); + } + // ========================================================================= // Password Personal Data Policy // ========================================================================= @@ -987,7 +1123,7 @@ trait PoliciesBase if ($otherParam === $param) { continue; } - $this->assertSame(true, $response['body'][$otherAttribute], $otherAttribute . ' should be untouched while only ' . $param . ' was updated'); + $this->assertSame(true, $response['body'][$otherAttribute], $otherAttribute.' should be untouched while only '.$param.' was updated'); } // Restore the field before the next iteration @@ -1102,10 +1238,10 @@ trait PoliciesBase protected function getProjectDocument(): array { - return $this->client->call(Client::METHOD_GET, '/projects/' . $this->getProject()['$id'], [ + return $this->client->call(Client::METHOD_GET, '/projects/'.$this->getProject()['$id'], [ 'content-type' => 'application/json', 'x-appwrite-project' => 'console', - 'cookie' => 'a_session_console=' . $this->getRoot()['session'], + 'cookie' => 'a_session_console='.$this->getRoot()['session'], 'x-appwrite-response-format' => '1.9.4', ]); } @@ -1127,7 +1263,7 @@ trait PoliciesBase protected function getPolicy(string $policyId, bool $authenticated = true): mixed { - return $this->client->call(Client::METHOD_GET, '/project/policies/' . $policyId, $this->buildHeaders($authenticated)); + return $this->client->call(Client::METHOD_GET, '/project/policies/'.$policyId, $this->buildHeaders($authenticated)); } protected function updatePasswordDictionaryPolicy(bool $enabled, bool $authenticated = true): mixed @@ -1144,6 +1280,25 @@ trait PoliciesBase ]); } + /** + * @param array $params + */ + protected function updatePasswordStrengthPolicy(array $params, bool $authenticated = true): mixed + { + return $this->client->call(Client::METHOD_PATCH, '/project/policies/password-strength', $this->buildHeaders($authenticated), $params); + } + + protected function resetPasswordStrengthPolicy(): void + { + $this->updatePasswordStrengthPolicy([ + 'min' => 8, + 'uppercase' => false, + 'lowercase' => false, + 'number' => false, + 'symbols' => false, + ]); + } + protected function updatePasswordPersonalDataPolicy(bool $enabled, bool $authenticated = true): mixed { return $this->client->call(Client::METHOD_PATCH, '/project/policies/password-personal-data', $this->buildHeaders($authenticated), [ @@ -1187,7 +1342,7 @@ trait PoliciesBase } /** - * @param array $params + * @param array $params */ protected function updateMembershipPrivacyPolicy(array $params, bool $authenticated = true): mixed { diff --git a/tests/e2e/Services/Project/PoliciesPasswordStrengthIntegrationTest.php b/tests/e2e/Services/Project/PoliciesPasswordStrengthIntegrationTest.php new file mode 100644 index 0000000000..4a8d132e2f --- /dev/null +++ b/tests/e2e/Services/Project/PoliciesPasswordStrengthIntegrationTest.php @@ -0,0 +1,77 @@ +getProject()['$id']; + $apiKey = $this->getProject()['apiKey']; + + $serverHeaders = [ + 'content-type' => 'application/json', + 'x-appwrite-project' => $projectId, + 'x-appwrite-key' => $apiKey, + 'x-appwrite-response-format' => '1.9.4', + ]; + + $signupHeaders = [ + 'origin' => 'http://localhost', + 'content-type' => 'application/json', + 'x-appwrite-project' => $projectId, + ]; + + $response = $this->client->call(Client::METHOD_PATCH, '/project/policies/password-strength', $serverHeaders, [ + 'min' => 12, + 'uppercase' => true, + 'lowercase' => true, + 'number' => true, + 'symbols' => true, + ]); + + $this->assertSame(200, $response['headers']['status-code']); + $this->assertSame(12, $response['body']['min']); + $this->assertTrue($response['body']['uppercase']); + $this->assertTrue($response['body']['lowercase']); + $this->assertTrue($response['body']['number']); + $this->assertTrue($response['body']['symbols']); + + $weak = $this->client->call(Client::METHOD_POST, '/account', $signupHeaders, [ + 'userId' => ID::unique(), + 'email' => 'strength_weak_' . uniqid() . '@localhost.test', + 'password' => 'password123!', + 'name' => 'Weak Password User', + ]); + + $this->assertSame(400, $weak['headers']['status-code']); + + $valid = $this->client->call(Client::METHOD_POST, '/account', $signupHeaders, [ + 'userId' => ID::unique(), + 'email' => 'strength_valid_' . uniqid() . '@localhost.test', + 'password' => 'Password123!', + 'name' => 'Valid Password User', + ]); + + $this->assertSame(201, $valid['headers']['status-code']); + + $response = $this->client->call(Client::METHOD_PATCH, '/project/policies/password-strength', $serverHeaders, [ + 'min' => 8, + 'uppercase' => false, + 'lowercase' => false, + 'number' => false, + 'symbols' => false, + ]); + + $this->assertSame(200, $response['headers']['status-code']); + } +} diff --git a/tests/e2e/Services/Project/ProjectConsoleClientTest.php b/tests/e2e/Services/Project/ProjectConsoleClientTest.php index 3328c7602f..8fecd23823 100644 --- a/tests/e2e/Services/Project/ProjectConsoleClientTest.php +++ b/tests/e2e/Services/Project/ProjectConsoleClientTest.php @@ -122,6 +122,11 @@ class ProjectConsoleClientTest extends Scope $this->assertArrayNotHasKey('authLimit', $response['body']); $this->assertArrayNotHasKey('authSessionsLimit', $response['body']); $this->assertArrayNotHasKey('authPasswordHistory', $response['body']); + $this->assertArrayNotHasKey('authPasswordStrengthMin', $response['body']); + $this->assertArrayNotHasKey('authPasswordStrengthRequireUppercase', $response['body']); + $this->assertArrayNotHasKey('authPasswordStrengthRequireLowercase', $response['body']); + $this->assertArrayNotHasKey('authPasswordStrengthRequireNumber', $response['body']); + $this->assertArrayNotHasKey('authPasswordStrengthRequireSpecialChar', $response['body']); $this->assertArrayNotHasKey('authPasswordDictionary', $response['body']); $this->assertArrayNotHasKey('authPersonalDataCheck', $response['body']); $this->assertArrayNotHasKey('authDisposableEmails', $response['body']); diff --git a/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php b/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php index 7b44b0485d..94eb483f29 100644 --- a/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php +++ b/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php @@ -2906,6 +2906,177 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(0, $response['body']['authPasswordHistory']); } + public function testUpdateProjectAuthPasswordStrength(): void + { + $data = $this->setupProjectData(); + $id = $data['projectId']; + + $response = $this->client->call(Client::METHOD_PATCH, '/project/policies/password-strength', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $id, + 'x-appwrite-mode' => 'admin', + ], $this->getHeaders()), [ + 'min' => 7, + ]); + + $this->assertEquals(400, $response['headers']['status-code']); + + $response = $this->client->call(Client::METHOD_PATCH, '/project/policies/password-strength', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $id, + 'x-appwrite-mode' => 'admin', + ], $this->getHeaders()), [ + 'min' => 12, + ]); + + $this->assertEquals(200, $response['headers']['status-code']); + + $response = $this->client->call(Client::METHOD_PATCH, '/project/policies/password-strength', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $id, + 'x-appwrite-mode' => 'admin', + ], $this->getHeaders()), [ + 'uppercase' => true, + 'lowercase' => true, + 'number' => true, + 'symbols' => true, + ]); + + $this->assertEquals(200, $response['headers']['status-code']); + $this->assertEquals(12, $response['body']['min']); + $this->assertEquals(true, $response['body']['uppercase']); + $this->assertEquals(true, $response['body']['lowercase']); + $this->assertEquals(true, $response['body']['number']); + $this->assertEquals(true, $response['body']['symbols']); + + $weakPassword = 'password123!'; + $validPassword = 'Password123!'; + $email = uniqid() . 'user@localhost.test'; + + $response = $this->client->call(Client::METHOD_POST, '/account', array_merge([ + 'origin' => 'http://localhost', + 'content-type' => 'application/json', + 'x-appwrite-project' => $id, + ]), [ + 'userId' => ID::unique(), + 'email' => uniqid() . 'weak-account@localhost.test', + 'password' => $weakPassword, + 'name' => 'Weak Account', + ]); + + $this->assertEquals(400, $response['headers']['status-code']); + + $response = $this->client->call(Client::METHOD_POST, '/users', array_merge($this->getHeaders(), [ + 'content-type' => 'application/json', + 'x-appwrite-project' => $id, + 'x-appwrite-mode' => 'admin', + ]), [ + 'userId' => ID::unique(), + 'email' => uniqid() . 'weak-user@localhost.test', + 'password' => $weakPassword, + 'name' => 'Weak User', + ]); + + $this->assertEquals(400, $response['headers']['status-code']); + + $response = $this->client->call(Client::METHOD_POST, '/account', array_merge([ + 'origin' => 'http://localhost', + 'content-type' => 'application/json', + 'x-appwrite-project' => $id, + ]), [ + 'userId' => ID::unique(), + 'email' => $email, + 'password' => $validPassword, + 'name' => 'Password Strength User', + ]); + + $this->assertEquals(201, $response['headers']['status-code']); + $userId = $response['body']['$id']; + + $session = $this->client->call(Client::METHOD_POST, '/account/sessions/email', [ + 'origin' => 'http://localhost', + 'content-type' => 'application/json', + 'x-appwrite-project' => $id, + ], [ + 'email' => $email, + 'password' => $validPassword, + ]); + + $this->assertEquals(201, $session['headers']['status-code']); + $session = $session['cookies']['a_session_' . $id]; + + $response = $this->client->call(Client::METHOD_PATCH, '/account/password', array_merge([ + 'origin' => 'http://localhost', + 'content-type' => 'application/json', + 'x-appwrite-project' => $id, + 'cookie' => 'a_session_' . $id . '=' . $session, + ]), [ + 'oldPassword' => $validPassword, + 'password' => $weakPassword, + ]); + + $this->assertEquals(400, $response['headers']['status-code']); + + $response = $this->client->call(Client::METHOD_POST, '/account/recovery', array_merge([ + 'origin' => 'http://localhost', + 'content-type' => 'application/json', + 'x-appwrite-project' => $id, + ]), [ + 'email' => $email, + 'url' => 'http://localhost/recovery', + ]); + + $this->assertEquals(201, $response['headers']['status-code']); + + $lastEmail = $this->getLastEmailByAddress($email, function ($email) { + $this->assertStringContainsString('Password Reset', $email['subject']); + }); + $tokens = $this->extractQueryParamsFromEmailLink($lastEmail['html']); + + $response = $this->client->call(Client::METHOD_PUT, '/account/recovery', array_merge([ + 'origin' => 'http://localhost', + 'content-type' => 'application/json', + 'x-appwrite-project' => $id, + ]), [ + 'userId' => $userId, + 'secret' => $tokens['secret'], + 'password' => $weakPassword, + ]); + + $this->assertEquals(400, $response['headers']['status-code']); + + $headers = array_merge($this->getHeaders(), [ + 'x-appwrite-mode' => 'admin', + 'content-type' => 'application/json', + 'x-appwrite-project' => $id, + ]); + + $response = $this->client->call(Client::METHOD_PATCH, '/users/' . $userId . '/password', $headers, [ + 'password' => $weakPassword, + ]); + + $this->assertEquals(400, $response['headers']['status-code']); + + $response = $this->client->call(Client::METHOD_PATCH, '/project/policies/password-strength', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $id, + 'x-appwrite-mode' => 'admin', + ], $this->getHeaders()), [ + 'min' => 8, + 'uppercase' => false, + 'lowercase' => false, + 'number' => false, + 'symbols' => false, + ]); + + $this->assertEquals(200, $response['headers']['status-code']); + $this->assertEquals(8, $response['body']['min']); + $this->assertEquals(false, $response['body']['uppercase']); + $this->assertEquals(false, $response['body']['lowercase']); + $this->assertEquals(false, $response['body']['number']); + $this->assertEquals(false, $response['body']['symbols']); + } + #[Group('smtpAndTemplates')] #[Group('projectsCRUD')] public function testUpdateMockNumbers(): void diff --git a/tests/unit/Auth/Validator/PasswordStrengthTest.php b/tests/unit/Auth/Validator/PasswordStrengthTest.php new file mode 100644 index 0000000000..af49acb148 --- /dev/null +++ b/tests/unit/Auth/Validator/PasswordStrengthTest.php @@ -0,0 +1,59 @@ +assertFalse($validator->isValid('1234567')); + $this->assertTrue($validator->isValid('password')); + } + + public function testConfiguredPolicy(): void + { + $validator = new PasswordStrength([ + 'min' => 12, + 'uppercase' => true, + 'lowercase' => true, + 'number' => true, + 'symbols' => true, + ]); + + $this->assertFalse($validator->isValid('Password1!')); + $this->assertFalse($validator->isValid('password123!')); + $this->assertFalse($validator->isValid('PASSWORD123!')); + $this->assertFalse($validator->isValid('PasswordOnly!')); + $this->assertFalse($validator->isValid('Password1234')); + $this->assertTrue($validator->isValid('Password123!')); + $this->assertTrue($validator->isValid('Password123€')); + } + + public function testMinimumCanBeEight(): void + { + $validator = new PasswordStrength([ + 'min' => 8, + ]); + + $this->assertFalse($validator->isValid('1234567')); + $this->assertTrue($validator->isValid('12345678')); + } + + public function testAllowEmpty(): void + { + $validator = new PasswordStrength([ + 'min' => 12, + 'uppercase' => true, + 'lowercase' => true, + 'number' => true, + 'symbols' => true, + ], true); + + $this->assertTrue($validator->isValid('')); + } +}