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); + } +}