Support multiple-account auth in fj (per-invocation account/credential override) #157

Closed
opened 2026-06-12 16:51:28 +00:00 by gerri · 1 comment
Member

Problem

fj authenticates against rasterhub.com via a single git-credential helper tied to one account (here, the human operator stephen). 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 every fj action 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}/reviews with Authorization: token <gerri-PAT>), bypassing fj entirely.

Request

Let fj select the account/credential per invocation, e.g.:

  • an env var (FJ_TOKEN / FJ_ACCOUNT) and/or a --token / --account flag, and/or
  • named credential profiles (fj 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:

  • a fjord account (rasterhub.com / fjord-managed identity, e.g. stephen, gerri), and
  • a standalone single-instance Forgejo account (an arbitrary host + token, not fjord-managed).

So 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 create can post as a specified non-default account given that account's token.
  • The default (box-helper) account is used when no override is set.
  • Per-(host, account) profiles: both fjord (rasterhub.com) and standalone arbitrary-host Forgejo accounts are selectable, with credentials scoped to the host they belong to.
  • Token/account never logged.

Use case

Multi-agent fleet on usw-dev-01: lanes post QA reviews as gerri, the lead/operator act as stephen. 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.

## Problem `fj` authenticates against rasterhub.com via a single git-credential helper tied to one account (here, the human operator `stephen`). 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 every `fj` action 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}/reviews` with `Authorization: token <gerri-PAT>`), bypassing `fj` entirely. ## Request Let `fj` select the account/credential per invocation, e.g.: - an env var (`FJ_TOKEN` / `FJ_ACCOUNT`) and/or a `--token` / `--account` flag, and/or - named credential profiles (`fj 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: - a **fjord account** (rasterhub.com / fjord-managed identity, e.g. `stephen`, `gerri`), and - a **standalone single-instance Forgejo account** (an arbitrary host + token, not fjord-managed). So 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 create` can post as a specified non-default account given that account's token. - The default (box-helper) account is used when no override is set. - Per-(host, account) profiles: both fjord (rasterhub.com) and standalone arbitrary-host Forgejo accounts are selectable, with credentials scoped to the host they belong to. - Token/account never logged. ## Use case Multi-agent fleet on usw-dev-01: lanes post QA reviews as `gerri`, the lead/operator act as `stephen`. 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.
Owner

Closing: the request is implemented.

What shipped:

  • #307 (v0.8.0): fj --account <login> / FJ_ACCOUNT runs one command as a named account with FJ_TOKEN (or a host-scoped token). The login is verified against /user first, and every other way a request could pick its identity is refused while an override is active.
  • #308 (v0.8.0): named, verified PAT profiles per host and account, stored next to the host entries, with an explicit default (fj auth login --account, fj auth switch).
  • #309, #310, #311 (v0.8.0): Fjord OIDC profiles, per-account instances, and routing for browser shortcuts, mute and inbox filtering, fj status, auth token, refresh, session and logout, all scoped to the selected profile. Session cookies are stored per profile.
  • #317 (merged, in the next release): saved fj work sessions are tied to the host, account and instance they were saved under, and work resume / work continue refuse another identity.

Behavior without --account is unchanged, and credentials are scoped to their (host, account) pair, including standalone Forgejo hosts next to Fjord-managed ones. Usage is in docs/account-override.md.

Known limits, tracked separately: no command sends a stored profile cookie yet, and a config switch by another process while work context is gathering can still pair old data with the new identity.

Closing: the request is implemented. What shipped: - #307 (v0.8.0): `fj --account <login>` / `FJ_ACCOUNT` runs one command as a named account with `FJ_TOKEN` (or a host-scoped token). The login is verified against `/user` first, and every other way a request could pick its identity is refused while an override is active. - #308 (v0.8.0): named, verified PAT profiles per host and account, stored next to the host entries, with an explicit default (`fj auth login --account`, `fj auth switch`). - #309, #310, #311 (v0.8.0): Fjord OIDC profiles, per-account instances, and routing for browser shortcuts, mute and inbox filtering, `fj status`, `auth token`, `refresh`, `session` and `logout`, all scoped to the selected profile. Session cookies are stored per profile. - #317 (merged, in the next release): saved `fj work` sessions are tied to the host, account and instance they were saved under, and `work resume` / `work continue` refuse another identity. Behavior without `--account` is unchanged, and credentials are scoped to their (host, account) pair, including standalone Forgejo hosts next to Fjord-managed ones. Usage is in `docs/account-override.md`. Known limits, tracked separately: no command sends a stored profile cookie yet, and a config switch by another process while `work context` is gathering can still pair old data with the new identity.
Sign in to join this conversation.
No milestone
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
rasterstate/fj#157
No description provided.