roledesk is built on the boilerplate from here on: pipeline 2.0 (queue and scheduler), auth (one password, sessions, passkeys), the deploy kit and its docs, plus the coupling and packaging tests. Downstream copies, unedited. Refreshed from boilerplate/d56949f7d0f6c0bfe5745478e09007bfad67ae87 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
82 lines
3.5 KiB
Python
82 lines
3.5 KiB
Python
"""What the Account tab is told, and nothing more.
|
|
|
|
Three models, and the thing worth noticing about all three is what they cannot
|
|
carry. No token, no hash, no key material — not even the public half of a
|
|
passkey. The list of ways into an app is the one page most worth reading and
|
|
least worth leaking, so the shape it is rendered from is one that could not
|
|
leak a credential if it were logged whole.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
class SessionInfo(BaseModel):
|
|
"""One live login, for the account screen to list and revoke.
|
|
|
|
`id` is the row's own integer, which is what the revoke button sends back.
|
|
The screen therefore holds nothing that could be replayed as a credential.
|
|
"""
|
|
|
|
id: int
|
|
#: The browser that opened it, as it described itself. Advisory — a client
|
|
#: writes its own user agent — but it is what tells the laptop from the
|
|
#: phone, and an unexpected row here is the signal worth having.
|
|
label: str = ""
|
|
created_at: str = ""
|
|
last_seen_at: str = ""
|
|
expires_at: str = ""
|
|
#: The session making this request, which the UI must not offer to revoke
|
|
#: as though it were one of the others.
|
|
current: bool = False
|
|
|
|
|
|
class Passkey(BaseModel):
|
|
"""One registered authenticator, as the account screen sees it."""
|
|
|
|
id: int
|
|
#: What you called it. A passkey you cannot name is one you will never dare
|
|
#: revoke, because you will not know which key it is.
|
|
label: str = ""
|
|
created_at: str = ""
|
|
last_used_at: str = ""
|
|
#: How the authenticator says it can be reached — `usb`, `nfc`, `internal`,
|
|
#: `hybrid`. Advisory and self-reported, but it is what tells "the YubiKey"
|
|
#: from "this laptop" in a list where both are just names.
|
|
transports: list[str] = Field(default_factory=list)
|
|
|
|
|
|
class Account(BaseModel):
|
|
"""What the account screen knows. Deliberately almost nothing.
|
|
|
|
There is one user and they are already signed in, so there is no name, no
|
|
email and no id to show — only whether the door is locked, when the password
|
|
last changed, and what is currently signed in.
|
|
"""
|
|
|
|
#: Whether the door is locked at all. False on a loopback-bound app under
|
|
#: the default `auto`, and the screen says so rather than offering a
|
|
#: password change that would not be asked for.
|
|
locked: bool = False
|
|
#: The environment pins the password, so the browser cannot change it. The
|
|
#: variable is named by `AuthConfig.password_env`; see `auth.bootstrap`.
|
|
pinned: bool = False
|
|
#: Which variable that is, so the screen can name it rather than saying
|
|
#: "an environment variable" to somebody who has to go and find it.
|
|
pinned_by: str = ""
|
|
password_set_at: str = ""
|
|
sessions: list[SessionInfo] = Field(default_factory=list)
|
|
#: Registered authenticators. Always listed, even when the door is open,
|
|
#: because registering one on your laptop before you deploy is the sensible
|
|
#: order to do this in.
|
|
passkeys: list[Passkey] = Field(default_factory=list)
|
|
#: Whether this install can do WebAuthn at all — the `passkeys` extra is
|
|
#: optional, and a screen offering a button that 501s is worse than one
|
|
#: that says what to install.
|
|
passkeys_available: bool = False
|
|
#: Why passkeys cannot be *registered* right now, or "" if they can. The
|
|
#: honest common case is an insecure origin: WebAuthn refuses anything but
|
|
#: HTTPS, localhost excepted, so this reads "you need TLS first".
|
|
passkeys_blocked: str = ""
|