Skip to content

[Request]: transfer store records owned by an API key when the key is rotated or revoked #732

Closed

Description

@jimhoyd

Problem or use case

With per-record ownership (#331), operator-issued API keys have no owning user, so auth sets the request principal to apikey:<key id>. Records created through a key are owned by that key. When the key is revoked, expires or is rotated to a new key, those records become unreachable. There is no way to move them to the replacement key or to a user.

Owner decision (2026-09-25): accept key-owned records as built in #331, and track transfer as a follow-up.

Proposed behavior and alternatives

  • An operator command alongside urlcode-store ownerless, e.g. urlcode-store reassign --from apikey:<old> --to <principal id>, run with the server stopped (it takes the directory lock), with a dry-run report first.
  • Optionally, key rotation in auth (api-key-rotate) could print the reassign command for any owned collections.
  • Alternative: let API keys be issued on behalf of a user (issueApiKey({ownerUserId})), so the principal is the user id and records survive key rotation. That is a larger auth change and needs a decision.

Activity

  1. added
    enhancement
    extension
    on Sep 25, 2026
  2. jimhoyd commented on Sep 25, 2026

    @jimhoyd
    CollaboratorAuthor

    Decision (owner, 2026-09-25): both.

    1. User-linked API keys (auth): issueApiKey({name, scopes, quota?, userId?}) and the CLI JSON gain an optional userId, validated against an existing user. A user-linked key sets the request principal to that user's id, so owned records belong to the user and survive key rotation. It still acts within the key's scopes, not the user's session roles. Keys without userId keep today's apikey:<key id> principal (service keys). Deleting or disabling the user must disable the keys linked to them. The migration is additive (a nullable column).
    2. Operator reassign (store): urlcode-store reassign --from <principal id> --to <principal id> [--collection name] [--dry-run], next to the ownerless commands. It runs with the server stopped (it takes the directory lock), reports counts first, and respects the per-owner limit ([Request]: per-owner record limit for owned store collections #731) or refuses if moving would exceed it.

    Ready to implement.


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementextension

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions