0

I want to try to get information of local git that pushed to my git server, so I can use username as an user in my authorization and then user just need to put their password. How can I solve this problem because I can't get that information. I used library to make it, maybe someone could help me and I would appreciate any help from you

This is how I get git request to the server

public ActionResult Smart(string username, string project, string service, string verb)
    {
        switch (verb)
        {
            case "info/refs":
                return InfoRefs(username, project, service);
            case "git-upload-pack":
                return ExecutePack(username, project, "git-upload-pack");
            case "git-receive-pack":
                return ExecutePack(username, project, "git-receive-pack");
            default:
                return RedirectToAction("Tree", "Repository", new { Name = project });
        }
    }
gturri
  • 13,807
  • 9
  • 40
  • 57
aji
  • 651
  • 1
  • 5
  • 10

1 Answers1

1

There is no such thing as a git username. There are the signatures for the author and committer for each commit and then there's whatever you made the user authenticate with.

The only way you're going to be able to know who initiated the push is to ask the authentication layer that you put in front of the git protocol. If you use HTTP to serve the repository, that information would be in the HTTP library, if you use SSH, in the SSH library.

Carlos Martín Nieto
  • 5,207
  • 1
  • 15
  • 16
  • sorry, i mean signatures of the committer. can you give me an example how to get it from HTTP library because i want to make user just input a password but the username is come from their own local git config, i mean from their global config username of email – aji May 24 '14 at 12:21
  • Those are two separate concerns. If you want the username they used to authenticate, you use the HTTP library. If you want to take a look at the committer, you need to wait until you have the data and checked that it's a valid git pack. Then you can look at the data. Git won't look at the user/email information for network tasks at all. – Carlos Martín Nieto May 24 '14 at 12:56
  • So, you mean i can't get user/email of local git from user to put it as a username in my http response for authenticate the user before they pushed it into the git server ? – aji May 24 '14 at 13:06
  • After i tried to understand it, i think it just can working if i set username from my own url such as http://user@url.com/user/project.git – aji May 24 '14 at 13:25
  • That is one way, or you can set your ssh config to do that for a particular host – Carlos Martín Nieto May 24 '14 at 15:03