Expand description
_Session rows.
Sessions are rows in a real Parse class, not entries in a process’s memory. That is the whole point of this module: a token minted here survives a restart, is visible to every node, and is accepted by a parse-server pointed at the same database.
Everything here runs unauthenticated against storage, deliberately. Upstream resolves a
session token with auth: master(config) (Auth.js:168). It has to: until the lookup
finishes there is no caller, so there is no ACL to evaluate and no CLP to consult. Creation is
the same, new RestWrite(config, Auth.master(config), '_Session', null, sessionData)
(RestWrite.js:1133). What keeps that narrow is that no query in this module comes from a
client. Each one is built here from a session token, a user objectId or a session objectId.
The read side of _Session that a client reaches, GET /sessions, is a different path and
is not this module. Upstream narrows it to the caller’s own user rather than master-gating it
(RestQuery.js:117-133), and that belongs with the router.
Out of scope, and absent rather than half-present:
- Session renewal.
extendSessionOnUsedefaults tofalseupstream, so sessions expire and are never extended. Matching the default configuration is the whole of it. - The user cache.
getAuthForSessionTokenconsults a cache before the query (Auth.js:135-155). Every resolution here is a query. - Legacy non-
r:tokens.middlewares.jsroutes a token without the prefix to a separate resolver that looks the user up by_session_tokenon_User. Not implemented. POST /upgradeToRevocableSession, and client-driven_Sessioncreate and update.
Structs§
- Created
Session - A freshly minted session.
- Created
With - The
createdWithcolumn. - NewSession
- What a caller must supply to mint a session.
- Resolved
Session - A session resolved from a token.
- Session
Config - The two options that decide a session’s lifetime.
Enums§
- Session
Action - What created a session.
Constants§
- SESSION_
TOKEN_ PREFIX - Upstream’s revocable-session prefix (
RestWrite.js:1111).
Functions§
- create_
session - Mint a session and write its row.
- ensure_
session_ schema - Ensure
_SCHEMAcarries a_Sessionentry. - new_
session_ token - A new session token:
r:followed by 32 lowercase hex characters, 34 in total. - resolve_
session - Resolve a session token to its session.
- revoke
- Delete one session by its token. Returns whether a row was removed.
- revoke_
all_ for_ user - Delete every session belonging to a user. Returns how many.