Skip to content

Write a credential stub at minting; discover installations by JWT #83

Closed

Description

@radiusred-cody

Goal

Fold back finding 11 on #73: /user/installations fails under real operator credentials, so both live reviewer sessions minted via raw JWT with hand-supplied IDs. identity new already holds the App ID at creation: persist a small credential stub beside the private key under ~/.config/codecrew (slug, app_id, client_id), and teach scripts/codecrew-token to read the stub, mint the JWT, and discover the installation via GET /app/installations — no user-credential API dependence at all; the org and /user lookups remain fallbacks for stubless legacy Apps, and the docs say how to hand-write a stub for an App minted before this change. Tests ride along per #46 for the Go side; the script is smoke-verified by minting a real token.

Requirements

M5-R2

Plan

  1. identity new persists a credential stub beside the key: ~/.config/codecrew/<slug>.json carrying slug, App ID, and client ID — extracted into a writeCredentials helper so the write path is unit-testable; the verb prints both paths.
  2. scripts/codecrew-token resolution order becomes: stub (App ID from the file, JWT minted, installation discovered via GET /app/installations under the App's own JWT — preferring the installation on the current owner, else the only one) → legacy /orgs/{owner}/installations → /user/installations. No user-credential dependence when the stub exists; the error message tells a stubless legacy operator how to hand-write one.
  3. docs/identities.md: the stub in the minting flow and the one-line hand-written stub for Apps minted before this change.
  4. Tests per feat: request review from the reviewer-role holder #46 on the Go side (stub path convention, writeCredentials content and modes); the script is smoke-verified by minting real tokens through both the stub and legacy paths.

Ask-the-human points

None — mechanical remediation of finding 11.

Metadata

Metadata

Assignees

No one assigned

    Labels

    cc:task

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions