Skip to content

examples: implement SSH authentication#5051

Merged
pks-t merged 6 commits into
libgit2:masterfrom
pks-t:pks/examples-ssh-auth
Apr 26, 2019
Merged

examples: implement SSH authentication#5051
pks-t merged 6 commits into
libgit2:masterfrom
pks-t:pks/examples-ssh-auth

Conversation

@pks-t
Copy link
Copy Markdown
Member

@pks-t pks-t commented Apr 16, 2019

I've been asked how to implement SSH authentication with libgit2. I've thus decided to implement that support for our examples code, so that one may now clone SSH repos via the lg2 executable.

pks-t added 6 commits April 16, 2019 11:52
We currently have two locations in our examples where we define
the same compatibility wrappers for MSVC. Move them into
"common.h" to avoid duplication and make them available to other
examples.
Credential callback are being passed a bitset that indicates
which credential types are allowed in the current context. In our
examples code, we completely ignore that field and always return
username/password credentials, which doesn't necessarily make
sense e.g. when only SSH keys are allowed.

Refactor the code and only return username/password credentials
in the case where `USERPASS_PLAINTEXT` credentials are allowed.
Otherwise, return a positive error code to indicate that no
credentials could be acquired.
Implement plain username credential types. These type of
credentials might be asked for e.g. as some kind of
pre-authentication step, before the actual credentials are
passed.
Implement SSH key credentials. This allows users to use the SSH
transport with the lg2 example code.
Implement SSH key credentials. This allows users to use the SSH
transport with the lg2 example code.
The credentials callback may be passed a username in case where
the URL already includes the expected username. As we usually
cannot use a different username in such context, we should use
that one if provided and not ask the user for a diferent
username.
Copy link
Copy Markdown
Contributor

@tiennou tiennou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I'm frustrated that docurium eats that file, though…

@pks-t pks-t merged commit af95615 into libgit2:master Apr 26, 2019
@pks-t pks-t deleted the pks/examples-ssh-auth branch April 26, 2019 06:48
@pks-t
Copy link
Copy Markdown
Member Author

pks-t commented Apr 26, 2019

Thanks for your review, @tiennou!

@pks-t
Copy link
Copy Markdown
Member Author

pks-t commented Apr 26, 2019

I'm frustrated that docurium eats that file, though…

Do you know why that is? Is it just not getting processed at all or is there any magic construct inside that docurium fails to parse?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants