Skip to content

chore(keys): remove the initKeys and keyManager scaffolding, which writes keys nothing reads #243

Description

@Bccorb

Fell out of #205, where initKeys was removed from the container entrypoint (#236). The step is gone from the boot path, but the code is still in the tree and still wired into the dev stack, and it does nothing useful in either mode.

What it does

src/scripts/initKeys.ts calls ensureKeys() in src/scripts/keyManager.ts:

  • Production: ensureKeys() is if (!isProduction) { ... } followed by a comment placeholder. It returns immediately. Real keys come from SEAMLESS_JWKS_KEY_*_PRIVATE, which validateEnvs.sh requires.
  • Development: it writes ./keys/private.pem and ./keys/public.pem. Nothing reads either file. src/utils/signingKeyStore.ts keeps its own dev keys at ./keys/dev/ and generates them lazily with an exclusive write, and src/controllers/jwks.ts serves ./keys/dev/public.pem. Two different directories.

So a fresh dev clone generates two RSA keypairs, and one of them is never used.

What is left to clean up

The judgement call

keyManager.ts is not obviously abandoned. Its production branch carries a deliberate placeholder:

// PRODUCTION MODE
// Implement a first time JWKS rotation. See Seamless Auth docs for guides

So this is either scaffolding for first-boot JWKS rotation that should be built, or a stub that should go. That is a product decision, not a cleanup one, which is why #236 removed the boot cost and left the files alone rather than deleting JWKS-adjacent code in a performance PR.

Decide which, then either:

  • build it, and make the dev path use one key directory rather than two, or
  • remove it, dropping the compose line, the two source files and their specs, and folding anything worth keeping into signingKeyStore.

Either way the dev stack should stop generating a keypair nothing loads.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Fixes

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions