Skip to main content

Module auth

Module auth 

Source
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.

Structs§

Auth
Identity

Constants§

CACHE_TTL
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