Repository navigation
CI snapshot v3809
Source snapshot validated by the CI pipeline. This entry does not contain firmware bundles.
Changes:
[SECURITY-SENSITIVE] fix(ruview-auth): one refresh across processes; no proceed after lock timeout; a sent token is never kept (#2599)
- fix(ruview-auth): one refresh across processes, no proceed after a lock timeout, a sent token is never kept
Identity (cognitum-one/console#857) revokes the whole session family when a
used refresh token is presented again. ensure_fresh could do that in
ordinary use:
- after 3 s waiting on another process's lock it went ahead anyway;
- it presented the token it loaded earlier instead of re-reading the file
under the lock; - it kept the old token after a failed or timed-out request;
- it reused the old token when an answer carried no new one;
- on non-Unix it had no lock at all.
Now:
- login/lock.rs: flock on Unix. Elsewhere, an atomic
credentials.lock.d
directory (stale after 120 s), and if the lock state can't be read it fails
closed. A waiter polls for up to LOCK_WAIT (30 s, longer than the request
timeout). If it still has no lock it returns the new
StoreError::RefreshBusy, having sent nothing and changed nothing. - Under the lock the file is re-read, and a record another process already
refreshed is used. - Before sending, the stored record loses its refresh token (a token-less
marker). A process that dies mid-request leaves a record that answers
NoRefreshToken, never a reusable spent token. - Any failure once the request may have reached Identity clears the stored
credentials, and the in-memory session goes token-less too. That covers a
timeout, a reset, an error answer, a bad body, and a failed save of the new
pair. Only a connection that was never made restores the old token. - An answer with no new refresh token stores none; the spent one is not kept.
- client::refresh is bounded by REFRESH_TIMEOUT (20 s).
Tests (store_refresh_tests.rs). Each scenario runs in a child process, which
is this test binary re-invoked. Identity is a 127.0.0.1 fixture and all
tokens are fixtures.
- Two processes with one expired file: 1 refresh, and both get the new pair.
- A timeout after sending clears the file, and the next run sends nothing.
- A leftover token-less record is never sent.
- A held lock gives RefreshBusy and sends nothing.
- A refused connection keeps the token.
- An answer without a refresh token keeps none.
Mutation checks: dropping the re-read under the lock gives 2 refreshes;
keeping the token after an error fails the timeout test.
cargo test -p ruview-auth --all-features: 70 + 25 + 2 pass.
- fix(ruview-auth): File::lock on a never-deleted lock file everywhere; durable writes (review-393)
Fixes from review-393 on #2599:
- Lock. A takeover-by-removal lock (like the non-Unix lock directory in the
previous commit) can let two takers both hold it; review-393 reproduced this
1 in 100 on the console CLI's equivalent. The lock is nowFile::lock
(stable since 1.89, the repo's pinned toolchain) on every platform:- it locks
credentials.lock, which is never deleted; - it uses flock on Unix and LockFileEx on Windows;
- the OS releases it when the holder exits or dies, so there is no
staleness heuristic; - a lock that can't be taken at all fails closed;
- the 30 s wait followed by RefreshBusy is unchanged.
The crate no longer calls libc. The optionallibcdependency is left in
Cargo.toml so Cargo.lock doesn't change in this PR.
- it locks
- Durability. On Unix the parent directory is fsynced after the rename. On
other platforms write_private now sync_all's the tmp file before the rename. - Child processes in the refresh tests have the test-only hooks removed from
their environment.
New tests:
- a lock held by a live child process blocks; once the child is killed
(never releasing), the lock frees; - 8 threads x 25 rounds never have more than one holder;
- the lock file is never unlinked.
Stress: the full lib test binary ran 90 times, 6 in parallel, with 90 passes.
- fix(ruview-auth): make the credentials directory fsync best effort (L8)
The parent-directory fsync ran after the rename had already put the new
pair in place, and its error was fatal. On FUSE or network mounts that
reject a directory fsync (EINVAL/ENOTSUP), every refresh would clear the
new pair and sign the user out. It is now logged with tracing::warn and
ignored; the tmp file's sync_all before the rename stays fatal.
Corrects the marker-save comment, adds tests that inject a directory-fsync
failure through RUVIEW_TEST_FAIL_DIR_FSYNC (save succeeds; refresh rotates
and keeps the new pair), and drops the now-unused optional libc dependency.
- fix(ruview-auth): never launch a browser from tests
open_browser's unit test called the real launcher, so every
cargo test -p ruview-auth opened a tab at http://127.0.0.1:1/nope in the
developer's browser. Under cfg(test), open_browser now records the command
it would run instead of spawning it, and the test asserts that command.
Source commit: f7de049ebd637aae7f5d20d51cc23162938cbad9
Container images publish separately through the sensing-server release workflow.
Firmware downloads are attached to the dedicated vX.Y.Z-esp32 releases.