Repository navigation
Unbound user JWT authenticates nobody instead of failing the request - #14002
Conversation
#13992 threw user_jwt_invalid when a JWT was not issued for the request's project. A function domain resolves to the console, and clients send their own project's JWT there for the function to read, so every such request got 401 before reaching the function. The token still grants nothing: the request continues as a guest, as it did before #13992. Co-Authored-By: Claude Opus 5.5 <[email protected]>
🟢 Tier S · Ready to merge
An unbound user JWT no longer throws
📂 Walkthrough · 3
Reviewed |
|
| 'content-type' => 'application/json', | ||
| 'x-appwrite-jwt' => $jwt['body']['jwt'], | ||
| ]); | ||
| $this->assertEquals(200, $response['headers']['status-code']); |
There was a problem hiding this comment.
JWT forwarding goes untested The test sends
x-appwrite-jwt but checks only for a 200 response. The deployed cookies function reads the cookie header, not the JWT, so this test would still pass if the JWT were dropped before the function could read it. Assert the JWT value through the function response to cover the stated use case.
Prompt To Fix With AI
This is a comment left during a code review.
Path: tests/e2e/Services/Functions/FunctionsCustomServerTest.php
Line: 3032
Comment:
**JWT forwarding goes untested** The test sends `x-appwrite-jwt` but checks only for a 200 response. The deployed `cookies` function reads the `cookie` header, not the JWT, so this test would still pass if the JWT were dropped before the function could read it. Assert the JWT value through the function response to cover the stated use case.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
Follow-up to #13992.
What
When a user JWT isn't bound to the request's project, the HTTP
userresource and the realtime connection threwuser_jwt_invalid. A function domain resolves to projectconsole, and clients send their own project's JWT there for the function to read. Every such request now got a 401 before reaching the function.An unbound JWT now authenticates nobody, and the request continues as a guest, which is what it did before #13992. A user is still never loaded from an unbound token, so cross-project and console replays still end in 401 (as a guest missing scope). The existing binding tests are unchanged and pass.
Tests
New
FunctionsCustomServerTest::testFunctionsDomainServesRequestCarryingAnotherProjectsJwtcalls a function domain with another project's JWT. Run locally:main: 401;UsersCustomServerTest's cross-project, legacy, admin-mode and original JWT tests still pass (4/4).🤖 Generated with Claude Code