Commit 019abcf
authored
fix: use opaque state parameter in OAuth authorization flow (#41)
* fix: use opaque state parameter in OAuth authorization flow
Replace base64-encoded AuthRequest in the OAuth state parameter with
an opaque UUID token. The full AuthRequest is already stored in KV
via createOAuthState() — embedding it in the URL was redundant and
caused authorization URLs to exceed Cloudflare's size limits when
combined with CIMD client IDs or many scopes.
Security is unchanged: state is still validated via KV lookup +
SHA-256 session cookie binding + single-use deletion.
* test: assert opaque OAuth state token in e2e + unit coverage
Update OAuth tests for the opaque-state-token contract:
- cloudflare-auth.test.ts: getAuthorizationURL now takes stateToken and
passes it through verbatim (no base64 AuthRequest).
- oauth-routes.test.ts full-flow: assert the state forwarded to Cloudflare
is opaque, not a base64-encoded AuthRequest.
- oauth-routes.test.ts reject case: use a plain opaque token now that state
is the KV lookup key directly.
* test: harden opaque OAuth state flow
* fix: accept in-flight legacy OAuth state1 parent 13023f8 commit 019abcf
5 files changed
Lines changed: 220 additions & 96 deletions
File tree
- src/auth
- tests/auth
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | | - | |
5 | 3 | | |
6 | 4 | | |
7 | 5 | | |
| |||
71 | 69 | | |
72 | 70 | | |
73 | 71 | | |
74 | | - | |
| 72 | + | |
75 | 73 | | |
76 | 74 | | |
77 | 75 | | |
| |||
80 | 78 | | |
81 | 79 | | |
82 | 80 | | |
83 | | - | |
| 81 | + | |
84 | 82 | | |
85 | 83 | | |
86 | 84 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
558 | 558 | | |
559 | 559 | | |
560 | 560 | | |
561 | | - | |
562 | 561 | | |
563 | 562 | | |
564 | 563 | | |
565 | 564 | | |
566 | 565 | | |
567 | | - | |
568 | | - | |
569 | | - | |
570 | | - | |
571 | | - | |
572 | 566 | | |
573 | 567 | | |
574 | 568 | | |
575 | | - | |
| 569 | + | |
576 | 570 | | |
577 | 571 | | |
578 | 572 | | |
| |||
617 | 611 | | |
618 | 612 | | |
619 | 613 | | |
620 | | - | |
621 | | - | |
622 | | - | |
623 | | - | |
624 | | - | |
625 | | - | |
626 | | - | |
627 | | - | |
628 | | - | |
629 | | - | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
630 | 617 | | |
631 | 618 | | |
632 | 619 | | |
| |||
691 | 678 | | |
692 | 679 | | |
693 | 680 | | |
694 | | - | |
695 | 681 | | |
696 | 682 | | |
697 | 683 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
13 | 43 | | |
14 | 44 | | |
15 | 45 | | |
| |||
449 | 479 | | |
450 | 480 | | |
451 | 481 | | |
452 | | - | |
| 482 | + | |
453 | 483 | | |
454 | 484 | | |
455 | 485 | | |
| |||
1469 | 1499 | | |
1470 | 1500 | | |
1471 | 1501 | | |
1472 | | - | |
| 1502 | + | |
1473 | 1503 | | |
1474 | 1504 | | |
1475 | 1505 | | |
| |||
1754 | 1784 | | |
1755 | 1785 | | |
1756 | 1786 | | |
1757 | | - | |
1758 | | - | |
1759 | | - | |
1760 | | - | |
1761 | | - | |
1762 | | - | |
1763 | | - | |
1764 | | - | |
1765 | | - | |
1766 | | - | |
| 1787 | + | |
| 1788 | + | |
| 1789 | + | |
1767 | 1790 | | |
1768 | 1791 | | |
1769 | 1792 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
95 | | - | |
96 | | - | |
| 95 | + | |
| 96 | + | |
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
100 | | - | |
| 100 | + | |
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
| |||
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
114 | | - | |
115 | | - | |
| 114 | + | |
| 115 | + | |
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
| |||
0 commit comments