Skip to content
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

examples: implement SSH authentication #5051

Merged
merged 6 commits into from
Apr 26, 2019

Conversation

pks-t
Copy link
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.

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
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
Member Author

pks-t commented Apr 26, 2019

Thanks for your review, @tiennou!

@pks-t
Copy link
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.

None yet

2 participants