A Git LFS backend which provides pluggable authentication and blob store adapters. It is designed to run in a serverless environment to be used in conjunction with a Git provider such as GitHub or BitBucket, or self hosted Git.
- Add the Git LFS services to your application:
services.AddLfs();
- Register an implementation for IBlobAdapter and IAuthenticator. S3 is provided out of the box:
services.AddSingleton<IBlobAdapter, S3BlobAdapter>();
services.AddSingleton<IAuthenticator>(x => new DictionaryAuthenticator(new Dictionary<string, string> { { "username", "password" } }));
// Required when using S3BlobAdapter
services.AddSingleton<IS3BlobAdapterConfig>(x => new S3BlobAdapterConfig { Bucket = "estranged-lfs-test" });
services.AddSingleton<IAmazonS3>(x => new AmazonS3Client());
To use another blob store or authentication provider, register your own implementations into the services container. See below for more details.
Any blob store which generates pre-signed URLs can be used by implementing the interface IBlobAdapter:
public interface IBlobAdapter
{
Task<SignedBlob> UriForUpload(string Oid, long size);
Task<SignedBlob> UriForDownload(string Oid);
}
An S3 implementation is included, which generates pre-signed GET and PUT requests. This can be used out of the box if desired.
Git LFS supports HTTP Basic authentication, the mechanics of which the library deals with but the authentication portion is exposed behind the IAuthenticator interface.
public interface IAuthenticator
{
bool Authenticate(string username, string password);
}
A sample implementation exposing a dictionary of username => password is included as a reference.
There are currently two hosting examples:
- Estranged.Lfs.Hosting.AspNet
- Estranged.Lfs.Hosting.Lambda
The former is a simple example using only Asp.NET components, and the latter is an Asp.NET Lambda function which can be deployed directly to AWS Lambda, behind API Gateway.