Skip to content

Scope the forge credential an agent run receives

An agent run clones, pushes and opens its pull request with a git credential that SupaCloud hands into the run’s container. By default that is the credential stored for the workspace or for the person who launched the run. A stored personal or OAuth token usually reaches every repository that account can see, and it does not expire.

Where the forge supports it, SupaCloud replaces the stored token with a token that is limited to the run’s project and to the run itself.

Forge Per-run token What the container receives
GitLab (gitlab.com and self-managed) Yes: a project access token A token for this one project, with the Developer role and the write_repository and api scopes. It is revoked when the run ends and expires on its own at the end of the next day.
GitHub No The stored token. A short-lived, scoped GitHub token exists only as a GitHub App installation token, which needs a GitHub App credential that SupaCloud does not store yet.
Forgejo and Gitea No The stored token. These forges create tokens only with the account password, and their tokens have no expiry date.
Bitbucket No The stored token.

The stored GitLab token mints the per-run token, so it needs:

  • the Maintainer role (or higher) on the project;
  • the api scope;
  • a GitLab edition that offers project access tokens (every self-managed edition, and the paid tiers on gitlab.com).

If the stored token cannot mint one, the run keeps the stored token exactly as before, and the server logs a warning that names the project. Check the server log for GitLab run token refused to find such projects.

Limit the stored credential where no per-run token exists

Section titled “Limit the stored credential where no per-run token exists”

On GitHub, Forgejo, Gitea and Bitbucket, give agent runs a credential that reaches as little as possible:

  • use a dedicated bot account that is a member only of the repositories agents work on;
  • on GitHub, use a fine-grained personal access token limited to those repositories, with an expiry date;
  • on Forgejo and Gitea, scope the token to write:repository and write:issue, and rotate it on a schedule (see the secret rotation register).