{"thread":{"id":"34816","subject":"Authentication with e-mail address as user name for HTTPS remote","startedAt":"2013-08-31T06:52:06Z","lastAt":"2013-08-31T08:09:46Z","messageCount":2,"participants":["Patrick Atoon","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"226405","messageId":"CADZGgi9-nLpcaHQOevBnY9HZtkLD6Zn=gCZq8u5yefPV7gYaTg@mail.gmail.com","threadId":"34816","inReplyTo":null,"subject":"Authentication with e-mail address as user name for HTTPS remote","fromName":"Patrick Atoon","fromEmail":"patrick.atoon@gmail.com","sentAt":"2013-08-31T06:52:06Z","receivedAt":"2013-08-31T06:52:06Z","isPatch":false,"sender":{"key":"patrick.atoon@gmail.com","avatar":null},"body":"Hello,\n\nI run into a problem with command line git on Linux.\n\nThe remote git server I try to clone from uses HTTPS as a protocol and\nrequires full\nfledged e-mail addresses for a user name in its authentication. In\nTortoiseGit (with\nwinstore) or SourceTree, the user name and password are asked and\nstored. But on the\ncommand line I'm stuck, unable to provide the user name.\n\nHere is what happens. First try cloning without specifying the user name:\n\n---8<-------------------------------------------------------\n$ git clone https://git.server.com/git/test.git\nInitialized empty Git repository in /tmp/git/test/.git/\nerror: The requested URL returned error: 401 Authorization Required\nwhile accessing\nhttps://git.server.com/git/test.git/nfo/refs\n\nfatal: HTTP request failed\n---8<-------------------------------------------------------\n\nI couldn't find a \"--username\" flag or something similar for the git\ncommand, so my next\ntry was to incorporate the user name in the URL, basic auth style. The\nrepo URL looks\nsomething like this:\n\nhttps://user.email@emaildomain.com@git.server.com/git/test.git\n\nNote the double \"@\" there, it is bound to cause trouble.\nThis is what happened:\n\n---8<-------------------------------------------------------\n$ git clone https://user.email@emaildomain.com@git.server.com/git/test.git\nInitialized empty Git repository in /tmp/git/test/.git/\nPassword:\nerror: Couldn't resolve host 'emaildomain.com@git.server.com' while accessing\nhttps://user.email@emaildomain.com@git.server.com/git/test.git/info/refs\n\nfatal: HTTP request failed\n---8<-------------------------------------------------------\n\nIt appears the \"@\" was picked up as an indication that the URL\ncontains the username,\nhowever the URL was split at the wrong position. The splitting\nalgorithm doesn't seem to\ntake into account that a user name might contain an \"@\".\n\nMy request: please modify command line git to support full fledged\ne-mail addresses as\nuser names in HTTPS requests.\n\nI'm not a C adept, still I browsed the code a bit and bumped into\n\"transport.c\"'s\n\"transport_anonymize_url\" method. I think that code could be modified\nto do a better job\nof splitting the URL, which might then avoid problems down the line.\n\nThanks for reading this far.\n\nRegards,\n\nPatrick\n"},{"id":"226409","messageId":"20130831080946.GB21744@sigill.intra.peff.net","threadId":"34816","inReplyTo":"CADZGgi9-nLpcaHQOevBnY9HZtkLD6Zn=gCZq8u5yefPV7gYaTg@mail.gmail.com","subject":"Re: Authentication with e-mail address as user name for HTTPS remote","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2013-08-31T08:09:46Z","receivedAt":"2013-08-31T08:09:46Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sat, Aug 31, 2013 at 08:52:06AM +0200, Patrick Atoon wrote:\n\n> Here is what happens. First try cloning without specifying the user name:\n> \n> ---8<-------------------------------------------------------\n> $ git clone https://git.server.com/git/test.git\n> Initialized empty Git repository in /tmp/git/test/.git/\n> error: The requested URL returned error: 401 Authorization Required\n> while accessing\n> https://git.server.com/git/test.git/nfo/refs\n> \n> fatal: HTTP request failed\n\nThat should be prompting you. What version of git are you using?\n\n> I couldn't find a \"--username\" flag or something similar for the git\n> command, so my next try was to incorporate the user name in the URL,\n> basic auth style.\n\nYes, that's the correct way to do it from the command line.\n\nIf you are running v1.7.9 and later, you can also put this in your\nconfig:\n\n  [credential \"https://git.server.com\"]\n    username = user.email@emaildomain.com\n\nto automatically use that username for the particular domain.\n\n> https://user.email@emaildomain.com@git.server.com/git/test.git\n> \n> Note the double \"@\" there, it is bound to cause trouble.\n\nYes. You probably want to escape it like:\n\n  https://user.email%40emaildomain.com@git.server.com/git/test.git\n\nIn theory we could parse from the right-hand side of the hostname and\nrealize that only the right-most \"@\" is the username separator (under\nthe assumption that hostnames can never contain an \"@\"). I don't know if\nthat would violate the standard or not. However, it is not even git that\ndoes the actual parsing in this case, but rather libcurl.\n\n-Peff\n"}]}