Support multiple-account auth in fj (per-invocation account/credential override) #157
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Problem
fjauthenticates against rasterhub.com via a single git-credential helper tied to one account (here, the human operatorstephen). Our agent fleet needs to post PR comments and formal reviews as a separate QA account (gerri) so agent activity is attributable and distinct from the operator, and so reviews on agent-authored PRs aren't blocked by "can't review your own pull." Today everyfjaction attributes to the default account, so we work around it by calling the Forgejo API directly with a PAT (e.g.POST /repos/{o}/{r}/pulls/{n}/reviewswithAuthorization: token <gerri-PAT>), bypassingfjentirely.Request
Let
fjselect the account/credential per invocation, e.g.:FJ_TOKEN/FJ_ACCOUNT) and/or a--token/--accountflag, and/orfj auth login --account gerri;fj --account gerri pr review ...).Default behavior unchanged when no override is given.
Must be flexible for BOTH account types (operator requirement)
The account model must not assume a single forge or a fjord-managed identity. Profiles must be keyed per (host, account), covering both:
stephen,gerri), andSo an agent can act on a customer's independent Forgejo instance under that instance's own account, with credentials scoped to that
(host, account)pair, while rasterhub.com fjord identities continue to work side by side. Selection (env/flag/profile) resolves the right token for the target host + chosen account.Acceptance
fj pr review/fj pr comment/fj issue createcan post as a specified non-default account given that account's token.Use case
Multi-agent fleet on usw-dev-01: lanes post QA reviews as
gerri, the lead/operator act asstephen. Agents may also need to act on a customer's independent Forgejo instance under its own standalone account. Filed by gerri to dogfood the need.Closing: the request is implemented.
What shipped:
fj --account <login>/FJ_ACCOUNTruns one command as a named account withFJ_TOKEN(or a host-scoped token). The login is verified against/userfirst, and every other way a request could pick its identity is refused while an override is active.fj auth login --account,fj auth switch).fj status,auth token,refresh,sessionandlogout, all scoped to the selected profile. Session cookies are stored per profile.fj worksessions are tied to the host, account and instance they were saved under, andwork resume/work continuerefuse another identity.Behavior without
--accountis unchanged, and credentials are scoped to their (host, account) pair, including standalone Forgejo hosts next to Fjord-managed ones. Usage is indocs/account-override.md.Known limits, tracked separately: no command sends a stored profile cookie yet, and a config switch by another process while
work contextis gathering can still pair old data with the new identity.