Repository navigation
fix(previews): validate authorize parameters - #14013
Conversation
`/_appwrite/authorize` appended the `path` query parameter to the host origin as-is and took the scheme from the referer. Require the path to be root-relative, matching what the proxy builds it from, default it to `/`, and use the request protocol so the cookie flags and the redirect agree with the request that reached the host. Co-Authored-By: Claude Fable 5.1 <[email protected]>
🟢 Tier S · Ready to merge
The preview authorization route validates redirect paths as root-relative strings, defaults empty paths to Latest changes: The newest commits add a string-type guard for array-valued paths and e2e cases for array rejection and missing or empty path defaults.
📂 Walkthrough · 2
✅ Fixed since the last review · 1
Reviewed the commits since |
|
A `path[]=` query hands `getParam()` an array, which the string checks would trip over; reject it with the same 400 as any other invalid path. Also assert that a missing or empty path redirects to the site root. Co-Authored-By: Claude Fable 5.1 <[email protected]>
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
Brings in main's OAuth2 state and nonce validation (#14012), which cloud needs, along with the realtime origin alignment (#14020), subscriber target ownership (#14019), GitLab primary email (#14010), impersonation MFA (#14017), write-only webhook passwords (#14016), chunked-upload resume ownership (#14014), preview authorize validation (#14013), nightly forcing (#14015) and scheduled-function enqueue checks (#14011). The merge had no textual conflicts, and main left composer.json and composer.lock unchanged. So the lock keeps the branch's database and async pins. Main's assertResumeAllowed() in Storage Buckets/Files/Create checks Input(Database::PERMISSION_UPDATE, ...). utopia-php/database 8 has no PERMISSION_* constants, so every chunked resume would fail with an undefined-constant error. It now passes PermissionType::Update, as the rest of that action already does. Co-Authored-By: Claude Opus 5.5 <[email protected]>
What does this PR do?
The preview
/_appwrite/authorizeroute appended itspathquery parameter to the host origin without checking its shape, and derived the scheme from theReferer/Originheader rather than from the request itself.pathto be root-relative. The proxy builds it fromrequest_uri(+ query string), so that is the only shape it ever legitimately has; an empty value defaults to/, anything else is rejected with400 general_argument_invalid.$request->getProtocol(), the same source the proxy uses when it builds theoriginit hands to the console, so the cookie'sSecureflag and the redirect match the request that actually arrived.locationon the success path and cover the rejected shapes.Test Plan
composer linton both files,composer analyze app/controllers/general.phpandcomposer refactor:checkpass locally.tests/e2e/Services/Sites/SitesCustomServerTest::testPreviewDomainextended with the successlocationassertion and a set of rejectedpathvalues; runs in CI.Related PRs and Issues
Checklist
🤖 Generated with Claude Code