Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Authentication

Every request except /health carries a ChirpAuth ID token. amber-git checks the token, then whether you may reach the repository, before anything else.

Tokens amber-git accepts

TokenWho holds itHow to get it
Machine tokenAn agent or serviceThe client_credentials grant, from a ChirpAuth client Stackwell has registered with amber-git
Person’s tokenA personA ChirpAuth sign-in token issued for amber-git

Only production ChirpAuth tokens are accepted, and only while they are unexpired. amber-git has no sign-in page of its own; agents, services and scripts use machine tokens:

TOKEN=$(curl -sS https://signin.chirpauth.com/token \
  -d grant_type=client_credentials \
  -d client_id="$CLIENT_ID" \
  -d client_secret="$CLIENT_SECRET" | jq -r .id_token)

Every ChirpAuth machine client is owned by a person. amber-git sends force-pushes and deletes to the repository’s owner for approval, never to the client’s owner.

Sending the token

Either way works for git and for amber-git’s other routes:

  • Bearer: Authorization: Bearer <token>. With git: git -c http.extraHeader="Authorization: Bearer $TOKEN" ....

  • Basic: the token as the password, with any username. This lets a git credential helper supply it. A helper is a program git runs with get that prints the credential:

    #!/bin/sh
    # Save as git-credential-amber-git on your PATH, then run:
    #   git config --global credential.https://amber-git.stackwell.tech.helper amber-git
    [ "$1" = get ] || exit 0
    echo username=token
    echo "password=$(my-command-that-prints-a-fresh-token)"
    

Without a valid token, amber-git answers 401 with two challenges, so git asks its credential helper:

HTTP/2 401
www-authenticate: Basic realm="amber-git"
www-authenticate: Bearer

unauthenticated
curl -sS -o /dev/null -w '%{http_code}\n' 'https://amber-git.stackwell.tech/any-repo.git/info/refs?service=git-upload-pack' | grep -Fx 401

Access to a repository

  • Closed by default. A repository admits only the people and ChirpAuth clients Stackwell has granted on it. Anyone else gets 403 or 404.
  • A machine client reaches the repositories granted to it and those granted to the person who owns it.
  • A read-only client is one Stackwell has registered for reading only, such as a CI runner. It reaches only the repositories granted to the client itself, may fetch and use the read routes, and is refused (403) on every push, including the first step of one.

What each caller may do

ActionAnyone granted on the repositoryRead-only client
Clone, fetchYesYes
Read files without cloningYesYes
Re-send to the GitHub mirrorYesYes
Push new branches, tags and branch fast-forwardsYesNo (403)
Move an existing tagNo (refused for everyone)No (403)
Force-push or delete a branch or tagQueued for the owner’s approvalNo (403)
Withdraw a queued force-push or deleteThe pusher who queued it, or the repository’s owner as a personNo (it can’t queue anything)
Check whether a queued push is still waitingThe same as withdrawNo (it can’t queue anything)
Approve or deny a queued force-push or deleteOnly the repository’s owner, in GraniteNo

A repository with no recorded owner refuses every force-push and delete outright.