From e4d2b832355d6fb6256b76c652fb5a7fad13361f Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Tue, 26 May 2026 16:43:13 +0100 Subject: [PATCH 01/11] Add OAuth providers migration --- composer.json | 2 +- composer.lock | 88 +++++++++---------- .../Utopia/Response/Model/MigrationReport.php | 6 ++ 3 files changed, 51 insertions(+), 45 deletions(-) diff --git a/composer.json b/composer.json index 30d8eedc73..609e0f4bc2 100644 --- a/composer.json +++ b/composer.json @@ -75,7 +75,7 @@ "utopia-php/lock": "0.2.*", "utopia-php/logger": "0.8.*", "utopia-php/messaging": "0.22.*", - "utopia-php/migration": "dev-add-email-templates-migration as 1.12.0", + "utopia-php/migration": "dev-add-oauth-providers-migration as 1.12.0", "utopia-php/platform": "1.0.0-rc2", "utopia-php/pools": "1.*", "utopia-php/span": "1.1.*", diff --git a/composer.lock b/composer.lock index bbbf124068..bc09954b6f 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "575aa56a776213cb0c24063ec029441b", + "content-hash": "1000c57d7f81c28ff3e4efb70ccf95f6", "packages": [ { "name": "adhocore/jwt", @@ -69,16 +69,16 @@ }, { "name": "appwrite/appwrite", - "version": "24.1.0", + "version": "24.2.0", "source": { "type": "git", "url": "https://github.com/appwrite/sdk-for-php.git", - "reference": "dcb3550a3332de1c1665a015a09e9c73ff515e4f" + "reference": "d3217b6524b9d174ab91fb7ffc555c68bfa1da97" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/appwrite/sdk-for-php/zipball/dcb3550a3332de1c1665a015a09e9c73ff515e4f", - "reference": "dcb3550a3332de1c1665a015a09e9c73ff515e4f", + "url": "https://api.github.com/repos/appwrite/sdk-for-php/zipball/d3217b6524b9d174ab91fb7ffc555c68bfa1da97", + "reference": "d3217b6524b9d174ab91fb7ffc555c68bfa1da97", "shasum": "" }, "require": { @@ -104,10 +104,10 @@ "support": { "email": "team@appwrite.io", "issues": "https://github.com/appwrite/sdk-for-php/issues", - "source": "https://github.com/appwrite/sdk-for-php/tree/24.1.0", + "source": "https://github.com/appwrite/sdk-for-php/tree/24.2.0", "url": "https://appwrite.io/support" }, - "time": "2026-05-20T09:37:03+00:00" + "time": "2026-05-21T18:56:51+00:00" }, { "name": "appwrite/php-clamav", @@ -2895,16 +2895,16 @@ }, { "name": "symfony/polyfill-mbstring", - "version": "v1.37.0", + "version": "v1.38.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "6a21eb99c6973357967f6ce3708cd55a6bec6315" + "reference": "14c5439eec4ccff081ac14eca2dc57feb2a66d92" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/6a21eb99c6973357967f6ce3708cd55a6bec6315", - "reference": "6a21eb99c6973357967f6ce3708cd55a6bec6315", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/14c5439eec4ccff081ac14eca2dc57feb2a66d92", + "reference": "14c5439eec4ccff081ac14eca2dc57feb2a66d92", "shasum": "" }, "require": { @@ -2956,7 +2956,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.37.0" + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.38.1" }, "funding": [ { @@ -2976,20 +2976,20 @@ "type": "tidelift" } ], - "time": "2026-04-10T17:25:58+00:00" + "time": "2026-05-26T12:51:13+00:00" }, { "name": "symfony/polyfill-php82", - "version": "v1.37.0", + "version": "v1.38.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php82.git", - "reference": "34808efe3e68f69685796f7c253a2f1d8ea9df59" + "reference": "002dc0cfe5fd4ed6033d48f27d4f19a486c4b04b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php82/zipball/34808efe3e68f69685796f7c253a2f1d8ea9df59", - "reference": "34808efe3e68f69685796f7c253a2f1d8ea9df59", + "url": "https://api.github.com/repos/symfony/polyfill-php82/zipball/002dc0cfe5fd4ed6033d48f27d4f19a486c4b04b", + "reference": "002dc0cfe5fd4ed6033d48f27d4f19a486c4b04b", "shasum": "" }, "require": { @@ -3036,7 +3036,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php82/tree/v1.37.0" + "source": "https://github.com/symfony/polyfill-php82/tree/v1.38.1" }, "funding": [ { @@ -3056,20 +3056,20 @@ "type": "tidelift" } ], - "time": "2026-04-10T16:19:22+00:00" + "time": "2026-05-26T12:45:58+00:00" }, { "name": "symfony/polyfill-php83", - "version": "v1.37.0", + "version": "v1.38.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php83.git", - "reference": "3600c2cb22399e25bb226e4a135ce91eeb2a6149" + "reference": "8339098cae28673c15cce00d80734af0453054e2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php83/zipball/3600c2cb22399e25bb226e4a135ce91eeb2a6149", - "reference": "3600c2cb22399e25bb226e4a135ce91eeb2a6149", + "url": "https://api.github.com/repos/symfony/polyfill-php83/zipball/8339098cae28673c15cce00d80734af0453054e2", + "reference": "8339098cae28673c15cce00d80734af0453054e2", "shasum": "" }, "require": { @@ -3116,7 +3116,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php83/tree/v1.37.0" + "source": "https://github.com/symfony/polyfill-php83/tree/v1.38.1" }, "funding": [ { @@ -3136,20 +3136,20 @@ "type": "tidelift" } ], - "time": "2026-04-10T17:25:58+00:00" + "time": "2026-05-26T12:51:13+00:00" }, { "name": "symfony/polyfill-php85", - "version": "v1.37.0", + "version": "v1.38.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php85.git", - "reference": "fcfa4973a9917cef23f2e38774da74a2b7d115ee" + "reference": "ba2ba04f3352cfa2dcbbcb90aee13ed967f505b1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php85/zipball/fcfa4973a9917cef23f2e38774da74a2b7d115ee", - "reference": "fcfa4973a9917cef23f2e38774da74a2b7d115ee", + "url": "https://api.github.com/repos/symfony/polyfill-php85/zipball/ba2ba04f3352cfa2dcbbcb90aee13ed967f505b1", + "reference": "ba2ba04f3352cfa2dcbbcb90aee13ed967f505b1", "shasum": "" }, "require": { @@ -3196,7 +3196,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php85/tree/v1.37.0" + "source": "https://github.com/symfony/polyfill-php85/tree/v1.38.1" }, "funding": [ { @@ -3216,7 +3216,7 @@ "type": "tidelift" } ], - "time": "2026-04-26T13:10:57+00:00" + "time": "2026-05-26T02:25:22+00:00" }, { "name": "symfony/service-contracts", @@ -4675,16 +4675,16 @@ }, { "name": "utopia-php/migration", - "version": "dev-add-email-templates-migration", + "version": "dev-add-oauth-providers-migration", "source": { "type": "git", "url": "https://github.com/utopia-php/migration.git", - "reference": "edcb0aa3285b44616e570e5fe092aaac97deb686" + "reference": "45926dc407faede6b9d45afb9dfdf74c7edebfdb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/migration/zipball/edcb0aa3285b44616e570e5fe092aaac97deb686", - "reference": "edcb0aa3285b44616e570e5fe092aaac97deb686", + "url": "https://api.github.com/repos/utopia-php/migration/zipball/45926dc407faede6b9d45afb9dfdf74c7edebfdb", + "reference": "45926dc407faede6b9d45afb9dfdf74c7edebfdb", "shasum": "" }, "require": { @@ -4741,10 +4741,10 @@ "utopia" ], "support": { - "source": "https://github.com/utopia-php/migration/tree/add-email-templates-migration", + "source": "https://github.com/utopia-php/migration/tree/add-oauth-providers-migration", "issues": "https://github.com/utopia-php/migration/issues" }, - "time": "2026-05-21T16:14:58+00:00" + "time": "2026-05-26T15:19:03+00:00" }, { "name": "utopia-php/mongo", @@ -5391,16 +5391,16 @@ }, { "name": "utopia-php/validators", - "version": "0.2.3", + "version": "0.2.4", "source": { "type": "git", "url": "https://github.com/utopia-php/validators.git", - "reference": "9770269c8ed8e6909934965fa8722103c7434c23" + "reference": "b4ee60db4dbae5ffbe53968d01f69b6941251576" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/validators/zipball/9770269c8ed8e6909934965fa8722103c7434c23", - "reference": "9770269c8ed8e6909934965fa8722103c7434c23", + "url": "https://api.github.com/repos/utopia-php/validators/zipball/b4ee60db4dbae5ffbe53968d01f69b6941251576", + "reference": "b4ee60db4dbae5ffbe53968d01f69b6941251576", "shasum": "" }, "require": { @@ -5430,9 +5430,9 @@ ], "support": { "issues": "https://github.com/utopia-php/validators/issues", - "source": "https://github.com/utopia-php/validators/tree/0.2.3" + "source": "https://github.com/utopia-php/validators/tree/0.2.4" }, - "time": "2026-05-14T08:05:44+00:00" + "time": "2026-05-21T12:47:43+00:00" }, { "name": "utopia-php/vcs", @@ -8593,7 +8593,7 @@ }, { "package": "utopia-php/migration", - "version": "dev-add-email-templates-migration", + "version": "dev-add-oauth-providers-migration", "alias": "1.12.0", "alias_normalized": "1.12.0.0" } diff --git a/src/Appwrite/Utopia/Response/Model/MigrationReport.php b/src/Appwrite/Utopia/Response/Model/MigrationReport.php index 1b475595d1..a695619507 100644 --- a/src/Appwrite/Utopia/Response/Model/MigrationReport.php +++ b/src/Appwrite/Utopia/Response/Model/MigrationReport.php @@ -83,6 +83,12 @@ class MigrationReport extends Model 'default' => 0, 'example' => 1, ]) + ->addRule(Resource::TYPE_OAUTH_PROVIDERS, [ + 'type' => self::TYPE_INTEGER, + 'description' => 'Number of OAuth provider configs to be migrated (always 0 or 1 — the project-level provider map; secrets are not migrated).', + 'default' => 0, + 'example' => 1, + ]) ->addRule(Resource::TYPE_PROTOCOLS, [ 'type' => self::TYPE_INTEGER, 'description' => 'Number of protocol configs to be migrated (always 0 or 1 — the project-level REST/GraphQL/WebSocket flags).', From 79cb2458c15373ff6b8914cbfeb492aac5d609bf Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Thu, 28 May 2026 18:11:30 +0100 Subject: [PATCH 02/11] Bump migration lock for OAuth conditional-enable + appId guard --- composer.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.lock b/composer.lock index 3a6a895b50..20fe054484 100644 --- a/composer.lock +++ b/composer.lock @@ -4679,12 +4679,12 @@ "source": { "type": "git", "url": "https://github.com/utopia-php/migration.git", - "reference": "327bcc37b8bfbf9a269413aaf3ee6712c5fcdc44" + "reference": "b0820ded331d4dc437f183f3ca088df9f2397a5e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/migration/zipball/327bcc37b8bfbf9a269413aaf3ee6712c5fcdc44", - "reference": "327bcc37b8bfbf9a269413aaf3ee6712c5fcdc44", + "url": "https://api.github.com/repos/utopia-php/migration/zipball/b0820ded331d4dc437f183f3ca088df9f2397a5e", + "reference": "b0820ded331d4dc437f183f3ca088df9f2397a5e", "shasum": "" }, "require": { @@ -4744,7 +4744,7 @@ "source": "https://github.com/utopia-php/migration/tree/add-oauth-providers-migration", "issues": "https://github.com/utopia-php/migration/issues" }, - "time": "2026-05-28T16:13:35+00:00" + "time": "2026-05-28T17:09:03+00:00" }, { "name": "utopia-php/mongo", From 9ca6dc176e89f071d713119592bfb2814a844b73 Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Fri, 29 May 2026 10:45:48 +0100 Subject: [PATCH 03/11] OAuth2: 40 per-provider rules in MigrationReport; bump lock --- composer.lock | 8 ++++---- .../Utopia/Response/Model/MigrationReport.php | 19 +++++++++++++------ 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/composer.lock b/composer.lock index 20fe054484..4654dc2aec 100644 --- a/composer.lock +++ b/composer.lock @@ -4679,12 +4679,12 @@ "source": { "type": "git", "url": "https://github.com/utopia-php/migration.git", - "reference": "b0820ded331d4dc437f183f3ca088df9f2397a5e" + "reference": "3269cf3e588d4847bcc358ea8ea0e3067afda36a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/migration/zipball/b0820ded331d4dc437f183f3ca088df9f2397a5e", - "reference": "b0820ded331d4dc437f183f3ca088df9f2397a5e", + "url": "https://api.github.com/repos/utopia-php/migration/zipball/3269cf3e588d4847bcc358ea8ea0e3067afda36a", + "reference": "3269cf3e588d4847bcc358ea8ea0e3067afda36a", "shasum": "" }, "require": { @@ -4744,7 +4744,7 @@ "source": "https://github.com/utopia-php/migration/tree/add-oauth-providers-migration", "issues": "https://github.com/utopia-php/migration/issues" }, - "time": "2026-05-28T17:09:03+00:00" + "time": "2026-05-29T07:19:55+00:00" }, { "name": "utopia-php/mongo", diff --git a/src/Appwrite/Utopia/Response/Model/MigrationReport.php b/src/Appwrite/Utopia/Response/Model/MigrationReport.php index e680cf53ae..71be35b31f 100644 --- a/src/Appwrite/Utopia/Response/Model/MigrationReport.php +++ b/src/Appwrite/Utopia/Response/Model/MigrationReport.php @@ -5,6 +5,7 @@ namespace Appwrite\Utopia\Response\Model; use Appwrite\Utopia\Response; use Appwrite\Utopia\Response\Model; use Utopia\Migration\Resource; +use Utopia\Migration\Transfer; class MigrationReport extends Model { @@ -83,12 +84,6 @@ class MigrationReport extends Model 'default' => 0, 'example' => 1, ]) - ->addRule(Resource::TYPE_OAUTH_PROVIDERS, [ - 'type' => self::TYPE_INTEGER, - 'description' => 'Number of OAuth provider configs to be migrated (always 0 or 1 — the project-level provider map; secrets are not migrated).', - 'default' => 0, - 'example' => 1, - ]) ->addRule(Resource::TYPE_PROJECT_PROTOCOLS, [ 'type' => self::TYPE_INTEGER, 'description' => 'Number of protocol configs to be migrated (always 0 or 1 — the project-level REST/GraphQL/WebSocket flags).', @@ -173,6 +168,18 @@ class MigrationReport extends Model 'default' => '', 'example' => '1.4.0', ]); + + // OAuth2 providers — one rule per provider type. Each is reported as + // 0 or 1 (the per-project singleton). Secrets are never migrated; + // see the per-provider Resource classes in utopia-php/migration. + foreach (Transfer::GROUP_AUTH_OAUTH2_RESOURCES as $oauth2Type) { + $this->addRule($oauth2Type, [ + 'type' => self::TYPE_INTEGER, + 'description' => 'Number of `' . $oauth2Type . '` provider configs to be migrated (0 or 1; secrets are not migrated).', + 'default' => 0, + 'example' => 1, + ]); + } } /** From e8a6f037f598ae4bad5e04b8fd6a5836141ec2a5 Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Fri, 29 May 2026 11:59:18 +0100 Subject: [PATCH 04/11] OAuth2: single rule in MigrationReport; bump lock --- composer.lock | 8 ++++---- .../Utopia/Response/Model/MigrationReport.php | 18 ++++++------------ 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/composer.lock b/composer.lock index 4654dc2aec..52c77808aa 100644 --- a/composer.lock +++ b/composer.lock @@ -4679,12 +4679,12 @@ "source": { "type": "git", "url": "https://github.com/utopia-php/migration.git", - "reference": "3269cf3e588d4847bcc358ea8ea0e3067afda36a" + "reference": "e809d361b633040002bc284bac09dd987a04cd59" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/migration/zipball/3269cf3e588d4847bcc358ea8ea0e3067afda36a", - "reference": "3269cf3e588d4847bcc358ea8ea0e3067afda36a", + "url": "https://api.github.com/repos/utopia-php/migration/zipball/e809d361b633040002bc284bac09dd987a04cd59", + "reference": "e809d361b633040002bc284bac09dd987a04cd59", "shasum": "" }, "require": { @@ -4744,7 +4744,7 @@ "source": "https://github.com/utopia-php/migration/tree/add-oauth-providers-migration", "issues": "https://github.com/utopia-php/migration/issues" }, - "time": "2026-05-29T07:19:55+00:00" + "time": "2026-05-29T10:20:55+00:00" }, { "name": "utopia-php/mongo", diff --git a/src/Appwrite/Utopia/Response/Model/MigrationReport.php b/src/Appwrite/Utopia/Response/Model/MigrationReport.php index 71be35b31f..f2304fa16d 100644 --- a/src/Appwrite/Utopia/Response/Model/MigrationReport.php +++ b/src/Appwrite/Utopia/Response/Model/MigrationReport.php @@ -5,7 +5,6 @@ namespace Appwrite\Utopia\Response\Model; use Appwrite\Utopia\Response; use Appwrite\Utopia\Response\Model; use Utopia\Migration\Resource; -use Utopia\Migration\Transfer; class MigrationReport extends Model { @@ -169,17 +168,12 @@ class MigrationReport extends Model 'example' => '1.4.0', ]); - // OAuth2 providers — one rule per provider type. Each is reported as - // 0 or 1 (the per-project singleton). Secrets are never migrated; - // see the per-provider Resource classes in utopia-php/migration. - foreach (Transfer::GROUP_AUTH_OAUTH2_RESOURCES as $oauth2Type) { - $this->addRule($oauth2Type, [ - 'type' => self::TYPE_INTEGER, - 'description' => 'Number of `' . $oauth2Type . '` provider configs to be migrated (0 or 1; secrets are not migrated).', - 'default' => 0, - 'example' => 1, - ]); - } + $this->addRule(Resource::TYPE_OAUTH2_PROVIDER, [ + 'type' => self::TYPE_INTEGER, + 'description' => 'Number of OAuth2 provider configurations to be migrated. Secrets (clientSecret, p8File) are never migrated — destination admin must re-enter them per provider.', + 'default' => 0, + 'example' => 5, + ]); } /** From c2eaf7356563db4ca776b1c9ec977892e0cba497 Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Fri, 29 May 2026 15:40:34 +0100 Subject: [PATCH 05/11] Bump migration lock: drop OAuth conditional-enable guard --- composer.lock | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/composer.lock b/composer.lock index 52c77808aa..3cfcc4188c 100644 --- a/composer.lock +++ b/composer.lock @@ -3687,16 +3687,16 @@ }, { "name": "utopia-php/circuit-breaker", - "version": "0.3.0", + "version": "0.3.1", "source": { "type": "git", "url": "https://github.com/utopia-php/circuit-breaker.git", - "reference": "064243c1667778c00abf027ff53a735a228776de" + "reference": "db5d77f6c99ebce2ee81bd8ed4ae8f41bd2b0828" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/circuit-breaker/zipball/064243c1667778c00abf027ff53a735a228776de", - "reference": "064243c1667778c00abf027ff53a735a228776de", + "url": "https://api.github.com/repos/utopia-php/circuit-breaker/zipball/db5d77f6c99ebce2ee81bd8ed4ae8f41bd2b0828", + "reference": "db5d77f6c99ebce2ee81bd8ed4ae8f41bd2b0828", "shasum": "" }, "require": { @@ -3706,7 +3706,7 @@ "laravel/pint": "^1.29", "phpstan/phpstan": "^2.1", "phpunit/phpunit": "^10.0", - "utopia-php/telemetry": "0.2.*" + "utopia-php/telemetry": "^0.4" }, "suggest": { "ext-opentelemetry": "Required by utopia-php/telemetry when using OpenTelemetry metrics.", @@ -3743,9 +3743,9 @@ ], "support": { "issues": "https://github.com/utopia-php/circuit-breaker/issues", - "source": "https://github.com/utopia-php/circuit-breaker/tree/0.3.0" + "source": "https://github.com/utopia-php/circuit-breaker/tree/0.3.1" }, - "time": "2026-05-12T04:27:08+00:00" + "time": "2026-05-29T12:12:23+00:00" }, { "name": "utopia-php/cli", @@ -4679,12 +4679,12 @@ "source": { "type": "git", "url": "https://github.com/utopia-php/migration.git", - "reference": "e809d361b633040002bc284bac09dd987a04cd59" + "reference": "4829ace12f43f3d97020661660d0d4abb312eaad" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/migration/zipball/e809d361b633040002bc284bac09dd987a04cd59", - "reference": "e809d361b633040002bc284bac09dd987a04cd59", + "url": "https://api.github.com/repos/utopia-php/migration/zipball/4829ace12f43f3d97020661660d0d4abb312eaad", + "reference": "4829ace12f43f3d97020661660d0d4abb312eaad", "shasum": "" }, "require": { @@ -4744,7 +4744,7 @@ "source": "https://github.com/utopia-php/migration/tree/add-oauth-providers-migration", "issues": "https://github.com/utopia-php/migration/issues" }, - "time": "2026-05-29T10:20:55+00:00" + "time": "2026-05-29T14:33:29+00:00" }, { "name": "utopia-php/mongo", From 449bf8cbf6c5a4594e7763635bb939ef6bebb54c Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Mon, 1 Jun 2026 11:33:44 +0100 Subject: [PATCH 06/11] Add OAuth2 providers migration E2E test --- .../Services/Migrations/MigrationsBase.php | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/tests/e2e/Services/Migrations/MigrationsBase.php b/tests/e2e/Services/Migrations/MigrationsBase.php index 7b46542eb9..4415d9fcbc 100644 --- a/tests/e2e/Services/Migrations/MigrationsBase.php +++ b/tests/e2e/Services/Migrations/MigrationsBase.php @@ -3328,6 +3328,79 @@ trait MigrationsBase $this->client->call(Client::METHOD_PATCH, '/project/smtp', $destinationKeyHeaders, ['enabled' => false]); } + public function testAppwriteMigrationOAuth(): void + { + $sourceProjectId = $this->getProject()['$id']; + $destinationProjectId = $this->getDestinationProject()['$id']; + + $sourceKeyHeaders = [ + 'content-type' => 'application/json', + 'x-appwrite-project' => $sourceProjectId, + 'x-appwrite-key' => $this->getProject()['apiKey'], + ]; + $destinationKeyHeaders = [ + 'content-type' => 'application/json', + 'x-appwrite-project' => $destinationProjectId, + 'x-appwrite-key' => $this->getDestinationProject()['apiKey'], + ]; + + // Configure a GitHub OAuth2 provider on the source. enabled=false keeps the + // PATCH from triggering live credential verification (enabling fires a real + // network call to the provider). The migration carries the readable clientId + // and the enabled flag; the clientSecret is write-only on the source API and + // is never migrated. + $clientId = 'gh-client-' . ID::unique(); + $configure = $this->client->call(Client::METHOD_PATCH, '/project/oauth2/github', $sourceKeyHeaders, [ + 'clientId' => $clientId, + 'clientSecret' => 'gh-secret-not-migrated', + 'enabled' => false, + ]); + $this->assertEquals(200, $configure['headers']['status-code']); + $this->assertSame($clientId, $configure['body']['clientId']); + + $result = $this->performMigrationSync([ + 'resources' => [ + Resource::TYPE_OAUTH2_PROVIDER, + ], + 'endpoint' => $this->webEndpoint, + 'projectId' => $sourceProjectId, + 'apiKey' => $this->getProject()['apiKey'], + ]); + + $this->assertEquals('completed', $result['status']); + $this->assertEquals([Resource::TYPE_OAUTH2_PROVIDER], $result['resources']); + $this->assertArrayHasKey(Resource::TYPE_OAUTH2_PROVIDER, $result['statusCounters']); + $oauthCounters = $result['statusCounters'][Resource::TYPE_OAUTH2_PROVIDER]; + $this->assertEquals(0, $oauthCounters['error']); + $this->assertEquals(0, $oauthCounters['pending']); + $this->assertEquals(0, $oauthCounters['processing']); + $this->assertEquals(0, $oauthCounters['warning']); + // listOAuth2Providers returns every server-enabled provider, so a single run + // emits all of them; the configured GitHub provider is among the successes. + $this->assertGreaterThanOrEqual(1, $oauthCounters['success']); + + // The GitHub provider must round-trip to the destination: the readable + // clientId and enabled flag are carried; the secret is write-only and reads + // back empty on every path. + $fetched = $this->client->call(Client::METHOD_GET, '/project/oauth2/github', $destinationKeyHeaders); + $this->assertEquals(200, $fetched['headers']['status-code']); + $this->assertSame($clientId, $fetched['body']['clientId']); + $this->assertFalse($fetched['body']['enabled']); + $this->assertSame('', $fetched['body']['clientSecret']); + + // Reset both projects so the test is idempotent. + $this->client->call(Client::METHOD_PATCH, '/project/oauth2/github', $sourceKeyHeaders, [ + 'clientId' => '', + 'clientSecret' => '', + 'enabled' => false, + ]); + $this->client->call(Client::METHOD_PATCH, '/project/oauth2/github', $destinationKeyHeaders, [ + 'clientId' => '', + 'clientSecret' => '', + 'enabled' => false, + ]); + } + /** * Import documents from a CSV file. */ From 72d5fb8fb766b4c6edfa4b93d06b06b3c30692e0 Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Mon, 1 Jun 2026 13:12:45 +0100 Subject: [PATCH 07/11] chore(deps): bump utopia-php/migration to 4ac6933 (OAuth2 sandbox providers) --- composer.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.lock b/composer.lock index 3cfcc4188c..7d9d8c5753 100644 --- a/composer.lock +++ b/composer.lock @@ -4679,12 +4679,12 @@ "source": { "type": "git", "url": "https://github.com/utopia-php/migration.git", - "reference": "4829ace12f43f3d97020661660d0d4abb312eaad" + "reference": "4ac6933d3ee09e5e8ae097460b4aa47ff8a5587f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/migration/zipball/4829ace12f43f3d97020661660d0d4abb312eaad", - "reference": "4829ace12f43f3d97020661660d0d4abb312eaad", + "url": "https://api.github.com/repos/utopia-php/migration/zipball/4ac6933d3ee09e5e8ae097460b4aa47ff8a5587f", + "reference": "4ac6933d3ee09e5e8ae097460b4aa47ff8a5587f", "shasum": "" }, "require": { @@ -4744,7 +4744,7 @@ "source": "https://github.com/utopia-php/migration/tree/add-oauth-providers-migration", "issues": "https://github.com/utopia-php/migration/issues" }, - "time": "2026-05-29T14:33:29+00:00" + "time": "2026-06-01T10:31:18+00:00" }, { "name": "utopia-php/mongo", From d05ee8d0fed0c639adde37c699deea40da11ebc9 Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Mon, 1 Jun 2026 21:35:28 +0100 Subject: [PATCH 08/11] =?UTF-8?q?OAuth=20migration:=20configured-only=20pr?= =?UTF-8?q?oviders=20=E2=80=94=20bump=20lib=20lock=20+=20tighten=20E2E=20a?= =?UTF-8?q?ssertion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- composer.lock | 8 ++++---- tests/e2e/Services/Migrations/MigrationsBase.php | 5 ++--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/composer.lock b/composer.lock index 7d9d8c5753..e4a78c500b 100644 --- a/composer.lock +++ b/composer.lock @@ -4679,12 +4679,12 @@ "source": { "type": "git", "url": "https://github.com/utopia-php/migration.git", - "reference": "4ac6933d3ee09e5e8ae097460b4aa47ff8a5587f" + "reference": "d2a941d6d6a9b6863a02e42e3063a3c980d2ecf5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/migration/zipball/4ac6933d3ee09e5e8ae097460b4aa47ff8a5587f", - "reference": "4ac6933d3ee09e5e8ae097460b4aa47ff8a5587f", + "url": "https://api.github.com/repos/utopia-php/migration/zipball/d2a941d6d6a9b6863a02e42e3063a3c980d2ecf5", + "reference": "d2a941d6d6a9b6863a02e42e3063a3c980d2ecf5", "shasum": "" }, "require": { @@ -4744,7 +4744,7 @@ "source": "https://github.com/utopia-php/migration/tree/add-oauth-providers-migration", "issues": "https://github.com/utopia-php/migration/issues" }, - "time": "2026-06-01T10:31:18+00:00" + "time": "2026-06-01T19:51:29+00:00" }, { "name": "utopia-php/mongo", diff --git a/tests/e2e/Services/Migrations/MigrationsBase.php b/tests/e2e/Services/Migrations/MigrationsBase.php index 4415d9fcbc..2ce431f1cb 100644 --- a/tests/e2e/Services/Migrations/MigrationsBase.php +++ b/tests/e2e/Services/Migrations/MigrationsBase.php @@ -3375,9 +3375,8 @@ trait MigrationsBase $this->assertEquals(0, $oauthCounters['pending']); $this->assertEquals(0, $oauthCounters['processing']); $this->assertEquals(0, $oauthCounters['warning']); - // listOAuth2Providers returns every server-enabled provider, so a single run - // emits all of them; the configured GitHub provider is among the successes. - $this->assertGreaterThanOrEqual(1, $oauthCounters['success']); + // Only configured providers migrate; this project set up GitHub alone. + $this->assertEquals(1, $oauthCounters['success']); // The GitHub provider must round-trip to the destination: the readable // clientId and enabled flag are carried; the secret is write-only and reads From ff2efd915214e0727d9c65373ef8befe92ba70b3 Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Tue, 2 Jun 2026 09:23:34 +0100 Subject: [PATCH 09/11] chore(deps): bump migration lock (OAuth2 export null-guard + mock registrations) --- composer.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.lock b/composer.lock index e4a78c500b..778645ea70 100644 --- a/composer.lock +++ b/composer.lock @@ -4679,12 +4679,12 @@ "source": { "type": "git", "url": "https://github.com/utopia-php/migration.git", - "reference": "d2a941d6d6a9b6863a02e42e3063a3c980d2ecf5" + "reference": "6e4e416ecdd7a45134df9f579d92abf20363fc1f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/migration/zipball/d2a941d6d6a9b6863a02e42e3063a3c980d2ecf5", - "reference": "d2a941d6d6a9b6863a02e42e3063a3c980d2ecf5", + "url": "https://api.github.com/repos/utopia-php/migration/zipball/6e4e416ecdd7a45134df9f579d92abf20363fc1f", + "reference": "6e4e416ecdd7a45134df9f579d92abf20363fc1f", "shasum": "" }, "require": { @@ -4744,7 +4744,7 @@ "source": "https://github.com/utopia-php/migration/tree/add-oauth-providers-migration", "issues": "https://github.com/utopia-php/migration/issues" }, - "time": "2026-06-01T19:51:29+00:00" + "time": "2026-06-02T06:50:30+00:00" }, { "name": "utopia-php/mongo", From 275afb8e90ea78aa966b241810c59882a5df0df9 Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Wed, 3 Jun 2026 14:01:42 +0100 Subject: [PATCH 10/11] Test OAuth provider migration mappings --- composer.json | 2 +- composer.lock | 17 ++-- .../Services/Migrations/MigrationsBase.php | 92 ++++++++++++++++--- 3 files changed, 91 insertions(+), 20 deletions(-) diff --git a/composer.json b/composer.json index b78637ccd9..07cb56b58b 100644 --- a/composer.json +++ b/composer.json @@ -75,7 +75,7 @@ "utopia-php/lock": "0.2.*", "utopia-php/logger": "0.8.*", "utopia-php/messaging": "1.0.*", - "utopia-php/migration": "1.*", + "utopia-php/migration": "dev-add-oauth-providers-migration", "utopia-php/platform": "1.0.0-rc4", "utopia-php/pools": "1.*", "utopia-php/span": "1.1.*", diff --git a/composer.lock b/composer.lock index 335558fa9f..69c82d96d9 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "0c23c30bba86ad84377d4d1abce0992a", + "content-hash": "5d6823938d39a2ddbd3c40ada5fca362", "packages": [ { "name": "adhocore/jwt", @@ -4657,16 +4657,16 @@ }, { "name": "utopia-php/migration", - "version": "1.13.0", + "version": "dev-add-oauth-providers-migration", "source": { "type": "git", "url": "https://github.com/utopia-php/migration.git", - "reference": "0395af61922b52fb73bd9dbfb2dd10ac7aed2b01" + "reference": "dede00a186d30265318c7d7e82c85907584878ca" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/migration/zipball/0395af61922b52fb73bd9dbfb2dd10ac7aed2b01", - "reference": "0395af61922b52fb73bd9dbfb2dd10ac7aed2b01", + "url": "https://api.github.com/repos/utopia-php/migration/zipball/dede00a186d30265318c7d7e82c85907584878ca", + "reference": "dede00a186d30265318c7d7e82c85907584878ca", "shasum": "" }, "require": { @@ -4706,9 +4706,9 @@ ], "support": { "issues": "https://github.com/utopia-php/migration/issues", - "source": "https://github.com/utopia-php/migration/tree/1.13.0" + "source": "https://github.com/utopia-php/migration/tree/add-oauth-providers-migration" }, - "time": "2026-06-03T06:15:27+00:00" + "time": "2026-06-03T12:59:34+00:00" }, { "name": "utopia-php/mongo", @@ -8552,7 +8552,8 @@ "aliases": [], "minimum-stability": "dev", "stability-flags": { - "utopia-php/http": 5 + "utopia-php/http": 5, + "utopia-php/migration": 20 }, "prefer-stable": true, "prefer-lowest": false, diff --git a/tests/e2e/Services/Migrations/MigrationsBase.php b/tests/e2e/Services/Migrations/MigrationsBase.php index b6f44ff326..05b1866afe 100644 --- a/tests/e2e/Services/Migrations/MigrationsBase.php +++ b/tests/e2e/Services/Migrations/MigrationsBase.php @@ -3377,11 +3377,6 @@ trait MigrationsBase 'x-appwrite-key' => $this->getDestinationProject()['apiKey'], ]; - // Configure a GitHub OAuth2 provider on the source. enabled=false keeps the - // PATCH from triggering live credential verification (enabling fires a real - // network call to the provider). The migration carries the readable clientId - // and the enabled flag; the clientSecret is write-only on the source API and - // is never migrated. $clientId = 'gh-client-' . ID::unique(); $configure = $this->client->call(Client::METHOD_PATCH, '/project/oauth2/github', $sourceKeyHeaders, [ 'clientId' => $clientId, @@ -3391,6 +3386,35 @@ trait MigrationsBase $this->assertEquals(200, $configure['headers']['status-code']); $this->assertSame($clientId, $configure['body']['clientId']); + $keycloak = $this->client->call(Client::METHOD_PATCH, '/project/oauth2/keycloak', $sourceKeyHeaders, [ + 'clientId' => 'keycloak-client-' . ID::unique(), + 'clientSecret' => 'keycloak-secret-not-migrated', + 'endpoint' => 'keycloak.example.com', + 'realmName' => 'appwrite', + 'enabled' => false, + ]); + $this->assertEquals(200, $keycloak['headers']['status-code']); + + $oidc = $this->client->call(Client::METHOD_PATCH, '/project/oauth2/oidc', $sourceKeyHeaders, [ + 'clientId' => 'oidc-client-' . ID::unique(), + 'clientSecret' => 'oidc-secret-not-migrated', + 'wellKnownURL' => 'https://idp.example.com/.well-known/openid-configuration', + 'authorizationURL' => 'https://idp.example.com/oauth2/authorize', + 'tokenURL' => 'https://idp.example.com/oauth2/token', + 'userInfoURL' => 'https://idp.example.com/oauth2/userinfo', + 'enabled' => false, + ]); + $this->assertEquals(200, $oidc['headers']['status-code']); + + $okta = $this->client->call(Client::METHOD_PATCH, '/project/oauth2/okta', $sourceKeyHeaders, [ + 'clientId' => 'okta-client-' . ID::unique(), + 'clientSecret' => 'okta-secret-not-migrated', + 'domain' => 'trial-6400025.okta.com', + 'authorizationServerId' => 'aus000000000000000h7z', + 'enabled' => false, + ]); + $this->assertEquals(200, $okta['headers']['status-code']); + $result = $this->performMigrationSync([ 'resources' => [ Resource::TYPE_OAUTH2_PROVIDER, @@ -3408,19 +3432,40 @@ trait MigrationsBase $this->assertEquals(0, $oauthCounters['pending']); $this->assertEquals(0, $oauthCounters['processing']); $this->assertEquals(0, $oauthCounters['warning']); - // Only configured providers migrate; this project set up GitHub alone. - $this->assertEquals(1, $oauthCounters['success']); + $this->assertEquals(4, $oauthCounters['success']); - // The GitHub provider must round-trip to the destination: the readable - // clientId and enabled flag are carried; the secret is write-only and reads - // back empty on every path. $fetched = $this->client->call(Client::METHOD_GET, '/project/oauth2/github', $destinationKeyHeaders); $this->assertEquals(200, $fetched['headers']['status-code']); $this->assertSame($clientId, $fetched['body']['clientId']); $this->assertFalse($fetched['body']['enabled']); $this->assertSame('', $fetched['body']['clientSecret']); - // Reset both projects so the test is idempotent. + $fetched = $this->client->call(Client::METHOD_GET, '/project/oauth2/keycloak', $destinationKeyHeaders); + $this->assertEquals(200, $fetched['headers']['status-code']); + $this->assertSame($keycloak['body']['clientId'], $fetched['body']['clientId']); + $this->assertSame('keycloak.example.com', $fetched['body']['endpoint']); + $this->assertSame('appwrite', $fetched['body']['realmName']); + $this->assertFalse($fetched['body']['enabled']); + $this->assertSame('', $fetched['body']['clientSecret']); + + $fetched = $this->client->call(Client::METHOD_GET, '/project/oauth2/oidc', $destinationKeyHeaders); + $this->assertEquals(200, $fetched['headers']['status-code']); + $this->assertSame($oidc['body']['clientId'], $fetched['body']['clientId']); + $this->assertSame('https://idp.example.com/.well-known/openid-configuration', $fetched['body']['wellKnownURL']); + $this->assertSame('https://idp.example.com/oauth2/authorize', $fetched['body']['authorizationURL']); + $this->assertSame('https://idp.example.com/oauth2/token', $fetched['body']['tokenURL']); + $this->assertSame('https://idp.example.com/oauth2/userinfo', $fetched['body']['userInfoURL']); + $this->assertFalse($fetched['body']['enabled']); + $this->assertSame('', $fetched['body']['clientSecret']); + + $fetched = $this->client->call(Client::METHOD_GET, '/project/oauth2/okta', $destinationKeyHeaders); + $this->assertEquals(200, $fetched['headers']['status-code']); + $this->assertSame($okta['body']['clientId'], $fetched['body']['clientId']); + $this->assertSame('trial-6400025.okta.com', $fetched['body']['domain']); + $this->assertSame('aus000000000000000h7z', $fetched['body']['authorizationServerId']); + $this->assertFalse($fetched['body']['enabled']); + $this->assertSame('', $fetched['body']['clientSecret']); + $this->client->call(Client::METHOD_PATCH, '/project/oauth2/github', $sourceKeyHeaders, [ 'clientId' => '', 'clientSecret' => '', @@ -3431,6 +3476,31 @@ trait MigrationsBase 'clientSecret' => '', 'enabled' => false, ]); + foreach ([$sourceKeyHeaders, $destinationKeyHeaders] as $headers) { + $this->client->call(Client::METHOD_PATCH, '/project/oauth2/keycloak', $headers, [ + 'clientId' => '', + 'clientSecret' => '', + 'endpoint' => '', + 'realmName' => '', + 'enabled' => false, + ]); + $this->client->call(Client::METHOD_PATCH, '/project/oauth2/oidc', $headers, [ + 'clientId' => '', + 'clientSecret' => '', + 'wellKnownURL' => '', + 'authorizationURL' => '', + 'tokenURL' => '', + 'userInfoURL' => '', + 'enabled' => false, + ]); + $this->client->call(Client::METHOD_PATCH, '/project/oauth2/okta', $headers, [ + 'clientId' => '', + 'clientSecret' => '', + 'domain' => '', + 'authorizationServerId' => '', + 'enabled' => false, + ]); + } } /** From 488a25efb819542a2db3a155877bbd5f0617a3e0 Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Thu, 4 Jun 2026 06:23:22 +0100 Subject: [PATCH 11/11] Use released migration dependency --- composer.json | 2 +- composer.lock | 17 ++++++++--------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/composer.json b/composer.json index 07cb56b58b..b78637ccd9 100644 --- a/composer.json +++ b/composer.json @@ -75,7 +75,7 @@ "utopia-php/lock": "0.2.*", "utopia-php/logger": "0.8.*", "utopia-php/messaging": "1.0.*", - "utopia-php/migration": "dev-add-oauth-providers-migration", + "utopia-php/migration": "1.*", "utopia-php/platform": "1.0.0-rc4", "utopia-php/pools": "1.*", "utopia-php/span": "1.1.*", diff --git a/composer.lock b/composer.lock index eb74739408..79cee0b33e 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "5d6823938d39a2ddbd3c40ada5fca362", + "content-hash": "0c23c30bba86ad84377d4d1abce0992a", "packages": [ { "name": "adhocore/jwt", @@ -4658,16 +4658,16 @@ }, { "name": "utopia-php/migration", - "version": "dev-add-oauth-providers-migration", + "version": "1.13.2", "source": { "type": "git", "url": "https://github.com/utopia-php/migration.git", - "reference": "dede00a186d30265318c7d7e82c85907584878ca" + "reference": "50526e121efcf73e11309446f194623a431d7e32" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/migration/zipball/dede00a186d30265318c7d7e82c85907584878ca", - "reference": "dede00a186d30265318c7d7e82c85907584878ca", + "url": "https://api.github.com/repos/utopia-php/migration/zipball/50526e121efcf73e11309446f194623a431d7e32", + "reference": "50526e121efcf73e11309446f194623a431d7e32", "shasum": "" }, "require": { @@ -4707,9 +4707,9 @@ ], "support": { "issues": "https://github.com/utopia-php/migration/issues", - "source": "https://github.com/utopia-php/migration/tree/add-oauth-providers-migration" + "source": "https://github.com/utopia-php/migration/tree/1.13.2" }, - "time": "2026-06-03T12:59:34+00:00" + "time": "2026-06-04T05:09:07+00:00" }, { "name": "utopia-php/mongo", @@ -8574,8 +8574,7 @@ "aliases": [], "minimum-stability": "dev", "stability-flags": { - "utopia-php/http": 5, - "utopia-php/migration": 20 + "utopia-php/http": 5 }, "prefer-stable": true, "prefer-lowest": false,