Expand description
Browser sessions: an account signs its own browser in, so the authorize
page can hand a code only to a browser signed in as the account a sign-in
names. See plan/browser-binding.md.
The account asks for a one-time ticket with its own agent token
(bot.did.createBrowserSignIn). The browser that opens the ticket’s link,
GET /oauth/browser?ticket=…, is given COOKIE for a session holding
the account. The session is not a crate::auth::Credential: it cannot
approve, read or write. GET /oauth/authorize and GET /oauth/browser
are the only routes that read it.
One cookie names one session, and a session holds a set of accounts, each
with its own deadline. An account is in one browser at most, so signing
it in elsewhere takes it out of the old one. A session gets a new id
whenever an account joins, and the old id keeps working for
REPLACED_ID_GRACE, so two sign-ins in flight in one browser both land.
Everything here is in memory. A restart ends every session and ticket, as it ends every operator session.
Structs§
- Browser
- The session a request’s cookie resolves to.
- Browser
Session - A browser session, keyed by its id.
- Browser
Sessions - Every browser session and ticket this server holds.
- Inner 🔒
- Minted
- A ticket just minted.
- Signed
In - A ticket redeemed: the account that joined, and the session it joined.
- Ticket
- A ticket, keyed by the ticket itself.
Constants§
- BROWSER_
TICKET_ TTL - How long a ticket stays live. It is spent on first use.
- COOKIE
- The cookie a browser session rides in.
- DEFAULT_
BROWSER_ SESSION_ TTL - How long an account stays signed in to a browser, absent
[oauth] browser_session_ttl_secs: twelve hours, as an operator’s session. - PATH
- Where a browser signs in, and the page that lists the accounts it holds.
- REPLACED_
ID_ GRACE - How long a session’s old id keeps working after an account joining gave the session a new one.
- SECRET_
BYTES 🔒 - Random bytes a ticket and a session id are each drawn from.
Functions§
- cookie
- The
Set-Cookievalue that carriesbrowser’s session. - deadline 🔒
spanafternow, or the last momenttimecan name when a configured lifetime runs past it.- presented
- The session id a request’s
Cookieheaders carry, if any. - random_
secret 🔒 - 32 random bytes, base64url.
- view 🔒
sessionas a request sees it.
Type Aliases§
- Clock
- What
BrowserSessionsreads the time from.