Access and tokens
Access and tokens
How branchd decides what a key, a bot or a sign-in may do, and which credential to use for which job.
Every request to branchd, whether through the API, git over HTTPS, the container registry or Go modules, is allowed only when all of these allow it:
- Scopes: which features, at which level. Every credential carries
scopes such as
forge:contents:read(clone) orforge:package:edit(push images). See Scopes and levels. - Resources: which repositories and groups. A credential either reaches everything its owner can, or is limited to named repositories and groups. A group covers everything under it.
- The owner's current role. A key or token never does more than the person or bot it belongs to may do today. Lose a role, and every credential you hold loses it at once.
A level such as read or write is only a shortcut for a set of scopes. What a credential stores, and what branchd checks, is always the scopes.
Which credential to use
| You want to… | Use |
|---|---|
Work from your own machine with the branchd CLI, git and Docker | branchd auth login. It signs you in and keeps the token fresh. |
| Give one script or tool a narrow login that reaches only some repositories | A scoped login (--repo, --group, --scopes) |
| Give a script, CI system or registry client a long-lived credential that acts as you | A personal API key (xk_…) |
| Give automation a credential that belongs to a team, not a person | A bot and one of its keys |
| Let another company's application act for branchd users | OAuth, with the least scopes it needs |
| Run a job in a branchd pipeline | The job token, already in $BRANCHD_TOKEN |
Sending a credential
| Where | How |
|---|---|
| API | Authorization: Bearer <token or xk_ key> |
| git over HTTPS | The key or token as the password. The username is ignored. |
Container registry (registry.branchd.run) | docker login registry.branchd.run -u token --password-stdin, with the key on stdin. The username is ignored. |