Identity and authentication
This page explains how people and machines sign in to Golf in each deployment, and which credential each kind of request uses. Read it before you enroll users or add OAuth or machine credentials.
| Deployment | People sign in with | Machines use |
|---|---|---|
| Native Cloudflare | Cloudflare Access, mapped to an enrolled account | Access Service Auth plus a scoped Golf credential |
| Portable | A local Golf username/password, or optional Forgejo OAuth | Scoped provider or Golf tokens |
Signing in never creates a Golf account or a repository permission. Do not infer account linking from matching email addresses.
Native Cloudflare Access
The hosted default uses Cloudflare Access. The control and preview hostnames have separate applications/audiences; approved human identities and machine Service Auth have different policies. Public mode can expose selected anonymous source while sign-in remains protected.
Golf accepts runtime-verified Access identity and maps it to an already enrolled, active D1 account. Caller-supplied identity headers do not grant access. Access never auto-enrolls an account or creates repository grants. A platform/account role does not override current repository authority.
Machine Git and Golf CLI requests require their independently configured Access transport plus a scoped Golf credential. The native CLI reads these environment variables:
| Variable | Purpose |
|---|---|
GOLF_NATIVE_TOKEN | Scoped Golf credential |
GOLF_ACCESS_CLIENT_ID and GOLF_ACCESS_CLIENT_SECRET | Access Service Auth pair; incomplete pairs and redirects are refused |
Keep credentials out of URLs and command arguments.
Local Golf username/password
The operator explicitly maps an existing Forgejo user and scoped token to a Golf account. The Golf password is separate, at least 15 characters, and stored as a salted Argon2id verifier. Native credentials stay encrypted server-side; the browser receives an opaque HttpOnly cookie.
Registration is disabled. Follow installation and the local account contract. Ordinary account administration, session revocation and password-confirmed account changes have explicit current-authority checks.
Browser OAuth
Optional Forgejo OAuth uses a confidential application registered in Forgejo Settings → Applications with exact callback http://localhost:8080/auth/forgejo/callback in local development (use your Golf HTTPS origin remotely). Set all three of GOLF_FORGE_PUBLIC_URL (for example http://localhost:3001), GOLF_FORGE_OAUTH_CLIENT_ID and GOLF_FORGE_OAUTH_CLIENT_SECRET in the ignored .env, then run docker compose up -d from the checkout to recreate the affected containers; docker compose start does not apply changed settings. On Kubernetes, set oauth.enabled: true and put the client ID and secret in the existing Secret. Authorization uses single-use state/browser binding and S256 PKCE.
Read-only PAT bootstrap needs read:user and read:repository, plus underlying permissions. The CLI uses GOLF_FORGE_TOKEN or --token-stdin. Owner-issued GOLF_API_TOKEN is a separately scoped product credential, not a direct Git password.
Manage Golf sessions
Portable sessions have an absolute twelve-hour lifetime and survive service restarts. Secure remote origins require HTTPS and a host-only secure cookie. Source-session termination invalidates its delegated credentials. Provider PATs, OAuth consent and Git keys retain separate lifecycles.
Optional MFA and recovery slices have their own setup/evidence. Hosted customer IdPs, onboarding and Access seat economics remain production qualification. Never infer account linking from matching email addresses.