Using the git credential helper to authenticate using group tokens

Viewed 89

I'm in a situation where I'm running a GitLab CI pipeline where I need to feed multiple credentials into the credential helper, but they need to be scoped to specific groups within GitLab (I have group tokens for each group, and am pulling multiple repos from each group). I have to use the credential helper because this will ultimately be used in Unity, so the below code is just how I'm testing the credentials. I know there are easier ways to authenticate with the tokens to clone a repo, but those won't work in this case.

In the pipeline (being executed in PowerShell), I'm running the following commands

git config --global credential.helper wincred
git config --global credential.https://git.place.com/group-a/*.usehttppath true
git config --global credential.https://git.place.com/group-b/*.usehttppath true

echo "protocol=https`nhost=git.place.com`npath=group-a/`nusername=test`npassword=token-a" | git credential-wincred store
echo "protocol=https`nhost=git.place.com`npath=group-b/`nusername=test`npassword=token-b" | git credential-wincred store

I then test to see if the credentials are there by using

echo "url=https://git.place.com/group-a/project-a" | git credential fill

but it just hangs because it hasn't found any credentials matching the query and is waiting on my input.

Is there a way to do what I need, store group tokens for two different groups and use them to authenticate a couple different repos from each group?

0 Answers
Related