From ff8a99e6d56e64f3bcb8e3f0a2783f323aad5260 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Wed, 19 Aug 2026 10:37:09 +0200 Subject: [PATCH] Add Hugging Face OAuth2 provider to migration allow-list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Appwrite server is adding a built-in 'huggingface' OAuth2 provider (appwrite/appwrite#13123). Without an entry in the PROVIDERS allow-list, migrations fail with "No migration resource for OAuth2 provider 'huggingface'; skipped." — fromArray() returns null before the isConfigured() check, so the error fires even on projects that never configured the provider, failing the whole migration. Only clientId migrates (to the huggingfaceAppid attribute); clientSecret is write-only and stays redacted per the existing policy. Hugging Face uses the default clientId/clientSecret field names and has no extra settings, so there are no TARGET_SECRET fields. Co-Authored-By: Claude Opus 5 (1M context) --- .../Resources/Auth/OAuth2/OAuth2Provider.php | 1 + .../Unit/Resources/OAuth2ProviderTest.php | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/Migration/Resources/Auth/OAuth2/OAuth2Provider.php b/src/Migration/Resources/Auth/OAuth2/OAuth2Provider.php index e029dbdf..54c2ee00 100644 --- a/src/Migration/Resources/Auth/OAuth2/OAuth2Provider.php +++ b/src/Migration/Resources/Auth/OAuth2/OAuth2Provider.php @@ -49,6 +49,7 @@ final class OAuth2Provider extends Resource 'github' => ['clientId' => ['target' => self::TARGET_APP_ID]], 'gitlab' => ['clientId' => ['target' => self::TARGET_APP_ID], 'endpoint' => ['target' => self::TARGET_SECRET]], 'google' => ['clientId' => ['target' => self::TARGET_APP_ID], 'prompt' => ['target' => self::TARGET_SECRET]], + 'huggingface' => ['clientId' => ['target' => self::TARGET_APP_ID]], 'keycloak' => [ 'clientId' => ['target' => self::TARGET_APP_ID], 'endpoint' => ['target' => self::TARGET_SECRET, 'key' => 'keycloakDomain'], diff --git a/tests/Migration/Unit/Resources/OAuth2ProviderTest.php b/tests/Migration/Unit/Resources/OAuth2ProviderTest.php index c24a06cc..c74b009b 100644 --- a/tests/Migration/Unit/Resources/OAuth2ProviderTest.php +++ b/tests/Migration/Unit/Resources/OAuth2ProviderTest.php @@ -25,6 +25,24 @@ public function testFromArrayAppwrite(): void $this->assertTrue($provider->isConfigured()); } + public function testFromArrayHuggingFace(): void + { + $provider = OAuth2Provider::fromArray('huggingface', [ + 'id' => 'huggingface', + 'enabled' => true, + 'clientId' => 'client-123', + 'clientSecret' => 'super-secret', + ]); + + $this->assertNotNull($provider); + $this->assertEquals('huggingface', $provider->getProviderKey()); + $this->assertTrue($provider->getEnabled()); + $this->assertEquals(['clientId' => 'client-123'], $provider->getSettings()); + $this->assertEquals('client-123', $provider->getDestinationAppId()); + $this->assertEquals([], $provider->getDestinationSecretFields()); + $this->assertTrue($provider->isConfigured()); + } + public function testFromArrayNeverCopiesSecrets(): void { foreach (\array_keys(OAuth2Provider::PROVIDERS) as $providerKey) {