-
Notifications
You must be signed in to change notification settings - Fork 2.2k
refactor git-credentials handling for http requests #611
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
lfs/client.go
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WTF is a fun trace message :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Surely it means "Waiting To Fetch"!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gah, 2nd debug message that I left in here.
force pushes
These are not the commits you are looking for.
47a90fc to
ed376b4
Compare
|
I think we can fix #612 in this PR:
I believe that check was added so that the LFS client doesn't apply credentials from your LFS server at |
|
Sounds good to me 👍 |
|
While personally I would always get the API server to generate sufficient authentication tokens to pass to the storage server, I think dropping support for storage credentials entirely might be a step too far. How about supporting 401 responses from the storage server and fetching credentials only then, just like the API calls? Even though the storage server might not be hosted in the same place as the git server, git-credentials is still a pretty solid way to cache authentication data, and it would be nice to retain the ability to use basic auth on storage calls, for systems that don't support tokens. |
lfs/client.go
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could probably push this value onto creds itself, since we return anyway if there's an non-nil value in err.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand, push what into creds. The error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops, I see what you were doing here, ignore my suggestion.
|
@sinbad: While I think forcing users to maintain two sets of authentication is a poor user experience, I agree that having |
this puts the more important methods towards the top. It also stops exporting internal credential functions
|
I've updated this PR based on some feedback:
I've refactored the credential and client methods a bit. All credential related functions are in
One potential problem. Storage requests may add a lot of entries to the git credential helper if
There are now two functions for filling an HTTP request with an Authorization header:
It now ignores any exit code related errors from |
More cred tests
|
This is looking good in my QA tests 🤘 |
only check git-credentials for lfs api requests
This changes Git LFS so it only checks
git-credentialfor LFS API requests. The Git LFS API is intended to be mounted next to the Git server. So it makes sense to use git credentials, since it can take advantage of existing credentials for Git users that use HTTPS remotes.However, the client shouldn't have to check git credentials for the "storage api" requests. These are the requests to download or upload raw objects from URLs linked from the LFS API response. The Storage API may not require any authorization for public objects in public repositories. Basically, the Git LFS client should trust the LFS server to return enough meta data to authenticate the requests.
doApiRequestWithRedirects()is the low level function that handles API communications. It now fetches the credentials if needed, and saves the credentials on success.doApiBatchRequest()now tellsdoApiRequestWithRedirects()if credentials are needed/cc @rubyist @sinbad