info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/product/ux/technical-writing/#assignments
The methods for authentication defined here are inherited by all the other LFS controllers.
### Repositories::LfsApiController
#### `#batch`
After authentication the `batch` action is the first action called by the Git LFS
client during downloads and uploads (such as pull, push, and clone).
### Repositories::LfsStorageController
#### `#upload_authorize`
Provides payload to Workhorse including a path for Workhorse to save the file to. Could be remote object storage.
#### `#upload_finalize`
Handles requests from Workhorse that contain information on a file that workhorse already uploaded (see [this middleware](https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/middleware/multipart.rb)) so that `gitlab` can either:
- Create an `LfsObject`.
- Connect an existing `LfsObject` to a project with an `LfsObjectsProject`.
### LfsObject and LfsObjectsProject
- Only one `LfsObject` is created for a file with a given `oid` (a SHA256 checksum of the file) and file size.
-`LfsObjectsProject` associate `LfsObject`s with `Project`s. They determine if a file can be accessed through a project.
- These objects are also used for calculating the amount of LFS storage a given project is using.
Handles the lock API for LFS. Delegates mostly to corresponding services:
-`Lfs::LockFileService`
-`Lfs::UnlockFileService`
-`Lfs::LocksFinderService`
These services create and delete `LfsFileLock`.
#### `#verify`
- This endpoint responds with a payload that allows a client to check if there are any files being pushed that have locks that belong to another user.
- A client-side `lfs.locksverify` configuration can be set so that the client aborts the push if locks exist that belong to another user.
- The existence of locks belonging to other users is also [validated on the server side](https://gitlab.com/gitlab-org/gitlab/-/blob/65f0c6e59121b62c9b0f89b810ef5186969bb4d2/lib/gitlab/checks/diff_check.rb#L69).
gitlab-shell->>GitLab Rails: POST /api/v4/internal/lfs_authenticate
GitLab Rails-->>gitlab-shell: token with expiry
deactivate gitlab-shell
deactivate GitLab Rails
end
```
1. Clients can be configured to store credentials in a few different ways.
See the [Git LFS documentation on authentication](https://github.com/git-lfs/git-lfs/blob/bea0287cdd3acbc0aa9cdf67ae09b6843d3ffcf0/docs/api/authentication.md#git-credentials).
1. Running `gitlab-lfs-authenticate` on `gitlab-shell`. See the [Git LFS documentation concerning `gitlab-lfs-authenticate`](https://github.com/git-lfs/git-lfs/blob/bea0287cdd3acbc0aa9cdf67ae09b6843d3ffcf0/docs/api/server-discovery.md#ssh).
1.`gitlab-shell`makes a request to the GitLab API.
1. [Responding to shell with token](https://gitlab.com/gitlab-org/gitlab/-/blob/7a2f7a31a88b6085ea89b8ba188a4d92d5fada91/lib/api/internal/base.rb#L168) which is used in subsequent requests. See [Git LFS documentation concerning authentication](https://github.com/git-lfs/git-lfs/blob/bea0287cdd3acbc0aa9cdf67ae09b6843d3ffcf0/docs/api/authentication.md).
## Example clone
```mermaid
sequenceDiagram
Note right of Git client: Typical Git clone things happen first
Note right of Git client: Authentication for LFS comes next
activate GitLab Rails
autonumber
Git client->>GitLab Rails: POST project/namespace/info/lfs/objects/batch
GitLab Rails-->>Git client: payload with objects
deactivate GitLab Rails
loop each object in payload
Git client->>GitLab Rails: GET project/namespace/gitlab-lfs/objects/:oid/ (<-ThisURLisfromthepayload)
GitLab Rails->>Workhorse: SendfileUpload
Workhorse-->> Git client: Binary data
end
```
1. Git LFS requests the ability to download files with authorization header from authorization.
1.`gitlab` responds with the list of objects and where to find them. See
1. Git LFS makes a request for each file for the `href` in the previous response. See
[how downloads are handled with the basic transfer mode](https://github.com/git-lfs/git-lfs/blob/bea0287cdd3acbc0aa9cdf67ae09b6843d3ffcf0/docs/api/basic-transfers.md#downloads).
1.`gitlab` redirects to the remote URL if remote object storage is enabled. See
1. Git LFS makes a request for each file for the `href` in the previous response. See
[how uploads are handled with the basic transfer mode](https://github.com/git-lfs/git-lfs/blob/bea0287cdd3acbc0aa9cdf67ae09b6843d3ffcf0/docs/api/basic-transfers.md#uploads).
1.`gitlab` responds with a payload including a path for Workhorse to save the file to.