@@ -43,6 +43,18 @@ forge auth login # interactive: asks domain + token
4343forge auth login --domain github.com --token ghp_abc123
4444forge auth login --domain gitea.example.com --token abc123 --type gitea
4545forge auth login --domain gerrit.example.com --token user:http_password --type gerrit
46+ forge auth login --domain github.com --token-cmd 'rbw get github-token'
47+ ```
48+
49+ ` --token-cmd ` stores a shell command instead of a literal token; the command
50+ is run each time the token is needed (see [ token commands] ( #token-commands ) below).
51+
52+ When prompted for a token interactively, press ** Ctrl+E** as the first key
53+ to enter a command instead:
54+
55+ ```
56+ Token for github.com (Ctrl+E first for command):
57+ Command for token (e.g. rbw get github.com): rbw get github-token
4658```
4759
4860Check what's configured with ` forge auth status ` .
@@ -71,6 +83,38 @@ type = gerrit
7183token = user:http_password
7284```
7385
86+ ### Token commands
87+
88+ Instead of a literal ` token ` , use ` token-cmd ` to specify a shell command (not supported on Windows).
89+ The command is executed via ` sh -c ` each time forge needs the token and its
90+ stdout is used as the value. This lets you fetch secrets from a password manager
91+ instead of storing them in plain text:
92+
93+ ``` ini
94+ [github.com]
95+ token-cmd = rbw get github-token
96+
97+ [gitlab.com]
98+ token-cmd = pass show forge/gitlab
99+
100+ [myhostedgitlab.example.com]
101+ token-cmd = rbw get --raw myhostedgitlab | jq -r ' .fields | map(select(.name == "token"))[0].value'
102+ ```
103+
104+ The variable ` FORGE_DOMAIN ` is set to the domain name when the command runs,
105+ so a single command can serve multiple domains:
106+
107+ ``` ini
108+ [github.com]
109+ token-cmd = pass show forge/$FORGE_DOMAIN
110+
111+ [myhostedgitlab.example.com]
112+ token-cmd = pass show forge/$FORGE_DOMAIN
113+ ```
114+
115+ ` forge auth login ` sets this up interactively (Ctrl+E at the token prompt).
116+ ` forge auth status ` shows the command source instead of the resolved value.
117+
74118` .forge ` in the repo root is for per-project settings, committed to the repo, no tokens:
75119
76120``` ini
0 commit comments