From dbf96ad20473b7cd248e6ae421e9df759d6d5aec Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Fri, 18 Sep 2026 13:03:04 +0100 Subject: [PATCH 1/2] fix(account): offer only ID token providers on the ID token session The route described `apple, google` while whitelisting all 52 OAuth providers and generating the shared `OAuthProvider` enum, so an SDK offered every provider on this method and the docs example was `amazon`. Sending any of them passed validation and then failed in the action with PROJECT_PROVIDER_UNSUPPORTED. The whitelist now holds the providers that configure `idToken`, and the parameter generates its own `IdTokenProvider` enum. The mock providers stay whitelisted, since the e2e suites sign in with them, and the generated enum keeps excluding them, so it reads `apple, google`. --- .../Http/Account/Sessions/IdToken/Create.php | 5 ++-- .../Modules/Account/IdTokenSessionTest.php | 27 +++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 tests/unit/Platform/Modules/Account/IdTokenSessionTest.php diff --git a/src/Appwrite/Platform/Modules/Account/Http/Account/Sessions/IdToken/Create.php b/src/Appwrite/Platform/Modules/Account/Http/Account/Sessions/IdToken/Create.php index 05488e3931..d301b1492e 100644 --- a/src/Appwrite/Platform/Modules/Account/Http/Account/Sessions/IdToken/Create.php +++ b/src/Appwrite/Platform/Modules/Account/Http/Account/Sessions/IdToken/Create.php @@ -53,7 +53,8 @@ class Create extends Action public function __construct() { $providers = Config::getParam('oAuthProviders', []); - $idTokenProviders = \array_keys(\array_filter($providers, fn ($node) => !empty($node['idToken']) && empty($node['mock']))); + $idTokenProviders = \array_keys(\array_filter($providers, fn ($node) => !empty($node['idToken']))); + $documentedProviders = \array_filter($idTokenProviders, fn (string $provider) => empty($providers[$provider]['mock'])); $this ->setHttpMethod(Action::HTTP_REQUEST_METHOD_POST) @@ -84,7 +85,7 @@ class Create extends Action ->label('abuse-limit', 10) ->label('abuse-key', 'url:{url},ip:{ip}') ->label('abuse-reset', [201]) - ->param('provider', '', new WhiteList(\array_keys($providers), true), 'OAuth2 provider that issued the ID token. Currently, supported providers are: ' . \implode(', ', $idTokenProviders) . '.', enum: new Enum(name: 'OAuthProvider', exclude: ['mock', 'mock-unverified'])) + ->param('provider', '', new WhiteList($idTokenProviders, true), 'OAuth2 provider that issued the ID token. Currently, supported providers are: ' . \implode(', ', $documentedProviders) . '.', enum: new Enum(name: 'IdTokenProvider', exclude: ['mock', 'mock-unverified'])) ->param('idToken', '', new Text(8192, 0), 'OpenID Connect ID token (JWT) obtained natively from the provider, for example via Google Credential Manager or Sign in with Apple.') ->param('nonce', '', new Text(256, 0), 'Raw nonce used when requesting the ID token. Required for Apple, and whenever the token carries a nonce claim, which must match it. Ignored when the provider issued the token without a nonce.', true) ->param('accessToken', '', new Text(4096, 0), 'Provider access token to store alongside the session for calling provider APIs. Never used for authentication.', true) diff --git a/tests/unit/Platform/Modules/Account/IdTokenSessionTest.php b/tests/unit/Platform/Modules/Account/IdTokenSessionTest.php new file mode 100644 index 0000000000..70e75509c2 --- /dev/null +++ b/tests/unit/Platform/Modules/Account/IdTokenSessionTest.php @@ -0,0 +1,27 @@ + !empty($node['idToken']))); + + $parameter = (new Create())->getParams()['provider']; + $validator = $parameter['validator']; + $validator = \is_callable($validator) ? $validator() : $validator; + + $this->assertSame($expected, $validator->getList()); + $this->assertNotContains('amazon', $validator->getList()); + $this->assertStringContainsString('apple, google', $parameter['description']); + $this->assertSame('IdTokenProvider', $parameter['enum']->name); + } +} From cf1e3b254b0b467e079ed517126e3862f6fa362b Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Fri, 18 Sep 2026 13:04:46 +0100 Subject: [PATCH 2/2] test: drop the ID token provider unit test --- .../Modules/Account/IdTokenSessionTest.php | 27 ------------------- 1 file changed, 27 deletions(-) delete mode 100644 tests/unit/Platform/Modules/Account/IdTokenSessionTest.php diff --git a/tests/unit/Platform/Modules/Account/IdTokenSessionTest.php b/tests/unit/Platform/Modules/Account/IdTokenSessionTest.php deleted file mode 100644 index 70e75509c2..0000000000 --- a/tests/unit/Platform/Modules/Account/IdTokenSessionTest.php +++ /dev/null @@ -1,27 +0,0 @@ - !empty($node['idToken']))); - - $parameter = (new Create())->getParams()['provider']; - $validator = $parameter['validator']; - $validator = \is_callable($validator) ? $validator() : $validator; - - $this->assertSame($expected, $validator->getList()); - $this->assertNotContains('amazon', $validator->getList()); - $this->assertStringContainsString('apple, google', $parameter['description']); - $this->assertSame('IdTokenProvider', $parameter['enum']->name); - } -}