Repository navigation
Authentication
Anchor LFS authenticates users by validating credentials against the GitHub API. Each endpoint can be independently configured with its own authentication method and visibility.
The github authentication method validates GitHub Personal Access Tokens (PATs) against the GitHub API, checking repository-level permissions.
[[endpoints]]
name = "My Repository"
url = "https://github.com/org/repo"
endpoint = "/org/repo"
visibility = "public"
authentication = "github"How it works:
- The Git LFS client sends a Personal Access Token as the Basic Auth password
- Anchor LFS asks the GitHub API for the token owner's role on the repository
- Download operations require pull permission, and on a private repository a token that can read its contents
- Upload and lock operations require push permission and a token that can write the repository's contents
GitHub reports the owner's role whatever the token itself allows, so the server also checks the token with a request that changes nothing: it lists one commit to check reading, and creates an empty blob, which GitHub always rejects, to check writing. A read-only token, a fine-grained token that does not include the repository, or a classic token without the scope below is refused with 403, as is any upload or lock on an archived repository.
Token requirements:
The PAT must have access to the repository configured in the endpoint's url field:
-
Classic token: the
reposcope, orpublic_repoto upload to public repositories only - Fine-grained token: the repository under Repository access, and Contents set to Read-only for downloads or Read and write for uploads and locks (GitHub adds the Metadata: Read-only permission the server needs)
The Basic Auth username is ignored. Locks belong to the token's GitHub login, whatever username the client sends.
The none method allows all operations without credentials. This is intended for local development and testing only: anyone who can reach the endpoint can download, upload, and create or release any lock. The server logs a warning at startup for every none endpoint.
none is only accepted with visibility = "public". A private endpoint with authentication = "none" would be open to everyone despite its label, so the server refuses to start with that combination.
[[endpoints]]
name = "Local Dev"
url = "https://github.com/dev/test-repo"
endpoint = "/dev/test-repo"
visibility = "public"
authentication = "none"When using none authentication, lock ownership uses the Basic Auth username if provided, or "anonymous" if not. Git LFS sends no credentials to an endpoint that never answers 401, so unless a client sets lfs.<url>.access to basic (see Endpoints Without Authentication), every lock is owned by anonymous and any client can release it. Because clients choose the username freely, lock ownership is not enforced either way.
Each endpoint has a visibility setting that controls access:
visibility = "public"- Downloads: Anonymous (no authentication required)
- Uploads: Require authentication with push permission
visibility = "private"- Downloads: Require authentication with pull permission
- Uploads: Require authentication with push permission
- Requires
authentication = "github"
Each request needs the GitHub repository permission below, from a token that may read (pull on a private repository) or write (push) the repository's contents. Signed transfer URLs (GET and PUT /objects/{oid}, POST /objects/verify) take no credentials, because the batch request that issued them was already checked.
| Request | Public endpoint | Private endpoint |
|---|---|---|
| Batch download | Anyone, no credentials | pull |
| Batch upload | push | push |
| List locks | Anyone, no credentials | pull |
| Create a lock, verify locks, release your own lock | push | push |
| Force the release of someone else's lock | maintain or admin | maintain or admin |
Anonymous lock listing on public endpoints matches GitHub's own LFS server, so lock-aware tools work for anyone who can clone. On a personal repository only the owner has admin, so only the owner can force the release of a collaborator's lock. With authentication = "none", every request is allowed, forced releases included.
To authenticate against a GitHub Enterprise instance, set the github_api_url field on the endpoint:
[[endpoints]]
name = "Enterprise Repo"
url = "https://github.example.com/org/repo"
endpoint = "/org/repo"
visibility = "private"
authentication = "github"
github_api_url = "https://github.example.com/api/v3/"Notes:
- A trailing slash on
github_api_urlis optional; the server adds one if it is missing - The repository URL must match the GitHub Enterprise hostname
- Non-
github.comrepository URLs requiregithub_api_urlto be set; the server will reject the configuration otherwise -
github_api_urlmust usehttps;httpis accepted only forlocalhostand loopback addresses - Every client token for the endpoint is sent to
github_api_url. Agithub.comrepository may use a host other thanapi.github.com, such as an API proxy, but the server logs a warning at startup - Endpoints targeting the same GitHub Enterprise instance share a single authenticator and cache for efficiency
To reduce load on the GitHub API, authentication results are cached in memory.
[options]
auth_cache_ttl = "60s"- Default TTL: 60 seconds
- A lookup makes two GitHub API calls: the repository, for the owner's role, and the user, for the login that owns locks. The first upload or lock request adds one call to check the token can write, and the first download from a private repository one to check it can read
- Cache entries are keyed by a hash of the token and the endpoint, and hold the download and upload permissions with the token checks, so one lookup serves every batch and lock request for that token and endpoint
- Concurrent requests with the same token for the same endpoint share one lookup and one token check
- A background goroutine periodically sweeps expired entries
- Denials are cached, including a token that GitHub reports cannot see the repository (
403or404) - Invalid tokens (
401) are cached for 10 seconds, orauth_cache_ttlif that is shorter, so a client retrying a bad token reaches GitHub at most once every 10 seconds - GitHub rate limits and transient failures (e.g., network errors or GitHub outages) are not cached
- Set to
"0s"to disable caching entirely
When caching is enabled, permission changes on GitHub may take up to auth_cache_ttl to take effect on the LFS server.
| GitHub API response | Anchor LFS response |
|---|---|
401 (bad or expired token) |
401 and the client asks for credentials again |
403 or 404 (token cannot see the repository, cannot read or write its contents, or is not authorised for the organisation's SAML SSO) |
404 "repository not found" for downloads, 403 "insufficient permissions" for uploads and locks |
Rate limit (403 with X-RateLimit-Remaining: 0, a secondary rate limit, or 429) |
429 with Retry-After (at most one hour); Git LFS waits and retries |
5xx or no response |
502 "authentication service unavailable" |
Git LFS uses Git's credential system. When the server requires authentication, Git prompts for credentials or uses a configured credential helper.
The simplest approach is to configure Git to use a Personal Access Token:
# Store credentials in Git's credential helper
git credential approve <<EOF
protocol=https
host=lfs.example.com
username=your-github-username
password=ghp_your_personal_access_token
EOFOr use a .netrc file:
machine lfs.example.com
login your-github-username
password ghp_your_personal_access_token
The server only reads the token; the username is there because credential helpers and .netrc store one.
See Git LFS Client Setup for more details on client configuration.
- Git LFS Client Setup: Configure Git clients
- Configuration: Full configuration reference
- Security: Rate limiting and security considerations