Repository navigation
Add credentials support - #292
Conversation
Roughly based on the libgit2 online test setup.
There was a problem hiding this comment.
The comment indicates that the passphrase is optional, but it is a required parameter. It should default to ""
def initialize(username, publickey, privatekey, passphrase="")
However, this seems like too many ordered parameters to me. It is too easy to mix up the arguments ("did the publickey go first, or the privatekey?"). I would prefer hash style arguments, so the class can be initialized like so:
SshKey.new(
username: "git",
public_key: File.expand_path("~/.ssh/id_rsa.pub"),
private_key: File.expand_path("~/.ssh/id_rsa"),
passphrase: "passphrase"
)
The passphrase being optional, of course. The same would apply to Credentials::Plaintext, for consistency sake.
There was a problem hiding this comment.
Yes, I agree. A hash would be better suited for initializing the key.
There was a problem hiding this comment.
👍 That's an easy change.
|
This functionality would also need to be added to |
|
@dangerp Setting credentials on a Repository is wrong, as a repository can have multiple remotes that each can require different credentials. Instead, I'll add a way to set the credentials for a remote. |
|
@arthurschreiber good point, remotes are the correct place to add credentials. Since this is merged, will this be added to remotes in a separate pull request? I would like to help out here, but my c skills are nonexistent. |
|
@dangerp Yes, I'll ad the missing functionality in a separate pull request. I've been sick all of last week, so I've been a bit behind on this. |
This is a first rough draft for credentials support in Rugged.
It tries to expose a simple as well as flexible API.
For simple use-case (like scripting/automation, where the credentials are most likely known/fixed), it allows passing a
Rugged::Credentialsobject directly in the options hash toRugged::Repository#clone_at:For more complex use cases, like GUIs, it allows passing a proc instead. This proc can then handle the credential lookup:
This is not yet completely ready to be merged, I'm mainly looking for feedback on the API.