Skip to content

LFS prompting for credentials when connecting to public storage url #960

Closed

Description

@DarkShear

I am using git-lfs 1.1.0 and have my own git-lfs server which implements the batch api and conforms correctly to it (I think).

My git-lfs server is hosted on an EC2 server and supplies git-lfs with storage URLs which are pre-signed PUT and GET urls to an Amazon S3 bucket (with a different host to the git-lfs server). My problem is that for every PUT or GET git-lfs makes to the storage URL it prompts for credentials (username and password). I don't need it to prompt for credentials as no credentials are required with pre-signed S3 urls but I can't seem to find any way of getting git-lfs to not prompt. Additionally there is no way of caching credentials (to stop it prompting) for the storage host as entering any credentials causes an Authorization header to be sent to S3 which then causes the request to be rejected.

While trying to find a way around this I had a look at the source and it does seem like doStorageRequest() will always cause credentials to be prompted for when making a request to a storage url unless the lfs server api returns an Authorization header as part of the 'download' action (which I can't do as it breaks S3) or if there is a query parameter called 'token' which I can't add to the url as it will break Amazon's signature validation.

Would it be possible to allow the user to control this in some way, i.e.through a lfs.url.access config setting or something. Or do you have any other advice on how I can get around this issue?

It didn't seem to do this on older versions of git-lfs (pre-batch api).

Activity

  1. technoweenie commented on Jan 29, 2016

    @technoweenie
    Contributor

    Actually, I was thinking of tweaking the api to allow an authenticated property, which would solve your use case. Seems more explicit than requiring Authorization or the hacky token query param. Course, that won't help you right now.

    You absolutely can use token in S3 download urls though. When you're building the canonical request for signing, you can pass in custom query strings. AWS docs are here. It's common to parse custom S3 query strings from the logs for metrics.

  2. DarkShear commented on Jan 29, 2016

    @DarkShear
    Author

    I was using the aws-sdk to generate pre-signed URLs for me and it doesn't allow you to add custom query parameters. Creating your own canonical request and signature seemed like a pain but I had come to the same conclusion so bit the bullet, created my own pre-signed query and have managed to get it working with a custom 'token' parameter.

    It does seem to work now without prompting but adding the token parameter (which I didn't see mentioned anywhere in the docs - apologies if I have missed it) seemed fragile as I had no idea whether it was a permanent feature of git-lfs. Your suggested 'authenticated' property sounds like a fine solution to me.

  3. technoweenie commented on Feb 5, 2016

    @technoweenie
    Contributor

    Thanks for the suggestion. I've added it to the Git LFS v1.2 list: #844

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions