Skip to content

Desktop admin pages, audit log and activity - #20

Open
Skyfuller1303 wants to merge 57 commits into
itrycodinganditsbad:mainfrom
Skyfuller1303:admin-ui-desktop
Open

Skyfuller1303 wants to merge 57 commits into
itrycodinganditsbad:mainfrom
Skyfuller1303:admin-ui-desktop

Conversation

@Skyfuller1303

@Skyfuller1303 Skyfuller1303 commented Nov 4, 2026 •

Copy link
Copy Markdown

Builds on #19 (two-factor), #18 (audit log), #17 (admin API) and #14 (device sessions); please review those first. This branch contains their commits until they are merged.

What

Admin pages in the Craft Cloud app, plus an activity page for every account. The app reaches the server's admin API through new routes in the agent's local API, so it still never talks to the server directly. The server decides every permission; the app only hides what a member can't use.

Local API (agent)

  • GET /v1/account: the signed-in account, including its role and whether two-factor is on. The app uses it to know whether to offer the admin pages.
  • /v1/admin/... passes each server admin route through: the server overview, the user list with paging and search, creating an account, changing role and quota, disabling, enabling and removing an account, invites, password reset codes (optionally turning two-factor off), reset-two-factor, and listing and revoking an account's devices.
  • GET /v1/admin/audit, GET /v1/admin/audit/export (NDJSON passed through as a stream, never buffered) and GET /v1/account/activity. Query values are checked in the agent: the action filter takes only names from the closed list.
  • These routes sit behind the same Host, Origin and token checks as the other local routes, with small body limits.
  • The server's status, error code, challenge and Retry-After reach the app unchanged. A server 401 becomes the usual local 409 needs_you, and a member's forbidden never signs the agent out.
  • The agent stores and logs no password or code, and their Debug is redacted.

App client (craft-cloud-app)

  • Blocking calls for all of the above.
  • The export is written to a writer as it arrives. It counts as whole only when the server's last line says complete with the matching count and the HTTP framing ended properly. A cut-off stream is an error.
  • The admin and audit bodies now live in craft-cloud-api (re-exported from craft-cloud-proto under the same paths), since apps depend on api only. The wire format doesn't change.

Desktop

  • Users: list with search and paging; create (name and role; the quota is set afterwards); change role and quota; disable, enable and remove; issue and revoke an invite or reset code, shown once; turn another account's two-factor off; list and revoke an account's computers.
  • Confirmation: every change asks for the admin's password, and for a TOTP or recovery code when the admin has two-factor. It sends them once and clears them, including egui's undo history for those fields. Wrong password, wrong code, lock, last_admin, account_disabled, forbidden and rate limits each get a clear message, with the wait time when the server gives one.
  • Audit log: newest first; filter by action (from the closed list) or by account; paging. Each row shows who acted (account, command line or unknown) and what it was about, with full IDs on hover.
  • Export: saved to a file the user picks. It is written to a new temporary file in the same folder and renamed only when the export is whole, or truncated at the server's limit, which is shown as a warning. On any failure, no file is kept and an existing file is left alone.
  • Activity: every account sees its own events.
  • Late answers from an earlier page or an earlier sign-in are ignored.

Docs

docs/agent.md (the local admin, account, activity and audit routes) and docs/design/live.md.

Testing

  • cargo fmt --all -- --check, cargo check --workspace --all-targets --locked, cargo clippy --workspace --all-targets --locked -- -D warnings, cargo xtask licenses
  • cargo test for the desktop lib (--test-threads=1), app, api and proto
  • agent tests: lib, local_api, two_factor and end_to_end
  • server tests on SQLite
  • Agent tests run against a real server on loopback:
    • every admin route as admin, as member (forbidden, stays signed in) and with a revoked device;
    • confirmations with and without two-factor (TOTP, a recovery code used once, lock and rate limits);
    • audit paging, cursor and filters, and malformed filters (400);
    • whole, filtered and truncated exports;
    • no password or code in the agent's files or output.
  • App tests read the export over real TCP: whole, cut before or inside the last chunk, unfinished trailers, no end line, wrong count, oversized lines, a full disk.
  • Desktop model tests and kittest snapshots for the new screens: admin-*, audit-log*, activity. An undo-history test covers each secret field.

Not tested

Left open

  • No web admin; that is a separate PR once its technology is agreed.
  • The audit view shows account IDs, not names: the server sends IDs only.
  • Export by time (before_ms) is in the API but not in the UI.

Skyfuller1303 and others added 30 commits November 4, 2026 00:04
Migration 0007 gives a device its client kind, platform and app version
and, once revoked, the time and the reason, and gives a user the time of
the last password change (plus a disabled time nothing reads yet). All
of it is additive, BIGINT on Postgres, and the flag stays the check.

Meta gets create_device_with and redeem_with, rename_device,
revoke_device_as, revoke_other_devices, revoke_all_devices, account,
change_password and reset_password. Flag, time and reason are set
together and only by the first revoke. A password change or reset sets
the hash, revokes the devices and deletes the account's invite and
pairings in one transaction.

Tests run on both databases, including the migration from 0006.

Co-Authored-By: Claude <noreply@anthropic.com>
New: GET /account, POST /account/password, PATCH /devices/{id} and
POST /devices/revoke-others. Sign-in and join take an optional client
kind, platform and app version, checked before a try is counted. The
device list shows them with the time and reason of a revoke; all new
fields are optional on the wire.

Changing the password answers a wrong current password with 403
wrong_password, never 401, since the agent reads every 401 on a
signed-in route as a revoked device. It is limited to five tries per
account in 15 minutes, takes a password-check slot, and ends the revoked
devices' live connections at once. Password and name bodies are read up
to the new TINY_JSON_BYTES (4 KiB).

wrong_password and forbidden move into the shared error codes; the local
API refers to them. The agent, app and desktop only change where they
build the extended types.

Co-Authored-By: Claude <noreply@anthropic.com>
user reset-password now revokes every device of the account (reason
reset) and deletes its open invite and pairings, so a stolen token does
not outlive the old password. --keep-devices restores the old behaviour
for the devices. device revoke-all signs out an account's devices
without touching the password. Both print how many devices they ended;
device revoke records the admin as the reason.

Co-Authored-By: Claude <noreply@anthropic.com>
The API table and error codes in the design document, the password and
sign-out commands, the live-connection delay of the command line and the
rollout note (an older server refuses the newer database) in the
server guide.

Co-Authored-By: Claude <noreply@anthropic.com>
…evice

A /changes long-poll that was waiting when its device was signed out
through the API now ends at once, and one that wakes for any other reason
looks the device up again before it answers, so a device signed out by
the command line gets 401 instead of the next change set.

The live endpoint listens for revocations and looks the device up before
the upgrade, so a revoke between the sign-in check and the subscription
is not missed.

Co-Authored-By: Claude <noreply@anthropic.com>
change_password checks, inside its transaction, that the calling device
is still signed in (it may have been revoked while the password was
hashed) and answers 401 if not. A password that changed meanwhile is now
409 conflict instead of 400 invalid. Both are new MetaError variants
mapped in the server.

set_password_hash had no caller outside a test and is removed. A new test
breaks the pairing deletes with a trigger and checks that a password
change, an admin reset and a revoke-others undo everything on SQLite and
Postgres.

Co-Authored-By: Claude <noreply@anthropic.com>
The long-poll now listens for revocations and looks its device up before
it waits, so a revoke between the sign-in check and the wait is not
missed, and looks it up once more after the change set is fetched, as
the last step before the answer, so a revoke during the fetch is not
answered with changes.

Co-Authored-By: Claude <noreply@anthropic.com>
…changes a password

change_password locked the caller's device row and then the user's row,
while revoke_other_devices from another device locked its own device and
then the user's, and reset_password locked the user before the devices.
On Postgres two of them at once could deadlock and fail with a database
error. All of them now take the user's row first (a no-op update), then
the devices, then the pairings.

A new scenario runs password changes, sign-outs and an admin reset at the
same moment, over and over, on both databases and expects only successes,
conflicts and signed-out callers. The test trigger helper also drops its
Postgres function.

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
…-in adds a device

redeem consumed the invite and then updated the user, while a password
reset locks the user and then deletes the invite, so the two could
deadlock on Postgres. redeem now finds the invite or pairing with a plain
read, locks the account, and consumes the code again under the lock; a
code that is gone by then is invalid_code. create_pairing locks the
account first too.

A password sign-in verified the password outside any transaction, so a
reset or change that committed meanwhile could be followed by a new
device. sign_in_device locks the account and compares the stored hash
again before it creates the device; if it differs, login answers as for
a wrong password.

New scenarios run redeems, a sign-in, a pairing and a reset at the same
moment on both databases and expect no database error and no live device
once the reset is done.

Co-Authored-By: Claude <noreply@anthropic.com>
The invite delete and the pairing update now name the account the plain
read found, so a code hash removed and made again for another account
between that read and the lock is refused as invalid_code instead of
adding a device to the wrong account.

Co-Authored-By: Claude <noreply@anthropic.com>
The admin API's server overview shows whether blobs are on disk, in S3 or in memory. A backend that does not say is reported as other, so nothing outside the store crate has to change.

Co-Authored-By: Claude <noreply@anthropic.com>
New request and answer types for the routes under /api/v1/admin, with a redacting Debug for everything that holds a password or a code, and the error codes account_disabled and last_admin. The confirmation is a body with an optional password today, so an optional totp_code can join it later without breaking a client.

Co-Authored-By: Claude <noreply@anthropic.com>
Migration 0008 adds the purpose of an invite (invite or reset), a quota per space and a removal mark per user. The new Meta methods for the admin API each re-check the acting admin inside their own transaction and take the locks in one order, with a transaction-wide lock before the last-admin count. Disabled accounts are refused by the token check, sign-in, redeem, pairing and device creation, decided under the account's row lock. A reset code always sets a new password, signs every device out and then signs the redeeming computer in. A space's quota replaces the server-wide cap in the preflight check and in the count that follows.

Co-Authored-By: Claude <noreply@anthropic.com>
The require_admin layer and the routes under /api/v1/admin: counters, a paged and searchable user list, creating accounts, changing role and quota, disabling, enabling and removing, invites, password reset codes and a user's devices. Every change asks for the acting admin's password in its body. Sign-in and join answer account_disabled for a disabled account, and a redeemed reset code ends the live connections of the devices it signed out. Documents the API, the confirmation and the rollout in the design document and the server guide.

Co-Authored-By: Claude <noreply@anthropic.com>
Limiter::count added the attempt before comparing it with the maximum, so tries refused at the limit still raised the count. A refund of an attempt that had been accepted at the same moment then left the key above its limit with fewer wrong passwords than allowed. A refused try now leaves the count alone.

Co-Authored-By: Claude <noreply@anthropic.com>
Disabling and enabling an account leaves the password hash as it was, so a sign-in that verified the password before the disable could still create a usable device after the enable. Users get an auth_gen counter (migration 0008) that a disable, an enable, a removal and every password change or reset bump. The sign-in reads it with the hash and sign_in_device compares both under the account's lock. The server's refunds test covers the limiter change.

Co-Authored-By: Claude <noreply@anthropic.com>
The typed details of a security event, an event, a page of them and the last line of the NDJSON export. Every
field of the details is a closed list of words or a number, and fields a later release adds are ignored.

Co-Authored-By: Claude <noreply@anthropic.com>
Migration 0009 adds audit_events, with no foreign keys so that an event outlives its account. Every change that the
log names writes its event in its own transaction before the commit, so a change whose event cannot be written is
not made. A change that changes nothing writes none. A failed sign-in is one row per account and minute whose
counter goes up, written in a transaction of its own. The values of an event are typed and come from closed
lists, never from what a client typed. Old events are pruned in batches outside those transactions.

Meta methods that had no way to say who asked get one: revoke_device_by takes the origin, and admin_enable_user and
admin_revoke_invite take the time.

Co-Authored-By: Claude <noreply@anthropic.com>
GET /account/activity, GET /admin/audit and the streamed GET /admin/audit/export; a failed sign-in is written
after the answer is decided and never changes it. [audit] retention_days (1 to 3650, default 365) and
audit list and audit prune on the command line. The export reads fixed pages through a bounded channel up to a
fixed end of the log and ends with a line that says complete or truncated, or breaks the connection.

Co-Authored-By: Claude <noreply@anthropic.com>
The routes and events in the design, and the retention, the personal data and the upgrade note in the server guide.

Co-Authored-By: Claude <noreply@anthropic.com>
…in the export, reword the append-only note

The account's own activity no longer shows the details (the device an admin signed out, roles, counts) of an event about another
account, which a former administrator would otherwise keep seeing. The export validates before_ms like the list and applies it
to every page and the probe besides its fixed end. The docs now say the append-only choice is a design decision, not that SQLite
has no triggers.

Co-Authored-By: Claude <noreply@anthropic.com>
aes-gcm 0.10.3 (MIT OR Apache-2.0, pure Rust) seals the stored TOTP secrets.
hmac 0.13, sha1 0.11, subtle 2.6 and zeroize 1.9 were in the lockfile already
as transitive packages and become direct dependencies of the server: HMAC-SHA-1
makes the codes authenticator apps speak, subtle compares them in constant
time, zeroize wipes secrets. The server's tests also turn on its own
test-support feature, to move its clock.

Co-Authored-By: Claude <noreply@anthropic.com>
Migration 0009 adds the secret and recovery-code tables, the sign-in
challenges and the invites' reset_two_factor flag. Everything that issues a
device or uses a proof up locks the account's row first and checks again, under
the lock, the device, the password hash, auth_gen, the account's current
two-factor state and the challenge. A time step is accepted once and only a
later one after it, a recovery code once, and a wrong proof is counted in a
transaction of its own after the refused one rolled back, so the counters
survive; ten in a row lock the second factor for 15 minutes, doubling up to 24
hours. Turning it on, off or resetting it ends what an earlier check let through
(auth_gen, challenges, invite, pairings, devices). Redeeming an invite or reset
code of an account that has it takes the second factor in the same
transaction; the admin's reset of another account's two-factor sign-in, the
reset_two_factor flag of reset codes and the admin's own two-factor state are
part of the admin changes.

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Routes under /account/two-factor (status, setup, confirm, disable, recovery
codes), POST /auth/login/second-factor, a second factor on /join, a code on the
admin API's confirmations (one time step serves one change), POST
/admin/users/{id}/reset-two-factor and reset_two_factor on password-reset codes.
Resetting another admin's password or two-factor sign-in takes the acting
admin's own.

The secret is sealed with AES-256-GCM bound to the account (secretbox.rs) under
the key from [two_factor] key_file, which init makes and serve never does; serve
opens every stored secret at start and refuses to run when the key is missing or
one does not open. Rotation is key_file_old plus two-factor rekey. user
reset-2fa takes it away on the command line. TOTP (RFC 6238) is in totp.rs with
the RFC vectors.

Co-Authored-By: Claude <noreply@anthropic.com>
…ation

Co-Authored-By: Claude <noreply@anthropic.com>
…e secrets fresh per account

A wrong proof was counted after its transaction rolled back and released the
account's lock, so requests that waited for it checked a stale challenge and a
stale lock: more than five checks per challenge, and parallel failures could
jump the first lock from 15 to 30 minutes. Every check now runs before anything
is consumed (join checks the second factor before it deletes the invite), so
the refusing transaction commits the counters itself, still under the lock.

two_factor_rewrite reads an account's active and set-up ciphertexts fresh under
its lock and rewrites both; two_factor_all_secrets lists everything for the
final scan of rekey. join_code_locked_for lets the join route report a lock.

Co-Authored-By: Claude <noreply@anthropic.com>
…ock win at join

rekey no longer works from a snapshot: a confirmation that moves a set-up's
secret to the active one between the scan and the update was left under the old
key while the command said the old key could go. It now rewrites both
ciphertexts of an account under its lock, scans again, and fails unless nothing
is under another key. The join route reports an active two-factor lock (429
two_factor_locked with Retry-After) instead of the limiter's answer when the
code belongs to such an account. The key's name no longer claims to be unique.

Co-Authored-By: Claude <noreply@anthropic.com>
Skyfuller1303 and others added 20 commits November 4, 2026 11:24
…lenge and the app client's methods

The local API gets the second step of a sign-in (/v1/login/second-factor), the
account's two-factor calls passed on to the server, the password change, other
computers and device rename, and a second factor on /v1/join. A refusal's
challenge and wait (ErrorExtras) reach the app as Error::RefusedWith, so code that
matches Error::Refused keeps working. The wire types the app needs move from
proto to api, which proto re-exports.

Co-Authored-By: Claude <noreply@anthropic.com>
…unt's two-factor calls

The agent keeps the server's refusals whole in a type of its own (CallError), so
a wrong code, a wrong password or a lock is never read as a revoked device while
a real 401 still is; sync's TransportError is unchanged. login and join prompt for
the code on standard input (three tries, a lock says how long to wait), the local
API passes the challenge and the wait on typed, and every new route has its own
small body limit.

Co-Authored-By: Claude <noreply@anthropic.com>
The signed-in view gets a Security button. The page shows the account's two-factor
status, sets it up (password, then the secret with a QR code and the first code),
shows the recovery codes once, turns it off, makes new codes, changes the password
and signs the other computers out. A join for an account with two-factor sign-in
asks for the code (or a recovery code) and sends the same join again with it.
Secrets live in the page's step only, are dropped when it is left, and are redacted
in Debug. The signed-in snapshots change by the new button.

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
…etry-After header

The password and code fields of the Security page and of the join's second step get stable
ids, and every frame the egui state of each such field is dropped unless the model holds
text typed in it, so once a secret was sent, a step cancelled or the page left, Undo can't
bring it back. A kittest test types, sends, cancels and leaves, reopens and presses Ctrl+Z.

The local client keeps an answer's Retry-After header and uses it for the wait of a refusal
when the JSON has no retry_after_secs.

Co-Authored-By: Claude <noreply@anthropic.com>
Turning two-factor sign-in on and off, new recovery codes, a recovery code's use, an admin's and the command line's
reset, and auth.login on both successful sign-in paths are written in the transaction of the change, so an error in the
log fails the change. The wrong second step of a sign-in or a join is aggregated and written after the answer is decided,
and the lock's event after the counters and the lock are committed, so a fault in the log neither undoes the lock nor
changes an answer. A reset code that removes two-factor sign-in says so (two_factor_removed) on join.reset_redeemed, by
the account that redeemed it. Wrong proofs on signed-in routes are not written one by one.

Co-Authored-By: Claude <noreply@anthropic.com>
…ctor events over HTTP

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
The admin API's request and response types move from craft-cloud-proto to craft-cloud-api, which proto re-exports under
the same paths, so that craft-cloud-app (which depends on api only) can use them. The local API gets the paths of the
admin pass-throughs.

craft-cloud-app gets a blocking call for each admin route of the agent's local API. A refusal that carries the agent's
Retry-After header (an admin call the server rate limited) comes back as the new Error::Throttled, with the seconds to
wait, so the app can say when to try again; every other refusal is unchanged.
Adds /v1/admin/... to the local API, one route for each route of the server's admin API. The agent checks no role and
keeps no confirmation: each body is read as the shared type (so its Debug output hides the admin's password), limited
to 8 KiB, and written to the server with the device's token. The server's answer is the answer, with its HTTP status,
error code and message, and Retry-After for a 429. A 403 therefore stays a 403; the server's 401, which on a signed-in
route means this device was revoked, is told as every other call tells it (409 needs_you), never as a local 401.

Tests run the agent against a real server on loopback: an admin's reads and changes, a missing and a wrong confirmation,
the last admin, the server's rate limit, a member's 403, a revoked device, a signed-out agent and oversized bodies, and
that neither the password nor a code is written to the data folder or printed.
An account the server answers the admin counters to gets an Administration button: a paged user list with search, a
new account (name and role; its quota is set afterwards on the account's page, as a change of its own), one account's
role, quota, disable, enable, removal, invite, password reset code and computers, and the codes shown once.

Every change asks for the admin's password in a confirmation page and sends it in the call's body; the model clears
it as soon as it is sent, and its Debug output hides it. The confirmation is one type, so a second factor's code can
be added to it without touching the pages, events or calls. The server decides every permission: its refusals
(wrong_password, last_admin, account_disabled, forbidden, rate_limited with its wait) are shown in plain words.

Adds the model tests, kittest interaction tests and snapshots of the new screens (the existing ones are unchanged).
Describes the /v1/admin routes of the agent's local API in docs/agent.md (how the server's status and codes pass
through, and that the confirmation is never kept), mentions them in the local API's call list, and lists the new
modules in the workspace map.
…oke any open code

Review fixes for the admin pages.

The password field's undo history, which egui keeps in memory with the text as it was typed, is now dropped every frame
unless a confirmation is open with something typed in it: once a password was sent, or the page was cancelled or left,
Undo can't bring it back. The field has a stable id. A kittest test types a password, sends it, cancels, leaves and
presses Ctrl+Z each time, and checks that the field stays empty and that egui keeps no history. egui keeps this state in
memory only; the app doesn't enable eframe's persistence and the undo history is not serialized.

The numbers that match an answer to its call (the user list, a user's devices) never restart, so a late answer from
before the pages were opened again matches nothing. The admin check carries the number of the sign-in it was made for,
so a late answer for an earlier account can't change the current one's access.

"Revoke open code" is offered always, since the list's invite flag doesn't cover password reset codes. A revoke that
finds nothing open says so and looks at the list again.
craft-cloud-api gets the closed list of audit event names with a check for an audit filter (a name, or a prefix ending in a
dot), the local API's paths for the account, its activity and the admin audit and its export, and the serde, default and
redaction tests of the admin bodies (with the second factor and the reset flag) and of the audit bodies, kept with the
types.

craft-cloud-app gets Client::account, account_activity and admin_audit, and admin_audit_export, which reads the agent's
chunked NDJSON stream line by line into a writer: one line and a small buffer at a time, an event checked as an event, and
the export counted as whole only with the server's complete line and the number of events it says. A stream that ends without
it, breaks, or holds a line that doesn't read is an error. A truncated line is a good export that says so. The body reader
that takes the chunks off is tested against cut-off and malformed streams. The reset code call takes the whole
AdminPasswordReset and a call for reset-two-factor is added.
…ocal API

Adds GET /v1/account (the signed-in account's role and two-factor state), GET /v1/account/activity (any account's own
events), GET /v1/admin/audit (filtered, paged, newest first) and GET /v1/admin/audit/export, which passes the server's NDJSON
through chunk by chunk without ever holding more than the chunk in hand; a server stream that breaks ends the local one without
its last chunk, so the client sees a broken export. Cursors are passed as they came, limited in length and characters; a user
must be an account ID, an action one of the closed list or a prefix of it, and times and limits are bounded, all before
anything is sent. The server's statuses and codes (403 forbidden for a member, 429 with Retry-After) pass through as
everywhere, and the account's own activity reads none of the admin's filters.

Tests run against a real server on loopback: an admin with two-factor sign-in confirming changes with a code or a recovery
code (missing and wrong ones are two_factor_invalid and never sign the agent out, too many are stopped with the server's 429), a
reset code with reset_two_factor, resetting an account's two-factor sign-in, and the audit list, filters, own activity,
member refusals and a whole and a truncated export. The app's tests read an export over a real connection: whole, cut off
before the terminating chunk, cut in the middle of a chunk, without a last line, and refused.
…off, role from the account

The admin confirmation takes a code beside the password when the account has two-factor sign-in (the page asks for it once the
server says two_factor_invalid, too): one field, six digits are a code from the app, anything else a recovery code. Password
and code live in Confirmation, which clears both when they are sent; both fields have stable ids and go through the Security
page's forgetting of secrets in egui's undo history (one mechanism, with a test for the code field next to the password's).
The server's wrong or locked code and its rate limit are said as the Security page says them, with the wait.

Password reset codes go through AdminPasswordReset end to end, so a reset code can turn two-factor off when it is used, and
a change of its own turns an account's two-factor sign-in off and signs its computers out. An account's page shows whether
it has two-factor sign-in.

The app learns whether the account is an admin from GET /v1/account (the server's role, and whether the account has
two-factor sign-in) instead of probing an admin route; the server's counters are asked for when the admin pages open. The
Refusal and error shapes are the two-factor ones: a refusal keeps its challenge and its wait from the JSON or the header.
…the export to a file

The admin pages get an audit log: events newest first as words with the typed details the server writes, paged with the
server's cursors given back as they came, filtered by an event name or group from the closed list (never anything else) and by
an account (opened from its page), with a refresh. Its export goes to a file the person picks: the app writes the agent's
stream to <file>.part and moves it into place only when the stream ended with the server's complete line, so a broken stream
or a full disk fails the export, removes the part file and leaves what was at the path; a stream the server cut at its limit
is a good file the page says is not the whole log, never a plain success.

Every signed-in account gets an Activity page with its own events (the signed-in view's Activity button), whatever its role.

Late answers match nothing (the numbers that tell them apart never restart). The Security, Activity and Administration
buttons are all in the signed-in view. New screens are drawn by kittest: the audit log (light and dark), an export in progress,
truncated and failed, the activity page, an account with two-factor sign-in and the confirmation that asks for a code. The
signed-in snapshots and the admin ones whose screens gained a button are regenerated.
…nd factor in the admin confirmation

Adds GET /v1/account, the account's activity, the audit list and its streamed export, and reset-two-factor to the table of the
local API's admin calls, and describes the second factor in the confirmation, a reset code that turns two-factor off, and why
and how an export is counted as whole.
…their export, read the end of a chunked body, show who and what

The audit export is written to a file created for it alone in the destination's folder (it must not exist, so nothing is
truncated and no link is followed), moved over the chosen path only when the stream ended properly, and removed on any failure;
a file that happens to be called <path>.part, and an existing destination, are never touched by a failed export.

The picker's answer and the export's answer carry the number of the export that asked for them, so after leaving and opening the
pages again, or starting a second export, a late answer of the first finishes nothing of the second.

The reader of a chunked body now needs the last line break after the last chunk and its trailers (which are bounded): a
connection that ends after "0\r\n" or inside a trailer is a cut-off body, not a complete one, which matters because an export
counts as whole only when its body does. Tested with unit cases and over a real connection.

Each audit event line now says who did it (the account's short ID, "the command line", or "unknown" for a sign-in nobody proved
anything for) and what it was about (account or computer, with the computer an act names in its details); the whole IDs are on
hover. The audit snapshots that show events are regenerated.
The server (device sessions) shows a device's client_kind, platform and
app_version in the device list, but the agent never sent them. Every
sign-in and join of the agent now says it is an agent, which operating
system it runs on and its own version, cut to the server's 32-byte limit.
A server-backed test checks that the device list shows them after both.
Conflicts in apps/craft-cloud-agent/src/http.rs: join_over_with keeps the second
factor fields and now also sends the device details. The first step of a
two-factor sign-in (login_step_over) sends them too; the server keeps them in
the challenge, so the second-factor request needs none.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant