Skip to content

auth: add file locking for tokens.json concurrent access #329

@staging-devin-ai-integration

Description

Problem

FileTokenMetadataStore performs read-modify-write cycles on tokens.json without file-level locking. When the CLI and server are running concurrently (e.g. during rotate-key), one process can clobber the other's changes.

This was pre-existing but becomes materially more likely now that rotate-key is a hot path that triggers both CLI writes (mint new admin token) and server writes (ongoing token operations).

Proposed fix

Add flock-based advisory file locking around all tokens.json and revocations.json read-modify-write operations in FileTokenMetadataStore and FileRevocationStore.

Context

Surfaced during review of #324.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions