feat(secrets): persist operator admin PAT, hard-fail rotate-secret without it #933
No reviewers
Labels
No labels
area:agents
area:dashboard
area:database
area:design
area:design-review
area:flows
area:infra
area:meta
area:security
area:sessions
area:webhook
area:workdir
security
type:bug
type:chore
type:meta
type:user-story
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
charles/claude-hooks!933
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/onboarding-persist-admin-token"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
applynow persistsbody.admin_tokenunder a per-forge secret name (FORGEJO_ADMIN_TOKEN/GITLAB_ADMIN_TOKEN) after a successful mint, so later repo-admin operations reuse it without re-prompting the operator.POST /watched-repos/:owner/:name/rotate-secretreads that secret instead of grabbing any agent token (which lacks admin scope on operator-owned repos and silently 502'd oneditWebhook). Returns 412 with a clear message when the secret is absent or the forge is unsupported./secretsHTTP surface manages the value going forward (POST / PUT / DELETE / rotate). No schema changes —secrettable + name conventions cover it.Why
Discovered while debugging silent webhook signature failures on
charles/claude-hooks. The rotate-secret route picked the first agent token vialistResolvedAgents(); agent tokens do not carry admin perms on operator-owned repos, soeditWebhookreturned 502 with no actionable error. The admin PAT entered during onboarding was used once formintAgentTokensViaAdminand then dropped on the floor.Files
apps/server/src/setup/admin-bootstrap.ts— newadminTokenSecretName(forge)helper.apps/server/src/http/handlers/onboarding-apply.ts— encrypt + upsert admin token after successful mint.apps/server/src/main.ts— rotate-secret reads admin PAT from secret store, hard-fails when missing.Test plan
just qa— 3262 pass / 0 fail.FORGEJO_ADMIN_TOKENrow appears in/secrets.rotated_atbumps).POST /watched-repos/.../rotate-secretsucceeds with admin token present.DELETE /secrets/FORGEJO_ADMIN_TOKEN.PUT /secrets/FORGEJO_ADMIN_TOKENfrom settings UI.Out of scope
editWebhookPATCH silently ignoressecretfield updates — rotate route should use DELETE+CREATE instead. Tracked separately./webhooks/vs/webhook/) producing dead hooks at install time. Tracked separately.0009_agent_type_config_provider_dispatch.sql, schema columnsprovider_chain_json/failover_json/usage_threshold_tokens,addProviderDispatchColumnsIfPresent,handleUpsertDispatch,restoreDispatchConfigRevision,PUT /api/agent-types/:name/dispatch,mergeAgentoverrides,agent-db-skills-tab.tsxquery-key fixes, andapi.tsdispatch diff-and-PUT — none of which are mentioned in the title, the Files list, or (presumably) the linked issue. Split it: land the PAT/rotate fix as-is, open a second PR for the dispatch feature.a00628a73c8e9894444bGood catch. Branch was cut from
fix/agent-type-provider-dispatchsoddf660c7rode along.Rebased
fix/onboarding-persist-admin-tokenontoorigin/main(dropping the provider-dispatch commit) and force-pushed. Diff is now the 3 files in the PR body only:The provider-dispatch work stays on PR #931 as originally intended.