Skip to main content

Module browser

Module browser 

Source
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.
BrowserSession
A browser session, keyed by its id.
BrowserSessions
Every browser session and ticket this server holds.
Inner 🔒
Minted
A ticket just minted.
SignedIn
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-Cookie value that carries browser’s session.
deadline 🔒
span after now, or the last moment time can name when a configured lifetime runs past it.
presented
The session id a request’s Cookie headers carry, if any.
random_secret 🔒
32 random bytes, base64url.
view 🔒
session as a request sees it.

Type Aliases§

Clock
What BrowserSessions reads the time from.