Skip to content

fix(ui): decide auth key expiry on the server - #704

Open
decky-grande wants to merge 1 commit into
tale:mainfrom
decky-grande:fix/auth-key-expiry-server-clock
Open

decky-grande wants to merge 1 commit into
tale:mainfrom
decky-grande:fix/auth-key-expiry-server-clock

Conversation

@decky-grande

Copy link
Copy Markdown

Fixes #703.

Headscale stamps an expired key's expiration with its own clock, and the auth keys page compared that against the browser's clock. With the browser a second or two behind, a key that was just expired stayed listed as active, with its Expire button.

The loader now marks each key expired using the server's clock, and the status filter and the row read that flag instead of calling new Date() in the browser.

  • Regression test in tests/integration/headplane/auth-keys.test.ts: expire a key, then check the loader lists it as expired. It fails before the change.
  • Changelog line under # Next → ## Fixes.
  • Checked by hand with the harness and a browser clock set 2 s behind: before, the row read "Expires: now" with the Expire button; after, it reads "Expired just now" with no button.

pnpm test:unit, pnpm run typecheck, pnpm run lint and the auth keys integration tests pass locally against Headscale 0.29.5.

🤖 Generated with Claude Code

Headscale stamps an expired key with its own clock, and the auth keys
page compared that against the browser's clock. A browser even a second
behind kept listing a key it had just expired as active, with its Expire
button, until the next reload some time later.

The loader now marks each key expired using the server's clock, and the
status filter and row use that flag.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ No blocking issues — one non-blocking note below.

Approach: sound — expiry is now decided in the loader, where the clock that stamps the timestamp lives, and it matches how mapNodes already computes node expiry server-side.

Reviewed changes

Reviewed the full diff (4 files, 1 commit): the auth-keys loader annotates each key with expired from the server clock, the row and status filter read that flag, a regression test covers an expired key, and the changelog has a ## Fixes line.

  • Server-side expiry flag. overview.tsx snapshots Date.now() and marks every listed key expired before returning it, so a browser clock behind the server no longer keeps a just-expired key active.
  • Row and filter read the flag. auth-key-row.tsx and the status filter use key.expired; the client-side new Date() comparison is gone.
  • Regression test. Expires a key through the action and asserts the loader lists it as expired, which fails without the new field.

Non-blocking

  • A key that expires while the page is open stays listed as active until the loader revalidates. expired is a loader-time snapshot, so once a key's expiry passes with the page open, its row keeps the Expire button and the Active filter keeps it; before this change, changing the status filter recomputed now and corrected both. overview.tsx

Pullfrog  | Fix it ➔ | View workflow run | Using deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏

This branch has not been deployed

No deployments
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.

Auth key stays listed as active after expiring it when the browser clock is behind

1 participant