fix: stamp last_used_at on E2E connect - #110
Merged
Merged
Conversation
E2E nodes authenticate via proof and skip token_store.validate(), the only place that updated last_used_at. As a result `hermes node list` showed "-" forever for E2E nodes like workmac. Add TokenStore.touch_last_used(name) to stamp the record directly, and call it from the E2E branch after the proof is verified (offloaded to a thread, best-effort like the legacy path). - tokens.py: new touch_last_used() — skips revoked, no-ops unknown names - wsserver/server.py: stamp on E2E connect - tests/test_auth.py: 3 regression tests Signed-off-by: Blasius Patrick <blasius.patrick@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
hermes node listshowedLAST_USEDas-for E2E-authenticated nodes (e.g. workmac), even while connected.Root cause
last_used_atwas only ever written in one place:TokenStore.validate(). But E2E nodes authenticate via proof and explicitly skipvalidate()(is_valid = True # proof verified — skip token store check). So their records never got stamped.Fix
tokens.py— newTokenStore.touch_last_used(name)that stampslast_used_atdirectly (no token check — proof was already verified by the caller). Skips revoked records, no-ops on unknown names, best-effort write (same swallow-on-failure contract asvalidate()).wsserver/server.py— in the E2E branch, right after proof verification, calltouch_last_usedviaasyncio.to_thread(same offload pattern as the legacyvalidate()path).tests/test_auth.py— 3 regression tests: stamps existing record, skips revoked, no-ops on unknown.Notes
Test
pytest— 52 passed (3 new)ruff check— clean