vole
Clone
Read only, no credentials:
https://rodent.software/git/vole.git
Write over SSH with a registered key:
git clone ssh://git@0.0.0.0:2222/vole.git
A free and open-source forge that lives in your Git repo.
Give a job a credential for the bot it acts as
6e1fca5115b709d31eeb51864b187d79aa104e5f · Keenan Nemetz · 6d ago · parent 446542e6
Give a job a credential for the bot it acts as A workflow can name a bot account with `bot:`. When the job is leased the instance generates a key for that run, stores the public half with the run, repository and expiry, and sends the private half on the lease channel. The runner writes it into the job's run directory with a known_hosts entry for the instance, so a step's `git push` or `vole issue comment` authenticates as the account and nothing has to be wired per job. The account's role is the permission, in full. The credential replaces exactly one requirement — that writing to the issues branch needs `maintain` — and adds no rule of its own. What a job may write there is what its account may do, asked the same way the browser asks: discuss, file an issue, manage an item it wrote, open a change from a branch it may push, triage and approve when the role allows it. Those are the ACL's own capabilities (`CanDiscuss`, `CanOpenRequest`, `CanTriage`, `CanApprove`), so a maintainer's job may do everything a maintainer's key may do, including labels, states, and other people's items. A session is scoped only when the fingerprint it authenticated with is a live credential row; an expired one reads as absent, so the push falls back to the account's own role and is refused where a contribute account cannot write. Two things end the key: the run finishing, which drops the row, and the expiry, which is what stops a credential whose runner was killed and never reported. The key is also masked in the log like a secret, since a step that cats it should not leave it in the attempt. Closes #165.
server/ci.go +9
| @@ -220,6 +220,7 @@ func (s *Server) queue(m *repo.Meta, repoName string, spec queueSpec) int { | |||
| 220 | 220 | Env: job.Env, | |
| 221 | 221 | Network: job.Network, | |
| 222 | 222 | Timeout: durationText(job.Timeout), | |
| 223 | Bot: job.Bot, | ||
| 223 | 224 | ReleaseArtifacts: releasePaths(job), | |
| 224 | 225 | PagesPath: site, | |
| 225 | 226 | Created: time.Now().UTC(), | |
| @@ -464,6 +465,14 @@ func (s *Server) watchLeases(ctx context.Context) { | |||
| 464 | 465 | s.Log.Warn(fmt.Sprintf("ci: %d job(s) returned to the queue, %d failed after %d attempts", | |
| 465 | 466 | back, failed, runs.MaxAttempts)) | |
| 466 | 467 | } | |
| 468 | // A run whose runner disappeared never sends a finish, so the key it was | ||
| 469 | // given is ended by its expiry. Sweeping here keeps the rows bounded and | ||
| 470 | // means a credential that is refused is not still sitting in the table. | ||
| 471 | if dropped, err := s.Runs.ExpiredCredentials(time.Now().UTC()); err != nil { | ||
| 472 | s.Log.Warn("ci: cannot sweep expired run credentials", "err", err) | ||
| 473 | } else if dropped > 0 { | ||
| 474 | s.Log.Info("ci: swept expired run credentials", "credentials", dropped) | ||
| 475 | } | ||
| 467 | 476 | // Presence is not history: a runner that was killed leaves a row nothing | |
| 468 | 477 | // will ever refresh, so it is forgotten rather than shown as connected. | |
| 469 | 478 | if n, err := s.Runs.PruneSessions(time.Now().UTC().Add(-10 * time.Minute)); err != nil { | |