Repository navigation
fix(login): tell the reader why the browser viewer refused their link - #6
Merged
Merged
Conversation
`--web` mints a token for every session and puts it in the link, so the browser keeps the old link in its history and offers it back in the address bar. The next session refuses it with `wrong token`, two words in plain text: true, and no help at all. The reader cannot tell it from a broken viewer, and the one thing they have to do — take the link this run printed — is not in it. A refused page load now answers with a page that says the link belongs to an older session, that the terminal printed the current one, and that the address bar completes the stale one. The paths the script calls keep the plain body, because it reads the status and never the text. The printed instructions say the same thing, at the point where the reader is about to copy the link.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What breaks today
login --webmints a token for every session and puts it in the link. Thebrowser keeps that link in its history and offers it back in the address bar, so
the next session gets a token that has expired with the session that minted it.
The viewer answers
403 Forbiddenwith a body of two words,wrong token, intext/plain.Those two words are true and useless. The reader cannot tell them from a broken
viewer, and the one thing they have to do — take the link that this run printed —
is not in them.
What this changes
A refused page load (
GET /) now answers with a page that says three things:the link belongs to a session that has ended, the terminal printed the current
one, and the address bar completes the stale one.
The paths the script itself calls (
/delta,/input,/quit) keep the plainbody, because the script reads the status code and never the text. The token
check, the constant-time comparison and the per-session token are unchanged: this
touches the message and nothing about what the viewer lets through.
print_urlsays the same thing at the point where the reader is about to copythe link.
Tests
token's length, and that it no longer holds the string it replaces.
a_browser_client_sees_the_display_and_types_into_itnowasserts that
/deltawith a wrong token keeps the plain body, and that a pageload with a stale token gets the page.
cargo test --lib: 75 passed.cargo test --lib -- --ignored a_browser_client:passed against a real Xvfb display.
cargo fmt --checkandcargo clippy --lib -- -W clippy::all: clean.I also drove the server with a real browser to confirm the diagnosis: a correct
link serves the display and polls
/deltaat 200, and a token from an earliersession renders the bare
wrong tokenpage that this replaces.