A service for accounts and sign-in sessions: registration, guests, sign-in and sign-out, passwords, recovery, email addresses and account deletion. It also resolves session tokens to users for every request needing one.
It knows nothing of HTTP: a request that opens or ends a session answers with the SessionCookie to set. hecate-server-tapir serves each method as an endpoint.
Value parameters
- accounts
-
The store that deletes accounts, or
Noneto refuse deletion. Give one only once the host's cascade removes everything of a user's. - affected
-
The hook told whom each committed change concerns (see Affected).
- mailing
-
The composer of mail, or
Noneto refuse every request about email addresses and forgotten passwords. - policy
-
The rules for sessions, passwords and mail.
- report
-
The handler of failures whose detail must not reach the client. The default prints to the console.
- users
-
The store of users, sessions and recovery codes.
Attributes
- Companion
- object
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
Members list
Value members
Concrete methods
Changes a user's email address once their password is confirmed. A new address is sent a link and replaces the old one only once confirmed; giving the current address withdraws a pending change, and giving none removes the address at once.
Changes a user's email address once their password is confirmed. A new address is sent a link and replaces the old one only once confirmed; giving the current address withdraws a pending change, and giving none removes the address at once.
Value parameters
- change
-
The new address, if any, and the user's password.
- locale
-
The language to write the mail in.
- user
-
The signed-in user.
Attributes
- Returns
-
An answer with the addresses after the change, or a refusal.
Changes a user's password once their current one is confirmed, closing every session and opening a fresh one.
Changes a user's password once their current one is confirmed, closing every session and opening a fresh one.
Value parameters
- change
-
The current password and its replacement.
- user
-
The signed-in user.
Attributes
- Returns
-
An answer with the new session's cookie, or a refusal.
Claims a guest's account with a username and password, keeping what is theirs. Closes every session and opens a fresh one. Refused for an account with a password.
Claims a guest's account with a username and password, keeping what is theirs. Closes every session and opens a fresh one. Refused for an account with a password.
Value parameters
- credentials
-
The username and password chosen.
- user
-
The signed-in guest.
Attributes
- Returns
-
An answer with the claimed user and the session's cookie, or a refusal.
Confirms an address with the link sent to it, making it its user's. Every other link sent them stops working, and the old address is told of the change.
Confirms an address with the link sent to it, making it its user's. Every other link sent them stops working, and the old address is told of the change.
Value parameters
- confirmation
-
The link's secret.
- locale
-
The language to write to the old address in.
Attributes
Makes a guest, runs what they came for and opens their session, all at once, so nothing is made if arrival refuses. Refused unless AuthPolicy.guests.
Makes a guest, runs what they came for and opens their session, all at once, so nothing is made if arrival refuses. Refused unless AuthPolicy.guests.
Type parameters
- X
-
The type of what
arrivalproduces.
Value parameters
- arrival
-
The action the guest came for, run in the transaction that makes them, refusing by failing with an AuthProblem.
- name
-
The name the guest gave, which becomes their username, numbered if taken (see UserStore.createGuest).
Attributes
- Returns
-
An answer with the guest, what
arrivalproduced and the session's cookie, or a refusal.
Finds the user signed in under a session token.
Finds the user signed in under a session token.
Value parameters
- token
-
The session's token, if the request carried one.
Attributes
- Returns
-
An answer with the user, or
Noneif nobody is signed in.
Deletes a user's account (see AccountStore.delete) once their password is confirmed; a guest's needs none. Refused if the service has no AccountStore, and while anyone manages the account, as deleting it is then theirs alone (AuthRefusal.AccountManaged).
Deletes a user's account (see AccountStore.delete) once their password is confirmed; a guest's needs none. Refused if the service has no AccountStore, and while anyone manages the account, as deleting it is then theirs alone (AuthRefusal.AccountManaged).
Value parameters
- password
-
The user's password, ignored for a guest.
- user
-
The signed-in user.
Attributes
- Returns
-
An answer with the cookie clearing the session, or a refusal.
Reads a user's email address and any address awaiting confirmation.
Reads a user's email address and any address awaiting confirmation.
Value parameters
- user
-
The signed-in user.
Attributes
- Returns
-
An answer with the addresses, or a refusal.
Issues a fresh set of recovery codes once the password is confirmed, invalidating earlier codes. The codes are answered only this once.
Issues a fresh set of recovery codes once the password is confirmed, invalidating earlier codes. The codes are answered only this once.
Value parameters
- password
-
The user's password.
- user
-
The signed-in user.
Attributes
- Returns
-
An answer with the codes, or a refusal.
Regains an account with a recovery code: sets a new password, closes every other session and opens one. Never says whether the username or the code was wrong.
Regains an account with a recovery code: sets a new password, closes every other session and opens one. Never says whether the username or the code was wrong.
Value parameters
- recovery
-
The username, code and new password.
Attributes
- Returns
-
An answer with the user and the session's cookie, or a refusal.
Counts a user's unused recovery codes.
Counts a user's unused recovery codes.
Value parameters
- user
-
The signed-in user.
Attributes
- Returns
-
An answer with the count, or a refusal.
Registers an account and opens a session for it.
Registers an account and opens a session for it.
Value parameters
- credentials
-
The username and password chosen.
Attributes
- Returns
-
An answer with the user and the session's cookie, or a refusal.
Signs in to an account whose password someone else set, replacing it with the user's own, which must differ from it, and opens a session. Checked as sign-in is, as slowly for an unknown username, and refused as AuthRefusal.CredentialsIncorrect alike. An account whose password is its user's own may be signed in to this way too, changing it.
Signs in to an account whose password someone else set, replacing it with the user's own, which must differ from it, and opens a session. Checked as sign-in is, as slowly for an unknown username, and refused as AuthRefusal.CredentialsIncorrect alike. An account whose password is its user's own may be signed in to this way too, changing it.
Value parameters
- replacement
-
The username, the password someone else set, and the user's own.
Attributes
- Returns
-
An answer with the user and the session's cookie, or a refusal.
Sends a password reset link to every account with the given confirmed address. It answers at once and alike whether or not any account has the address, sending in the background, so that the answer discloses nothing; an account sent a link too recently is skipped.
Sends a password reset link to every account with the given confirmed address. It answers at once and alike whether or not any account has the address, sending in the background, so that the answer discloses nothing; an account sent a link too recently is skipped.
Value parameters
- locale
-
The language to write the mail in.
- resetRequest
-
The address to send the links to.
Attributes
Sends the address awaiting a user's confirmation a fresh link, unless the last was sent too recently. Changes nothing when no address awaits.
Sends the address awaiting a user's confirmation a fresh link, unless the last was sent too recently. Changes nothing when no address awaits.
Value parameters
- locale
-
The language to write the mail in.
- user
-
The signed-in user.
Attributes
- Returns
-
An answer with the user's addresses, or a refusal.
Resets a forgotten password with a link sent by email: sets the new password, closes every session and opens one. Every reset link of the account then stops working.
Resets a forgotten password with a link sent by email: sets the new password, closes every session and opens one. Every reset link of the account then stops working.
Value parameters
- reset
-
The link's secret and the new password.
Attributes
- Returns
-
An answer with the user and the session's cookie, or a refusal.
The rules for accounts, for clients to state before refusing anything.
The rules for accounts, for clients to state before refusing anything.
Attributes
Opens a session once the password matches. An unknown username is refused exactly as a wrong password is, and as slowly. A suspended account is refused as such only once its password is right.
Opens a session once the password matches. An unknown username is refused exactly as a wrong password is, and as slowly. A suspended account is refused as such only once its password is right.
Value parameters
- credentials
-
The username and password given.
Attributes
- Returns
-
An answer with the user and the session's cookie, or a refusal.
Closes a session.
Closes a session.
Value parameters
- token
-
The session's token, if the request carried one.
Attributes
- Returns
-
An answer with the cookie clearing the session, or a refusal.
Finds the user signed in under a session token, refusing if there is none.
Finds the user signed in under a session token, refusing if there is none.
Value parameters
- token
-
The session's token, if the request carried one.
Attributes
- Returns
-
An answer with the user, or a refusal.