| title | Intercepting a push |
|---|---|
| description | How to intercept a push with GitProxy |
In this section, we will demonstrate the power 💪 of GitProxy and how it works with a barebones & out-of-the-box demonstration using default configuration. Before we start, there are a few prerequisites:
For demonstration purposes, we recommend forking GitProxy and then cloning the repository to your PC:
git clone https://github.com/<YOUR-GITHUB-USERNAME>/git-proxy.gitCreate a configuration file in a new folder (separate to your fresh clone) with the following JSON:
{
"authorisedList": [
{
"project": "<YOUR-GITHUB-USERNAME>",
"name": "git-proxy",
"url": "https://github.com/<YOUR-GITHUB-USERNAME>/git-proxy.git"
}
]
}Now that you've got the prerequisites in place, it's time to run GitProxy and load the configuration file from your new folder:
npx -- @finos/git-proxy --config ./new-folder/proxy.config.jsonTo confirm GitProxy is running successfully, you should see the following in your terminal:
Listening on 8000
Service Listening on 8080Navigate into your test-bed repository (where you cloned your GitProxy fork) on your PC:
cd ./git-proxyBy default the clone of your repository will communicate with GitHub. To change this, so that your local copy of the repository speaks with GitProxy, run:
git remote -v
git remote set-url origin http://localhost:8000/<YOUR-GITHUB-USERNAME>/git-proxy.git
git remote -vYou can also try HTTPS with git -c http.sslVerify=false remote set-url origin https://localhost:8443/<YOUR-GITHUB-USERNAME>/git-proxy.git.
When TLS is enabled, the UI and REST API are also served over HTTPS on port 8444 (configurable via GIT_PROXY_HTTPS_UI_PORT) in parallel to the plain HTTP port 8080.
:::note
SSH protocol is currently not supported, see #27.
To simulate HTTPS connectivity, you can use ngrok (or similar tools) to create an HTTP/HTTPS public ingress and use its host to replace http://localhost:8080 in the git remote set-url command mentioned above.
:::
Open up the README.md and make a change to the file.
git add README.md
git commit -m "chore: update README.md"git pushImmediately after a push, you should receive a message in your terminal:
remote:
remote: GitProxy has received your push ✅
remote:
remote: 🔗 Shareable Link
remote: http://localhost:8080/dashboard/push/000000__b12557
remote:The push is now held in a suspended state by GitProxy and requires approval before it can be pushed to the upstream repository on GitHub.
GitProxy will prompt the entry of your git credentials. These credentials are your GitHub username and a Personal Access Token. For the ability to push and pull code through GitProxy, you will only require the public_repo scope.
GitProxy will reprompt you for credentials each time you push. To automatically re-use your credentials, you can run:
git config --global credential.helper osxkeychain # MacOS
git config --global credential.helper manager # Windows
git config --global credential.helper store # Linux:::info
GitProxy does not use your Personal Access Token other than to authenticate with GitHub when pushing code. This is identical to the process of pushing code to a repository without GitProxy installed.
:::