Skip to content

Commit c0d8a2b

Browse files
committed
fix(sdk): return-to vectors cover the root and an empty path, and the guides explain query decoding
1 parent 4ff80d5 commit c0d8a2b

5 files changed

Lines changed: 30 additions & 4 deletions

File tree

‎crates/crypto/tests/sdk_vectors.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1410,6 +1410,7 @@ impl Vectors {
14101410
let longest = format!("/{}", "a".repeat(2047));
14111411
let too_long = format!("{longest}a");
14121412
for (name, description, return_to, accepted) in [
1413+
("root", "the site root is accepted", "/".into(), true),
14131414
(
14141415
"printable-ascii",
14151416
"every printable ASCII character but \\ and # is accepted",
@@ -1477,6 +1478,7 @@ impl Vectors {
14771478
"/notes#x".into(),
14781479
false,
14791480
),
1481+
("empty", "an empty path is refused", String::new(), false),
14801482
(
14811483
"relative",
14821484
"a path not starting with / is refused",

‎docs/user/apps/sign-in-rust.md‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,11 @@ route that reads the session. `ended`, the sessions auth ended, is the state of
5959
The router serves:
6060

6161
- `GET /auth/login?return_to=/page` sends the browser to auth, and back to
62-
`/page` once signed in. `return_to` must be a path on your app, percent-encoded
63-
as a URL holds it: a raw space or non-ASCII character returns home instead.
62+
`/page` once signed in. `return_to` must be a path on your app, in printable
63+
ASCII once the query is decoded, or sign-in returns home instead. To
64+
return to a path with a space or non-ASCII character, percent-encode it in
65+
the path, then encode the whole path again as the query parameter:
66+
`return_to=%2Fcaf%25C3%25A9` reaches the check as `/caf%C3%A9`.
6467
- `GET /auth/callback` completes the sign-in and sets the session cookie.
6568
- `POST /auth/logout` signs the user out.
6669

‎docs/user/apps/sign-in-typescript.md‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,11 @@ which also defines the small helpers they call, `env`, `page` and `escape`.
6565
`login.handle` answers the login routes and returns `null` for any other request:
6666

6767
- `GET /auth/login?return_to=/page` sends the browser to auth, and back to
68-
`/page` once signed in. `return_to` must be a path on your app, percent-encoded
69-
as a URL holds it: a raw space or non-ASCII character returns home instead.
68+
`/page` once signed in. `return_to` must be a path on your app, in printable
69+
ASCII once the query is decoded, or sign-in returns home instead. To
70+
return to a path with a space or non-ASCII character, percent-encode it in
71+
the path, then encode the whole path again as the query parameter:
72+
`return_to=%2Fcaf%25C3%25A9` reaches the check as `/caf%C3%A9`.
7073
- `GET /auth/callback` completes the sign-in and sets the session cookie.
7174
- `POST /auth/logout` signs the user out.
7275

‎tests/sdk-vectors/return-to/empty.json‎

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎tests/sdk-vectors/return-to/root.json‎

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)