Repository navigation
feat(oauth2): add Webflow provider - #13946
Conversation
Sign in with a Webflow account through the authorization code flow: authorize at webflow.com/oauth/authorize, exchange the code at api.webflow.com/oauth/access_token, and read the account from /v2/token/authorized_by under the authorized_user:read scope. Webflow returns no refresh token and exposes no refresh grant, so refreshTokens has nothing to exchange.
The provider list resolves each entry by matching its $id against the candidate models named in OAuth2ProviderList, so a provider missing from that union makes GET /v1/project/oauth2 throw "Missing model for rule" for every project. Add Webflow there, and to the SDK response model list on the per-provider get so the generated spec carries its shape. Also place the entry after WordPress in the four descending registries it was inserted ahead of.
🔵 Tier A · Mergeable after minor fixes
Adds Webflow OAuth2 login and project configuration, including provider registration, response models, and SDK metadata. The newest commit adds a credential check when Webflow is enabled, using an intentionally invalid authorization code at Webflow’s token endpoint. Latest changes: The newest commit adds
📂 Walkthrough · 10
Reviewed the commits since |
|
| public static function getProviderClass(): string | ||
| { | ||
| return Webflow::class; | ||
| } |
There was a problem hiding this comment.
Invalid credentials can enable Webflow
When a project enables Webflow with a non-empty but invalid client ID or secret, the update succeeds and marks sign-in as enabled. The shared update path checks credentials only when the adapter implements verifyCredentials(), which Webflow does not. This contradicts the endpoint’s promise to reject invalid credentials and can offer users a sign-in method that fails at the provider.
Knowledge Base Used: Project administration
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/Appwrite/Platform/Modules/Project/Http/Project/OAuth2/Webflow/Update.php
Line: 16-19
Comment:
**Invalid credentials can enable Webflow**
When a project enables Webflow with a non-empty but invalid client ID or secret, the update succeeds and marks sign-in as enabled. The shared update path checks credentials only when the adapter implements `verifyCredentials()`, which Webflow does not. This contradicts the endpoint’s promise to reject invalid credentials and can offer users a sign-in method that fails at the provider.
**Knowledge Base Used:** [Project administration](https://app.greptile.com/appwrite/-/custom-context/knowledge-base/appwrite/appwrite/-/docs/project-administration.md)
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.| public function getUserID(string $accessToken): string | ||
| { | ||
| $user = $this->getUser($accessToken); | ||
|
|
||
| return $user['id'] ?? ''; |
There was a problem hiding this comment.
Webflow behavior lacks test coverage
No Webflow-specific test exercises token responses, identity lookup, or the new project update/get/list round trip. A mismatch in provider data or a broken public route could therefore go unnoticed. Cover observable results with stubbed provider responses rather than assertions that mirror source code or configuration.
Knowledge Base Used:
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/Appwrite/Auth/OAuth2/Webflow.php
Line: 101-105
Comment:
**Webflow behavior lacks test coverage**
No Webflow-specific test exercises token responses, identity lookup, or the new project update/get/list round trip. A mismatch in provider data or a broken public route could therefore go unnoticed. Cover observable results with stubbed provider responses rather than assertions that mirror source code or configuration.
**Knowledge Base Used:**
- [Account authentication and identity](https://app.greptile.com/appwrite/-/custom-context/knowledge-base/appwrite/appwrite/-/docs/account-authentication.md)
- [API platform and request surface](https://app.greptile.com/appwrite/-/custom-context/knowledge-base/appwrite/appwrite/-/docs/api-platform.md)
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
| $json = \json_decode((string) $response->getBody(), true); | ||
|
|
||
| if (isset($json['error']) && $json['error'] === 'invalid_client') { | ||
| throw new \Exception('Webflow application with the provided Client ID and/or Client Secret is invalid.'); |
There was a problem hiding this comment.
Reject unexpected token responses during credential verification
If Webflow returns a 5xx or a non-JSON response, sendRequest() still returns it and this check treats it as valid credentials. An explicit enabled: true update then persists Webflow as enabled without ever having verified the client; only a recognized token error should count as a successful check.
🟡 Minor · error-handling · Reply if this doesn't apply.
| return $this->user; | ||
| } | ||
|
|
||
| public function verifyCredentials(): void |
There was a problem hiding this comment.
Cover Webflow credential validation through the project API
The new check decides whether the project update accepts credentials, but there is no Webflow success/failure coverage alongside the existing project OAuth2 API tests (tests/e2e/Services/Project/OAuth2Base.php). A regression that lets invalid credentials enable Webflow would not be caught by the current suite.
🟡 Minor · testing · Reply if this doesn't apply.
What does this PR do?
Adds Webflow as an OAuth2 provider.
A provider needs seven touch points on current main, found by reading the Kick adapter's own commit (
15f94d99ca): the adapter, the config entry, a Response model plus itsMODEL_constant, registration inapp/init/models.php, a per-provider Project OAuth2Updateaction, its entry inBase::getProviderActions(), and itsaddActioninProject\Services\Http. It also has to appear in theOAuth2ProviderListunion and in the SDK response model list on the per-provider get.The adapter follows
Twitch.phprather thanKick.php, since Webflow documents no PKCE. Endpoints were taken from Webflow's own documentation rather than assumed: authorizehttps://webflow.com/oauth/authorize, tokenhttps://api.webflow.com/oauth/access_token, userhttps://api.webflow.com/v2/token/authorized_by.refreshTokens()is a no-op because Webflow exposes no refresh grant. It is unreachable in practice — the session refresh path is guarded on a non-empty refresh token, and Webflow never issues one.Test Plan
composer linton all changed files →{"tool":"pint","result":"passed"}vendor/bin/phpunit tests/unit/Auth/OAuth2 tests/unit/General/OAuthProvidersTest.php→ 95 tests, 414 assertions, passing, run and watched. The one warning is environmental (Swoole\Timerabsent on the host) and reproduces on unmodified code.Response::output()path rather than assuming:OAuth2Webflowdeclares'$id' => 'webflow'and is now named in theOAuth2ProviderListunion, which is whatoutput()matches against.Worth noting for reviewers: the first cut of this change registered the provider everywhere except the
OAuth2ProviderListunion. Becauseoutput()resolves each list entry by matching$idagainst the union's candidate models, that would have madeGET /v1/project/oauth2return 500 for every project on the instance, not just ones using Webflow. It is fixed here, and an audit of all 48 enabled providers confirmed Webflow was the only one missing from that union.Related PRs and Issues
Checklist