Aller au contenu principal
BlueForge
Commencer gratuitement

Agent pack

Tokens: minting, storing, scoping, rotating

Where tokens come from and how they are scoped — read from docs and CLI source, no token minted.

Rendered from docs/agent-pack/tokens.mdrelease v0.2.0Edit on forge-git

Verified 2026-10-11 by reading docs and CLI source (no command was run, no token minted, no secret store read). Sources: packr-registry/CLAUDE.md + docs/07-tokens.md, packages/cli/cmd/*.go; forge-control packages/forge-cli/src/commands/{api-key,login,vault}.ts; forge-git CLAUDE.md + packages/cli/src/commands/token.ts, lib/scope-aliases.ts; forge-auth CLAUDE.md + packages/fauth/README.md.

claude/TOKENS.md (Oct 9) is largely wrong. Do not follow it. It uses packr admin tokens create (packr is the server; the client is packr-cli), tea user create-token / fgit secret set (unconfirmed; no fgit secret exists), a minted FORGE_CONTROL_DEPLOY_TOKEN (the real one is BLUEFORGE_DEPLOY_TOKEN, a shared bearer, not minted per app), 30/90-day cadences no CLI enforces, and telling you to echo tokens into files. Its fauth section is accurate.

Rules for agents (all CLIs)

  • Agents do not mint, rotate or revoke tokens, and never read, print or write token values unless the operator explicitly asks for that action. Hand the step to the operator (! <command>). If a sweep/automation token is needed, the operator authorises it and chooses the identity.
  • Never put a token in argv (ps shows it), in a commit, a PR body, a log or a message. Prefer --output-file (0600), stdin, or a keychain.
  • One token per purpose and per repo. Narrowest role/scope that works. Never admin/@full/all for automation.
  • Verify a token without printing it (each section says how). Rotation order is always: mint new, verify, swap consumers, revoke old last.

packr-cli (registry https://api.packr.blueforge.studio)

Binary is packr-cli (not packr, the server).

Purpose Role Notes
Human / the session that mints tokens admin only that session
CI publish ci-publish scope @blueforge-studio, one token per repo
CI install ci-readonly separate secret from the publish token
Sweep / automation maintainer or ci-publish never admin

Roles: ci-readonly read; ci-publish read+publish; maintainer +unpublish; admin all. Prefer the bare --scope @org form: a scope with an ecosystem and no namespace is ecosystem-wide, and unscoped package names bypass the scope check.

Commands (token_remote.go, rotate.go): token create <name> [--role --ecosystem --namespace --scope --expires <days> --output-file <p> --to-forge-git <owner>/<repo>:<SECRET> --registry], token list, token revoke <id>, token reissue, token verify, rotate [--name --scope --expires --output-file --to-forge-git], login [--provider --password --name --scope --registry], doctor, whoami, logout. Default expiry 30 days (token create), 90 days (device flow). Expiry is enforced (internal/auth/middleware.go:59); packr-registry/CLAUDE.md saying otherwise is stale.

  • Stored in ~/.packr/credentials.json or keychain service packr-cli (account = registry URL); login / rotate also write ~/.npmrc. Env: PACKR_TOKEN (wins over the stored login), PACKR_REGISTRY, PACKR_CREDENTIAL_STORE.
  • Rotate: unset PACKR_TOKEN first (rotate refuses while it is set), mint with --output-file (or --to-forge-git to write straight into a forge-git Actions secret without printing), check token list, swap the CI secret and local stores, revoke the old one last.
  • Verify: packr-cli doctor (server probe). whoami only decodes the local store and passes on a dead token. GET /-/v1/credential/verify?scope= checks scope.
  • 401 on admin routes while publish still works = token predates a JWT_SECRET rotation: login --password again. login --password "$PASS" puts the password in argv.
  • No-browser path: POST /-/v1/login, then POST /api/v1/admin/users/me/tokens (see packr-registry/CLAUDE.md). A token minted as the wrong user is invisible in token list.

forge CLI (forge-control)

  • forge login [--api-url] [--api-key] only saves a key to ~/.config/forge/credentials.json. Device-code OAuth login is not implemented (login.ts:9).
  • Env: FORGE_API_KEY, FORGE_API_URL, MISSION_CONTROL_URL, FORGE_PROFILE, FORGE_APP, FORGE_ENV, FORGE_CONFIG_PATH.
  • forge api-key create --project <slug> --name <n> [--scope metrics:read] [--out <file>] [--quiet], list --project <slug>, delete <key-id>. create needs project admin; metrics:read is operator-only. Use --out (0600, printed masked); the default prints plaintext once. Only a SHA-256 hash is stored server-side. Use a per-project deployer key for deploys. Rotate: mint, check, forge login --api-key "$(cat f)" then rm f, then delete the old key.
  • forge vault: deployer-allowed set|set-many|get|list|push|audit; admin-only rekey|delete|bulk-delete|rotate. Use set --stdin|--file|--generate, never --value (visible in ps).
  • BLUEFORGE_DEPLOY_TOKEN: a shared bearer sent as X-Forge-Deploy-Token, equal to the receiver's FORGE_DEPLOY_TOKEN. Read from env then /etc/forge/blueforge-deploy.env. If unset, registration is silently skipped. I found no mint endpoint.
  • Gitea admin-token rotation: forge-control/docs/runbooks/rotate-gitea-admin-token.md (mint, probe, roll, check last_used_at, revoke, confirm 401). Keychain service forge-secrets.

fgit (forge-git)

  • fgit login is manual: opens $FORGE_GIT_URL/user/settings/tokens, you paste a PAT; saved to ~/.config/forge/credentials.json (0600). The "OAuth device flow" text in forge-git/CLAUDE.md is wrong.
  • Credential resolution: $FORGE_GIT_TOKEN, then credentials.json, then ~/.forge-secrets/forge-git-token, forge-git.token, forge-git.token.new. A stale FORGE_GIT_TOKEN env var overrides a fresh login and causes client-side 401s. Diagnose with fgit token doctor.
  • fgit token generate <user> <name> [--scopes --output-file --expires-in --save --print --via auto|api|ssh], token rotate <user> <old> [--new-name --keep-old --update-tea], list, explain, doctor, scopes list|explain. Default --expires-in 7d (never allowed). An explicit --expires-in <date> is refused before minting when the transport cannot set one (neither the wrap API nor this Gitea's generate-access-token can — remedy printed: --expires-in never); the no-flag default keeps its loud warn-and-retry on the SSH path. Without --output-file the token goes to a 0600 tempfile; --print puts it on stdout, do not use it. Minting for other users, --via ssh and fgit-ops … are operator-only.
  • Aliases: @repo-creator (write:organization, write:repository, read:organization, read:repository, read:user; no write:user — for fgit init, revoke right after); @readonly (read:user, read:organization, read:repository); @contributor (write:repository, read:user); @developer (contributor + read:organization, read:repository; no write:issue despite its description); @default (write:repository, write:issue, read:user, read:issue, read:organization, read:repository); @admin; @full (Gitea all).
  • Recommended: human dev @default (7d); CI/sweep a narrow explicit scope or @developer plus an explicit write:issue if it must comment; @admin/@full stay on the operator machine.
  • Ambient token: id 241 (ambient-2026-09-28-operator-narrowed), never expires, rotate by 2026-12-27. forge-admin (id 1) has no 2FA and reaches everything: operator plane only. Do not set prohibit_login on a bot account; it kills that account's tokens (this killed flake-record-ci).
  • Token-mint 401 after restart: the server side was closed 2026-09-23; the remaining cause is a stale client env var or secrets file.

fauth (forge-auth), if a task needs it

API keys fk_… with scope strings (14 defined in src/lib/scopes/scopes.ts); a bearer can mint a narrower key (POST /api/v1/keys, self-narrowing); revoke with DELETE /api/keys/:id or fauth logout. No-browser mint: fauth login --admin --email <e> [--app <slug>] [--days 1-90, default 30]. --admin overwrites an existing ~/.forge-secrets/forge-auth.json: always use a scratch FORGE_SECRETS_DIR. Env: FAUTH_TOKEN (wins over the file), FAUTH_BASE_URL, FAUTH_APP_ID, FAUTH_EMAIL, FAUTH_ADMIN_KEY. Minted keys self-verify via GET /api/v1/me and are revoked if that fails.

UNVERIFIED

Current token state (the "both packr tokens 401" note is likely resolved by the 2026-09-21 and 2026-10-02 rotations); forge-control/docs/secrets/rotation-design.md and docs/08-cli-auth.md were not read in full; fgit secret set / tea mint commands are unconfirmed; the --save help text in fgit shows an old credentials path.

Restez informé

Notes de version et accès anticipé

Un e-mail à chaque nouveauté : fonctionnalités de la plateforme, nouvelles applications et invitations de lancement. Inscrivez-vous sur la liste d'attente pour accéder en avant-première à l'inscription en libre-service et aux sites de promotion.

Pas de spam. Désabonnement en un clic.