You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+81-10Lines changed: 81 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,29 +10,66 @@ Because this helper is designed to allow sharing credentials on the same machine
10
10
11
11
## Installation and Usage
12
12
13
-
This helper is written in Typescript and compiles down to two Javascript scripts, one for the server and one for the client.
13
+
This helper is written in TypeScript and can be installed globally via npm or pnpm.
14
14
15
-
### Download
15
+
### Installation Options
16
16
17
-
Download the latest release from this repo. The release consists of a filed named `git-credential-forwarder.zip` which contains two Javascript scripts: `gcf-server.js` and `gcf-client.js`. These can be placed wherever you want, but these instructions assume they are placed in the home directories of the host and container.
17
+
#### Global Installation (Recommended)
18
+
19
+
Install the package globally using npm or pnpm:
20
+
21
+
```
22
+
npm install -g git-credential-forwarder
23
+
# or
24
+
pnpm add -g git-credential-forwarder
25
+
```
26
+
27
+
This will make the commands `gcf-server` and `gcf-client` available globally.
28
+
29
+
#### Manual Download
30
+
31
+
Alternatively, you can download the latest release from this repo. The release consists of a file named `git-credential-forwarder.zip` which contains two JavaScript scripts: `gcf-server.js` and `gcf-client.js`. These can be placed wherever you want.
32
+
33
+
After downloading, make the scripts executable:
34
+
35
+
```
36
+
chmod +x gcf-server.js gcf-client.js
37
+
```
18
38
19
39
### On the host
20
40
21
-
Run `node ~/gcf-server.js`. This will launch the server and it will listen for TCP connections on localhost at a random port which will be displayed in the console. You will need to keep this console/terminal open.
41
+
If installed globally:
42
+
```
43
+
gcf-server
44
+
```
45
+
46
+
If using manual download:
47
+
```
48
+
./gcf-server.js
49
+
```
50
+
51
+
This will launch the server and it will listen for TCP connections on localhost at a random port which will be displayed in the console. You will need to keep this console/terminal open.
22
52
23
53
Notes:
24
54
25
55
- You can tell it to use a specific port by setting the environmental variable `GIT_CREDENTIAL_FORWARDER_PORT`
26
56
27
57
### In the container
28
58
29
-
Run `export GIT_CREDENTIAL_FORWARDER_SERVER="host.Docker.internal:PORT` where PORT is replaced with the port displayed when you ran the server.
59
+
Run `export GIT_CREDENTIAL_FORWARDER_SERVER="host.docker.internal:PORT"` where PORT is replaced with the port displayed when you ran the server.
60
+
61
+
Edit your git configuration file to call the client as a git credential helper:
30
62
31
-
Edit your git configuration file to call the client you just complied as a git credential helper, as follows:
63
+
If installed globally:
64
+
```
65
+
[credential]
66
+
helper = "!f() { gcf-client $*; }; f"
67
+
```
32
68
69
+
If using manual download:
33
70
```
34
71
[credential]
35
-
helper = "!f() { node ~/gcf-client.js $*; }; f"
72
+
helper = "!f() { /path/to/gcf-client.js $*; }; f"
36
73
```
37
74
38
75
Run git normally and all requests for credentials should be passed through to the host which will handle appropriately on the host side.
@@ -46,14 +83,33 @@ Notes:
46
83
47
84
Here's a strategy to make this fairly easy to use with a Docker container built with a Dockerfile.
48
85
86
+
#### Option 1: Using npm or pnpm (Recommended)
87
+
88
+
On the host, set a specific port that you will listen on by configuring the env variable `GIT_CREDENTIAL_FORWARDER_PORT`.
89
+
90
+
Add these lines in the Dockerfile:
91
+
92
+
```
93
+
# Install Node.js and npm/pnpm first if needed
94
+
RUN npm install -g git-credential-forwarder
95
+
# or
96
+
RUN pnpm add -g git-credential-forwarder
97
+
98
+
RUN git config --global credential.helper '!f(){ gcf-client $*; }; f'
@@ -77,6 +133,21 @@ Note that this will not work from a Mac OS host per [this Docker issue](https://
77
133
78
134
You can enable debugging on either the server or the client by setting the environmental variable `GIT_CREDENTIAL_FORWARDER_DEBUG` to `true`.
79
135
136
+
## Development
137
+
138
+
### Publishing to npm
139
+
140
+
This project uses GitHub Actions to automatically publish to npm when a new release is created. To set this up:
141
+
142
+
1. Generate an npm token with publish permissions
143
+
2. Add the token as a GitHub repository secret named `NPM_TOKEN`
144
+
3. Update the version in package.json
145
+
4. Commit the changes and push to GitHub
146
+
5. Create a new tag for the release: `git tag v1.x.x && git push --tags`
147
+
6. Create a new release on GitHub using the tag to trigger the publishing workflow
148
+
149
+
The GitHub Actions workflow will use pnpm to build, test, and publish the package to the npm registry.
150
+
80
151
## Security
81
152
82
153
Nothing is perfectly secure, but I have tried to think through the security implications of running a helper like this. Here are some thoughts and I would definitely welcome any others in the issues or discussions sections:
0 commit comments