Repository navigation
Commit 842e862
authored
fix(sdk): the TypeScript SDK's same-origin check refuses Origin: null (#552)
If an app's redirect URI has an opaque origin, such as
`com.example.app:/callback`, the TypeScript SDK let a request with
`Origin: null` and no `Sec-Fetch-Site` through its CSRF check on logout
and `session()`. That's because `new URL(...).origin` is the string
`"null"` for such a URI. The Rust SDK refuses this request.
Now the TypeScript check refuses `Origin: null` too: a URI whose origin
is `null` matches nothing, as in Rust (`BrowserRequest::is_same_origin`
requires a tuple origin).
Both SDKs now run the rule from a new `same-origin/` category in
`tests/sdk-vectors`, which includes the opaque case. Without the fix,
the TypeScript SDK fails `opaque-origin-null.json`. The SDK architecture
page and the doc comment on `#sameOrigin` now describe the case.
Closes #548
> [!NOTE]
> Written by Claude Opus 5.5 in Claude Code (via T3 Code); reviewed by
GPT 6.1 Sol
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->
**TypeScript SDK (`packages/auth/src/login.ts`)**
- `Login.#sameOrigin` now refuses an `Origin` comparison when the
redirect URI origin is `"null"`.
- Before this change, a request with `Origin: null` and no
`Sec-Fetch-Site` passed for opaque redirect URIs such as
`com.example.app:/callback`.
- The code comment now states that `null` never matches, including for
opaque redirect-URI origins.
**TypeScript tests (`packages/auth/test/vectors.test.ts`)**
- Adds a `same-origin vectors` test group.
- For each case, the test builds a POST request with the case's
`sec-fetch-site` and `origin` headers and checks whether `login.session`
returns a session or a `Response`.
**Shared vectors (`tests/sdk-vectors/same-origin/`,
`tests/sdk-vectors/README.md`)**
- Adds nine `same-origin` cases: `cross-site`, `fetch-site-only`,
`no-headers`, `no-referrer-form`, `opaque-origin-null`, `origin-null`,
`origin-only`, `same-site`, and `sibling-origin`.
- `opaque-origin-null.json` covers the opaque redirect URI case and
expects `ok: false`.
- The README category table documents the new category and its inputs.
**Rust tests (`crates/auth-sdk/src/tests.rs`)**
- Adds a `same_origin_vectors` test.
- The test loads the `same-origin` cases and compares `is_same_origin`
with each expected result.
**Rust vector generator (`crates/crypto/tests/sdk_vectors.rs`)**
- Adds a `same_origin` generator that records expected results for the
app origin.
- `Vectors::finish` now includes the `same-origin` directory.
**Documentation (`docs/dev/architecture/sdk.md`)**
- The Sessions section states that `Origin` must equal the redirect URI
origin.
- It states that `null` never matches, including for opaque redirect-URI
origins.
**Public API**
- No exported or public declarations changed.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->1 parent e24ecd3 commit 842e862
15 files changed
Lines changed: 249 additions & 6 deletions
File tree
- crates
- auth-sdk/src
- crypto/tests
- docs/dev/architecture
- packages/auth
- src
- test
- tests/sdk-vectors
- same-origin
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
311 | 312 | | |
312 | 313 | | |
313 | 314 | | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
314 | 331 | | |
315 | 332 | | |
316 | 333 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
168 | 168 | | |
169 | 169 | | |
170 | 170 | | |
| 171 | + | |
171 | 172 | | |
172 | 173 | | |
173 | 174 | | |
| |||
1302 | 1303 | | |
1303 | 1304 | | |
1304 | 1305 | | |
| 1306 | + | |
| 1307 | + | |
| 1308 | + | |
| 1309 | + | |
| 1310 | + | |
| 1311 | + | |
| 1312 | + | |
| 1313 | + | |
| 1314 | + | |
| 1315 | + | |
| 1316 | + | |
| 1317 | + | |
| 1318 | + | |
| 1319 | + | |
| 1320 | + | |
| 1321 | + | |
| 1322 | + | |
| 1323 | + | |
| 1324 | + | |
| 1325 | + | |
| 1326 | + | |
| 1327 | + | |
| 1328 | + | |
| 1329 | + | |
| 1330 | + | |
| 1331 | + | |
| 1332 | + | |
| 1333 | + | |
| 1334 | + | |
| 1335 | + | |
| 1336 | + | |
| 1337 | + | |
| 1338 | + | |
| 1339 | + | |
| 1340 | + | |
| 1341 | + | |
| 1342 | + | |
| 1343 | + | |
| 1344 | + | |
| 1345 | + | |
| 1346 | + | |
| 1347 | + | |
| 1348 | + | |
| 1349 | + | |
| 1350 | + | |
| 1351 | + | |
| 1352 | + | |
| 1353 | + | |
| 1354 | + | |
| 1355 | + | |
| 1356 | + | |
| 1357 | + | |
| 1358 | + | |
| 1359 | + | |
| 1360 | + | |
| 1361 | + | |
| 1362 | + | |
| 1363 | + | |
| 1364 | + | |
| 1365 | + | |
| 1366 | + | |
| 1367 | + | |
| 1368 | + | |
| 1369 | + | |
| 1370 | + | |
| 1371 | + | |
| 1372 | + | |
| 1373 | + | |
| 1374 | + | |
| 1375 | + | |
| 1376 | + | |
| 1377 | + | |
| 1378 | + | |
| 1379 | + | |
| 1380 | + | |
| 1381 | + | |
| 1382 | + | |
| 1383 | + | |
| 1384 | + | |
| 1385 | + | |
| 1386 | + | |
| 1387 | + | |
| 1388 | + | |
| 1389 | + | |
| 1390 | + | |
| 1391 | + | |
| 1392 | + | |
| 1393 | + | |
| 1394 | + | |
| 1395 | + | |
| 1396 | + | |
| 1397 | + | |
| 1398 | + | |
| 1399 | + | |
| 1400 | + | |
| 1401 | + | |
1305 | 1402 | | |
1306 | 1403 | | |
1307 | 1404 | | |
| |||
1589 | 1686 | | |
1590 | 1687 | | |
1591 | 1688 | | |
| 1689 | + | |
1592 | 1690 | | |
1593 | 1691 | | |
1594 | 1692 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
392 | 392 | | |
393 | 393 | | |
394 | 394 | | |
395 | | - | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
396 | 398 | | |
397 | 399 | | |
398 | 400 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
747 | 747 | | |
748 | 748 | | |
749 | 749 | | |
750 | | - | |
751 | | - | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
752 | 753 | | |
753 | 754 | | |
754 | 755 | | |
755 | 756 | | |
756 | | - | |
| 757 | + | |
| 758 | + | |
757 | 759 | | |
758 | 760 | | |
759 | 761 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| |||
166 | 167 | | |
167 | 168 | | |
168 | 169 | | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
169 | 193 | | |
170 | 194 | | |
171 | 195 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| 49 | + | |
49 | 50 | | |
50 | 51 | | |
51 | 52 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments