Skip to main content

Git Authentication

Stoker supports three authentication methods for private Git repositories. Public repositories need no auth configuration — just set spec.git.repo and spec.git.ref.

Token authentication

Use a personal access token (classic or fine-grained) for HTTPS repositories. This is the simplest method for GitHub, GitLab, and Bitbucket.

Create a secret containing the token:

kubectl create secret generic git-token -n <namespace> \
--from-literal=token=ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Reference it in the GatewaySync CR:

apiVersion: stoker.io/v1alpha1
kind: GatewaySync
metadata:
name: my-sync
namespace: my-namespace
spec:
git:
repo: "https://github.com/org/private-repo.git"
ref: "main"
auth:
token:
secretRef:
name: git-token
key: token
# ... gateway, sync config

When to use: Quick setup, CI-generated tokens, or when SSH is blocked by network policy.

Fine-grained tokens

GitHub fine-grained tokens let you scope access to a single repository with read-only permissions. This is the recommended approach for production.

Auth method comparison

MethodProtocolScopeRotationAgent credential
TokenHTTPSPer-tokenManualMounted Secret
SSH keySSHPer-repo (deploy key)ManualMounted Secret
GitHub AppHTTPSPer-installationAutomatic (1hr)Controller-managed Secret (PEM never mounted)

Next steps