Add support for configured URLs containing credentials per RFC1738#362
Add support for configured URLs containing credentials per RFC1738#362ewbankkit wants to merge 4 commits intogit-lfs:masterfrom ewbankkit:rfc1738-auth
Conversation
…RFC1738. Log a warning for such URLs as the credentials are in plaintext. This resolves #202.
lfs/config.go
Outdated
There was a problem hiding this comment.
Using a defer here seems odd. This isn't really cleaning up a resource. I wonder if we should just have a NewEndpoint() function that encapsulates this?
|
👍 for the idea. I'm a little concerned that a function on |
|
Yeah, I don't like writing directly to stderr from within what is effectively library code but there is some precedence (e.g. |
|
I think it makes sense for library code to return errors, and the |
|
Code-style counterproposal: func (c *Configuration) Endpoint() Endpoint {
e := c.endpoint()
if u, err := url.Parse(e.Url); err == nil && u.User != nil {
fmt.Fprintln(os.Stderr, "warning: configured LFS endpoint contains credentials")
}
return e
}
func (c *Configuration) endpoint() Endpoint {
if url, ok := c.GitConfig("lfs.url"); ok {
return Endpoint{Url: url}
}
if len(c.CurrentRemote) > 0 && c.CurrentRemote != defaultRemote {
if e := c.RemoteEndpoint(c.CurrentRemote); len(e.Url) > 0 {
return e
}
}
return c.RemoteEndpoint(defaultRemote)
} |
I looked into it and didn't see a best way to do that. The |
|
I came to the same conclusion. I think an stderr message here is fine. If someone can come up with a better idea, I have no problem slowly refactoring things to support it. I do want to change |
|
Incorporated suggested code style proposal. |
|
Hey @ewbankkit, I noticed some issues with this when I actually reviewed the code. The I fixed it in Thanks for diving in and attempting this! |
This PR adds support for URLs containing credentials per RFC1738 -
user:pass@host- to be configured in the usual places.Such URLs will trigger a warning.
Any credentials parsed from a configured URL will be saved via
git credential approve.