Expand description
Who is calling: this server’s API tokens (bearer) and session cookies.
Players, tokens and sessions are the server’s own (chess.players,
chess.api_tokens, chess.sessions). Tokens are hashed with SHA-256,
with Lichess’s scope names (board:play, bot:play, challenge:read,
challenge:write, email:read) plus chess:fairplay for reviewers.
People make and revoke them on the Account page (crate::http::web),
through the OAuth flow, or (for a host site’s players) through the
site’s server (crate::http::web::esports_token). New tokens start
ocp_; tokens imported from a host site keep its esl_. A short cache
keeps a busy game from hitting the database for every move; a revoked
token stops working within CACHE_TTL.
Staff. A player’s roles here (admin; manager) are this server’s
alone. Their rights need a passkey check as well, made in the session or
with the token in hand (crate::passkeys), which lasts
CHESS_ADMIN_PASSKEY_HOURS; until then the identity is only pending.
Partners. Other services (a host site) call with a partner token
(ocs_), which an admin makes; its scopes say what it may do:
PARTNER_READ (games, players, the feed) and PARTNER_SITE (the host
site’s endpoints: its players’ tokens and links). The host site’s shared
secret (ESPORTS_SECRET) still works as a partner with both, so a site
can move to a partner token at its own pace.
Structs§
Constants§
- CACHE_
TTL - PARTNER_
PREFIX - Partner tokens’ prefix.
- PARTNER_
READ - Partner scope: read games, players and the feed.
- PARTNER_
SCOPES - PARTNER_
SITE - Partner scope: the host site’s endpoints (
/api/esports/…). - SCOPES
- Scopes this server understands (Lichess’s names, and one of ours).
- SESSION_
COOKIE - Signed in to this server (its own sign-in, or with the host site).
- SITE_
TOKEN_ PREFIX - Tokens imported from a host site (esports-lab) keep its prefix.
- TOKEN_
PREFIX - New tokens’ prefix.
Functions§
- bearer
- cookie
- hash_
key - random_
token - same
- Compare secrets in constant time.
- staff_
roles - An admin’s or manager’s roles, as stored.