Skip to main content

Module users

Module users 

Source
Expand description

Users, browser sessions and API tokens.

Structs§

IdpLogout
What a back-channel logout of the identity provider did.
NewLocalUser
OidcIdentity
Identity asserted by the OIDC provider after a successful login.
UserUpdate

Enums§

SignIn
How a user signed in (recorded in the audit log).
TokenLifetime
How long a new token lives.

Constants§

REAUTH_WINDOW_MINUTES
How long a fresh single sign-on counts as the sign-off of a review decision (TEAMCRAFT_APPROVAL_REAUTH).

Functions§

active_actor
The actor of an active user as it is now (memberships and hidden groups read again); None for a deactivated or deleted user. Long-running work on behalf of a user (the assistant’s tool loop) calls this per step, so a lost membership or a newly restricted group applies at once.
actor
Loads the full actor (incl. project memberships) for a user id.
actor_for_api_token
The user of a personal access token and the token’s scope; None for an unknown, expired or revoked token or a deactivated user. A use moves the expiry of a token with a sliding lifetime (idle_days) forward.
actor_for_session
authenticate_local
Verifies username and password of a local account. Returns None for unknown users, wrong passwords, OIDC accounts and deactivated users.
change_own_password
Changes the caller’s own password after verifying the current one.
confirm_own_password
Confirms the actor’s own password for a sign-off (#152 step 4).
count
create_first_admin
Creates the bootstrap administrator if the database contains no users. First start without any account: creates the administrator (the “create the administrator” form of the login page). Concurrent attempts are serialised with an advisory lock; once an account exists it fails.
create_local
Creates a local (password) account. actor = None is used by the CLI and the bootstrap logic.
create_session
Creates a session and returns the plaintext token for the cookie; the sign-in is recorded in the audit log (user.sign_in, never the token).
create_token
Creates a personal access token. The plaintext is returned exactly once.
delete_session
Ends a web session (sign-out); recorded as user.sign_out. An unknown or already ended session is not an error and leaves no entry.
ensure_bootstrap_admin
find_by_username
get
idp_logout
The identity provider logged the user with the subject sub out (OpenID Connect Back-Channel Logout, issue #173 step 9): their browser sessions end and the time is noted (users.idp_logout_at). An unknown subject does nothing (None). API and desktop tokens stay.
list
list_tokens
mark_session_reauthenticated
Marks the web session (by the hash of its token) of user_id as signed in again just now. False when the session is not the user’s (or gone).
purge_expired
Removes expired sessions and stale OIDC login attempts.
record_failed_sign_in
Records a failed password sign-in (user.sign_in_failed). For an existing account the entry names it; for an unknown username it does not keep what was typed – that is often a password entered in the wrong field. The password itself is never recorded.
reviewer_candidates
Active users that may be asked to review a change.
revoke_token
Deletes an API token (its owner, or an administrator).
session_actor
The user of a web session and when the session began (for the maximum sign-in age of need-to-know groups); None for an unknown or expired session or a deactivated user.
session_recently_reauthenticated
Whether the web session token of the user signed in again with single sign-on within the last REAUTH_WINDOW_MINUTES.
set_password
Sets the password of a local account. actor = None is used by the CLI.
set_preferred_cad
Stores the preferred CAD program of the signed-in user: a format family (cadformat::families) or "" = show all files alike. Display only – it never changes what the user may read or download.
set_skin
Stores the UI skin of the signed-in user.
token_lifetime_for
The lifetime of a new token of user: for a single sign-on user capped by TEAMCRAFT_OIDC_TOKEN_IDLE_DAYS (sso_idle_days, 0 = off; issue #173), for anybody else as asked.
update
Updates a user (admin only). The role of OIDC users is managed through IdP groups and is overwritten at their next login.
upsert_oidc_user
Finds or provisions the user for an OIDC identity and synchronises name, e-mail and role (derived from groups) on every login.
username_from_hint
Turns an IdP username (or e-mail address) into a valid TeamCraft username.