2

I think I made a mistake in configuring my local git, but I can't see anything anywhere. This is something that scares me a lot, as it allows anyone who uses this computer full access to all my personnal projects. I hope I just did something wrong, and can fix it safely. Here is what happened:

  • I log in into my personnal GitLab gitlab.somewhere.com via browser with my root account (meperso@dot.com). (v8.5.5)
  • I create a new project "bundle" and set it to private.
  • I'm at work (windows 7, logged in as me.pro), but decided to check the project permissions for clone and push.
  • Surprisingly, the cloning process (via https) completed, with the expected message saying something like "your git repository appears to be empty". I start being concerned, this shouldn't be possible, my project is private, and no account was allowed yet.
  • I decide to push it further. I create a file in my local directory, git add it, commit, and push to origin. Everything worked. It didn't even asked for my username/password. In the commit history, in GitLab web interface, the commit is authored by me.pro@local, the Windows 7 login who doesn't have any authorized project on my gitlab.

Additional information : I'm using another Gitlab, hosted in the local network, for the company projects. But I wasn't logged in today.

I need some of my personnal project to get pieces of code, but I don't want someone who will this computer (happens regularily) to be able to push to origin without having to authenticate.

Here is the result of git config --list I typed outside of any project.

PS C:\> git config --list
core.symlinks=false
core.autocrlf=true
core.fscache=true
color.diff=auto
color.status=auto
color.branch=auto
color.interactive=true
help.format=html
http.sslcainfo=C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt
diff.astextplain.textconv=astextplain
rebase.autosquash=true
credential.helper=manager
PS C:\>

As you can see, there is not even a global username configured.

EDIT 1
The Windows Credential Manager was indeed storing some credentials. I was able to remove them from the WCM by running rundll32.exe keymgr.dll, KRShowKeyMgr and removing the line concerning my personal Gitlab at gitlab.somewhere.com.
Authentication was required again, that solves part of the problem.

But GitLab stil accepted the push from me.pro@local, despite the fact that the project is private, has no members, and the owner is meperso@dot.com.
the problem is still there...

Bonus question : how to prevent WCM to store credentials for a specific project ?
Answer : How do I disable git's credential helper for a single repository?
TL;DR: in your project-folder/.git/config, put helper = (empty string) in the [credential] section (or create it). Requires git 2.9+.

EDIT 2
I have a theory for the commit-that-should-not-be :
In WCM, there were also my project owner account. The commit was authenticated with these credentials, but the name was my Windows user. I can't check that theory, I deleted the credentials from the manager before suspecting this.

Community
  • 1
  • 1
Stéphane
  • 500
  • 5
  • 22
  • About your edits: you appear to be assuming that there's a link between the committer and the pusher. There's not. If you have commits with the committer set to me.pro@local, and you have push access, you can push those commits. Pushers are basically trusted to only push commits that should be in the repository. –  Dec 27 '16 at 13:48

1 Answers1

2

You have credential.helper=manager set. This is Git credential manager for windows and I suspect the thing is managing your credentials. Remove all lines that starts with helper in [credential] block from your .gitconfig file located in the windows's currently logged in user folder.

Sergei Voitovich
  • 2,804
  • 3
  • 25
  • 33
  • Thank you ! I indeed got credentials stored within Windows Credential Manager for my personal Gitlab at gitlab.somwehere.com. That doesn't explain _why_ I was able to commit and push for an account that wasn't granted access to the project, but at least I removed access without authentication. – Stéphane Dec 27 '16 at 12:51
  • Btw, I don't have a c:\users\me.pro\.gitconfig file or even a .git directory. Did I misunderstand your instructions ? – Stéphane Dec 27 '16 at 12:59
  • I found a"gitconfig" file in C:\Program Files\Git\mingw64\etc\ containing the guilty line. But it would disable the helper for the whole computer, I can't do that. – Stéphane Dec 27 '16 at 13:29
  • @Stéphane try to execute `git credential-manager delete ` or `git credential-manager clear ` it should delete credentials only for single repository and continues to work with others repositories – Sergei Voitovich Dec 27 '16 at 13:32
  • I edited the first post with a way to disable the helper for specific projects (not windows user, which is fine for me). I tried to push something, authentication required. If I enter my local user me.pro, the message is "everything is up to date", but nothing is recorded in gitlab. Which is fine too. That still doesn't explain how the initial commit was allowed. I'm guessing here that among the credentials stored, there were my project owner account too, but the author in the commit was named after my windows user. – Stéphane Dec 27 '16 at 13:38
  • @Stéphane hm, that's interesting. `user.name` and `user.email` don't set according to your `git config --list` output. They are required to make a commit. If you weren't ask to set `user.name` and `user.email` by git I think credential manager handled this problem by setting these variables onto windows user login & email. – Sergei Voitovich Dec 27 '16 at 13:57