git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
* How to Verify the Git Credentials supplied by the User
@ 2020-10-12 13:50 Deepak Patankar
  2020-10-12 17:46 ` Junio C Hamano
  0 siblings, 1 reply; 4+ messages in thread
From: Deepak Patankar @ 2020-10-12 13:50 UTC (permalink / raw)
  To: git

Hello!!

I am writing an application in which we will support git integration.
The user will provide us with his/her git credentials so that we can
push some files on his git. The git credentials which user will supply
can be

HTTP (Username and Password/ Kerberos)
SSH

Before saving the user credentials I want to validate that the
credentials entered is valid.

The user might be using GithHub/BitBucket/GitLab. I am trying to find
some git command which I can use to validate the credentials. Can you
please point me to some command/logic which I can try?

What I have tried?
I tried git ls-remote command, but it requires the repo name/url. In
one of our use case, the user won't specify the repository name
beforehand. Because of which I am not able to use this command.


Thanks
Deepak Patankar

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: How to Verify the Git Credentials supplied by the User
  2020-10-12 13:50 How to Verify the Git Credentials supplied by the User Deepak Patankar
@ 2020-10-12 17:46 ` Junio C Hamano
       [not found]   ` <CABmmNJOCJEpGwz3hxYsKO=xwx_rrVv5_QcZuS_=gUZH9bM0G2A@mail.gmail.com>
  0 siblings, 1 reply; 4+ messages in thread
From: Junio C Hamano @ 2020-10-12 17:46 UTC (permalink / raw)
  To: Deepak Patankar; +Cc: git

Deepak Patankar <patankardeepak04@gmail.com> writes:

> I am writing an application in which we will support git integration.
> The user will provide us with his/her git credentials so that we can
> push some files on his git. The git credentials which user will supply
> can be
>
> HTTP (Username and Password/ Kerberos)
> SSH
>
> Before saving the user credentials I want to validate that the
> credentials entered is valid.

It obviously depends on the remote side, but a relatively safe thing
to try is to run things like "ls-remote" or "push --dry-run" that
will not cause any actual damage against the remote, and see if your
authentication fail.

But you might be asking a XY question.  I would expect that any
reasonable application that manages authentication material for the
user and drives "git fetch" and "git push" would act as a credential
helper and uses the credential protocol to talk to Git, so it will
learn an authentication failure upon the first use, at which point
it has the chance to drop the authentication material it obtained
earlier and ask the user for the corrected one---there is no need
for the application to see if the authentication material is correct
before the user does anything else.


> The user might be using GithHub/BitBucket/GitLab. I am trying to find
> some git command which I can use to validate the credentials. Can you
> please point me to some command/logic which I can try?
>
> What I have tried?
> I tried git ls-remote command, but it requires the repo name/url. In
> one of our use case, the user won't specify the repository name
> beforehand. Because of which I am not able to use this command.

This assumes there always is a single authentication material
regardless of the URL, which is probably not a good security posture
to encourage the users to adopt.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: How to Verify the Git Credentials supplied by the User
       [not found]   ` <CABmmNJOCJEpGwz3hxYsKO=xwx_rrVv5_QcZuS_=gUZH9bM0G2A@mail.gmail.com>
@ 2020-10-13  5:24     ` Deepak Patankar
  2020-10-13  5:32       ` Junio C Hamano
  0 siblings, 1 reply; 4+ messages in thread
From: Deepak Patankar @ 2020-10-13  5:24 UTC (permalink / raw)
  To: Junio C Hamano, git

Hey Junio,

Thanks a lot for the help.

On Mon, 12 Oct 2020 at 23:16, Junio C Hamano <gitster@pobox.com> wrote:
>
> Deepak Patankar <patankardeepak04@gmail.com> writes:
>
> > I am writing an application in which we will support git integration.
> > The user will provide us with his/her git credentials so that we can
> > push some files on his git. The git credentials which user will supply
> > can be
> >
> > HTTP (Username and Password/ Kerberos)
> > SSH
> >
> > Before saving the user credentials I want to validate that the
> > credentials entered is valid.
>
> It obviously depends on the remote side, but a relatively safe thing
> to try is to run things like "ls-remote" or "push --dry-run" that
> will not cause any actual damage against the remote, and see if your
> authentication fail.
>
> But you might be asking a XY question.  I would expect that any
> reasonable application that manages authentication material for the
> user and drives "git fetch" and "git push" would act as a credential
> helper and uses the credential protocol to talk to Git, so it will
> learn an authentication failure upon the first use, at which point
> it has the chance to drop the authentication material it obtained
> earlier and ask the user for the corrected one---there is no need
> for the application to see if the authentication material is correct
> before the user does anything else.
>

My previous email was confusing. I will be doing the authentication
check the way you described above
i.e. it will be done only once and I won't do it again and again
before each operation.


I can use the "ls-remote", "push --dry-run" command you suggested, but
I have a use case which I don't know how to solve.
The above commands require a repository. In our application, the user
can give the following details

Git Details:
   Account URL:  https://github.com/OpenPrinting
   UserName: deepakpatankar
   password: ***********

In this case, we don't know the repo name. At this step, I just know
the account and the credentials of the user, later on
the user will provide me with the repo name to which he wants to sync his file.

Since I don't know the repository, I cannot do "git fetch" or "git
push --dry-run". Can I check this credentials with some
logic or git commands?


Thanks
Deepak Patankar

On Tue, 13 Oct 2020 at 10:25, Deepak Patankar
<patankardeepak04@gmail.com> wrote:
>
> Hey Junio,
>
> Thanks a lot for the help.
>
> On Mon, 12 Oct 2020 at 23:16, Junio C Hamano <gitster@pobox.com> wrote:
> >
> > Deepak Patankar <patankardeepak04@gmail.com> writes:
> >
> > > I am writing an application in which we will support git integration.
> > > The user will provide us with his/her git credentials so that we can
> > > push some files on his git. The git credentials which user will supply
> > > can be
> > >
> > > HTTP (Username and Password/ Kerberos)
> > > SSH
> > >
> > > Before saving the user credentials I want to validate that the
> > > credentials entered is valid.
> >
> > It obviously depends on the remote side, but a relatively safe thing
> > to try is to run things like "ls-remote" or "push --dry-run" that
> > will not cause any actual damage against the remote, and see if your
> > authentication fail.
> >
> > But you might be asking a XY question.  I would expect that any
> > reasonable application that manages authentication material for the
> > user and drives "git fetch" and "git push" would act as a credential
> > helper and uses the credential protocol to talk to Git, so it will
> > learn an authentication failure upon the first use, at which point
> > it has the chance to drop the authentication material it obtained
> > earlier and ask the user for the corrected one---there is no need
> > for the application to see if the authentication material is correct
> > before the user does anything else.
> >
>
> My previous email was confusing. I will be doing the authentication
> check the way you described above
> i.e. it will be done only once and I won't do it again and again
> before each operation.
>
>
> I can use the "ls-remote", "push --dry-run" command you suggested, but
> I have a use case which I don't know how to solve.
> The above commands require a repository. In our application, the user
> can give the following details
>
> Git Details:
>    Account URL:  https://github.com/OpenPrinting
>    UserName: deepakpatankar
>    password: ***********
>
> In this case, we don't know the repo name. At this step, I just know
> the account and the credentials of the user, later on
> the user will provide me with the repo name to which he wants to sync his file.
>
> Since I don't know the repository, I cannot do "git fetch" or "git
> push --dry-run". Can I check this credentials with some
> logic or git commands?
>
>
> Thanks
> Deepak Patankar
>
>
>
> >
> > > The user might be using GithHub/BitBucket/GitLab. I am trying to find
> > > some git command which I can use to validate the credentials. Can you
> > > please point me to some command/logic which I can try?
> > >
> > > What I have tried?
> > > I tried git ls-remote command, but it requires the repo name/url. In
> > > one of our use case, the user won't specify the repository name
> > > beforehand. Because of which I am not able to use this command.
> >
> > This assumes there always is a single authentication material
> > regardless of the URL, which is probably not a good security posture
> > to encourage the users to adopt.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: How to Verify the Git Credentials supplied by the User
  2020-10-13  5:24     ` Deepak Patankar
@ 2020-10-13  5:32       ` Junio C Hamano
  0 siblings, 0 replies; 4+ messages in thread
From: Junio C Hamano @ 2020-10-13  5:32 UTC (permalink / raw)
  To: Deepak Patankar; +Cc: git

Deepak Patankar <patankardeepak04@gmail.com> writes:

> I can use the "ls-remote", "push --dry-run" command you suggested, but
> I have a use case which I don't know how to solve.
> The above commands require a repository. In our application, the user
> can give the following details
>
> Git Details:
>    Account URL:  https://github.com/OpenPrinting
>    UserName: deepakpatankar
>    password: ***********
>
> In this case, we don't know the repo name. At this step, I just know
> the account and the credentials of the user, later on
> the user will provide me with the repo name to which he wants to sync his file.
>
> Since I don't know the repository, I cannot do "git fetch" or "git
> push --dry-run". Can I check this credentials with some
> logic or git commands?

You'd have to go outside Git, as our transport layer is only about
talking with existing repositories.  You cannot even create a new 
repository using Git native methods.

You may need to find a method that works with GitHub account (note
that I am not even using the word repository here, instead saying
"account") and such a method would likely have to involve GitHub
specific API, but it probably would not work with other hosting
providers.

I also would imagine that even at GitHub, one may want to use
different authentication info depending on which repository one
accesses, so the "there is a single User with a password at this
hosting site" data model might turn out to be insufficient, but
that is outside the scope of Git proper.



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-10-13  5:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-12 13:50 How to Verify the Git Credentials supplied by the User Deepak Patankar
2020-10-12 17:46 ` Junio C Hamano
     [not found]   ` <CABmmNJOCJEpGwz3hxYsKO=xwx_rrVv5_QcZuS_=gUZH9bM0G2A@mail.gmail.com>
2020-10-13  5:24     ` Deepak Patankar
2020-10-13  5:32       ` Junio C Hamano

git@vger.kernel.org list mirror (unofficial, one of many)

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://public-inbox.org/git
	git clone --mirror http://ou63pmih66umazou.onion/git
	git clone --mirror http://czquwvybam4bgbro.onion/git
	git clone --mirror http://hjrcffqmbrq6wope.onion/git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 git git/ https://public-inbox.org/git \
		git@vger.kernel.org
	public-inbox-index git

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.version-control.git
	nntp://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/inbox.comp.version-control.git
	nntp://ie5yzdi7fg72h7s4sdcztq5evakq23rdt33mfyfcddc5u3ndnw24ogqd.onion/inbox.comp.version-control.git
	nntp://4uok3hntl7oi7b4uf4rtfwefqeexfzil2w6kgk2jn5z2f764irre7byd.onion/inbox.comp.version-control.git
	nntp://news.gmane.io/gmane.comp.version-control.git
 note: .onion URLs require Tor: https://www.torproject.org/

code repositories for project(s) associated with this inbox:

	https://80x24.org/mirrors/git.git

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git