Repository navigation
TIGER-378: TTL + expiry + rotation for personal access tokens - #361
Merged
Merged
Conversation
The one real Zeabur-#1 echo: a PAT was mint-once and immortal (died only on an explicit revoke), so a leaked long-lived MACHINE PAT (node<->control-plane host/billing/vps token) stayed valid until a human noticed. Core substrate (safe: NULL expires_at = never expires, so every existing token and every ordinary user PAT is unchanged until a caller opts into a TTL): - migration 0057: add user_credential.expires_at DATETIME NULL (additive, instant). - createToken($userId, ?int $ttlSeconds): write expires_at when a TTL is given; return it. rotateToken() mints a fresh token for the same owner (overlap-safe — the caller revokes the old one only after distributing the new). - verifyTokenCredential(): refuse a token past expires_at, exactly like a revoked one. - tokensFor(): surface expires_at for a manage-tokens screen. - purgeExpiredTokens() + the core.auth.purge_expired_tokens daily job (hygiene; verification already refuses an expired token). Tests: TTL expires + stops verifying; a default token never expires; a zero/negative TTL means no expiry; purge sweeps only the expired; tokensFor carries expires_at; rotate mints a working token with overlap. 13/13 UserCredential + 16/16 schedule green. Follow-on (dev-first, not in this change): mint the fleet machine PATs WITH a TTL + a control-plane rotation job that re-mints and pushes to the node with an overlap window — proven on the dev CP/node with monitoring before it reaches prod, since a failed rotation would otherwise expire a healthy node's auth. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ASauLLscjqdsNqBNsx2Typ
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.
Closes the Zeabur-#1 echo for long-lived machine PATs: a PAT was mint-once and immortal (died only on explicit revoke).
Core substrate (safe —
NULL expires_at= never expires, so every existing token and ordinary user PAT is unchanged until a caller opts into a TTL):0057:user_credential.expires_at DATETIME NULL(additive, instant, no backfill).createToken($userId, ?int $ttlSeconds)writesexpires_atwhen a TTL is given;rotateToken()mints a fresh token overlap-safe (caller revokes the old only after distributing the new).verifyTokenCredential()refuses an expired token exactly like a revoked one.tokensFor()surfacesexpires_at;purgeExpiredTokens()+ thecore.auth.purge_expired_tokensdaily job sweep them.Tests: TTL expires + stops verifying; a default token never expires; zero/negative TTL = no expiry; purge sweeps only the expired;
tokensForcarriesexpires_at; rotate mints a working token with overlap. 13/13 UserCredential + 16/16 schedule green (PHP 8.5, MariaDB).Follow-on (not in this PR, dev-first): mint the fleet machine PATs (node↔CP host/billing/vps) WITH a TTL + a control-plane rotation job that re-mints and pushes to the node with an overlap window — proven on the dev CP/node with monitoring before prod, since a failed rotation would otherwise expire a healthy node's auth.
🤖 Generated with Claude Code
https://claude.ai/code/session_01ASauLLscjqdsNqBNsx2Typ