Skip to content

Commit 32d205b

Browse files
committed
settings: add allow unsafe remotes option
Add a new setting that allows users to express an explicit consent to using unsafe remote URLs (such as those using HTTP rather than HTTPS).
1 parent b164e4a commit 32d205b

File tree

6 files changed

+83
-1
lines changed

6 files changed

+83
-1
lines changed

docs/configuration.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,24 @@ Defaults to false (use hardware acceleration where available).
255255

256256
---
257257

258+
### credential.allowUnsafeRemotes
259+
260+
Allow transmitting credentials to unsafe remote URLs such as unencrypted HTTP
261+
URLs. This setting is not recommended for general use and should only be used
262+
when necessary.
263+
264+
Defaults false (disallow unsafe remote URLs).
265+
266+
#### Example
267+
268+
```shell
269+
git config --global credential.allowUnsafeRemotes true
270+
```
271+
272+
**Also see: [GCM_ALLOW_UNSAFE_REMOTES][gcm-allow-unsafe-remotes]**
273+
274+
---
275+
258276
### credential.autoDetectTimeout
259277

260278
Set the maximum length of time, in milliseconds, that GCM should wait for a
@@ -1024,6 +1042,7 @@ Defaults to disabled.
10241042
[envars]: environment.md
10251043
[freedesktop-ss]: https://specifications.freedesktop.org/secret-service/
10261044
[gcm-allow-windowsauth]: environment.md#GCM_ALLOW_WINDOWSAUTH
1045+
[gcm-allow-unsafe-remotes]: environment.md#GCM_ALLOW_UNSAFE_REMOTES
10271046
[gcm-authority]: environment.md#GCM_AUTHORITY-deprecated
10281047
[gcm-autodetect-timeout]: environment.md#GCM_AUTODETECT_TIMEOUT
10291048
[gcm-azrepos-credentialtype]: environment.md#GCM_AZREPOS_CREDENTIALTYPE

docs/environment.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,32 @@ Defaults to false (use hardware acceleration where available).
302302

303303
---
304304

305+
### GCM_ALLOW_UNSAFE_REMOTES
306+
307+
Allow transmitting credentials to unsafe remote URLs such as unencrypted HTTP
308+
URLs. This setting is not recommended for general use and should only be used
309+
when necessary.
310+
311+
Defaults false (disallow unsafe remote URLs).
312+
313+
#### Example
314+
315+
##### Windows
316+
317+
```batch
318+
SET GCM_ALLOW_UNSAFE_REMOTES=true
319+
```
320+
321+
##### macOS/Linux
322+
323+
```bash
324+
export GCM_ALLOW_UNSAFE_REMOTES=true
325+
```
326+
327+
**Also see: [credential.allowUnsafeRemotes][credential-allowunsaferemotes]**
328+
329+
---
330+
305331
### GCM_AUTODETECT_TIMEOUT
306332

307333
Set the maximum length of time, in milliseconds, that GCM should wait for a
@@ -1153,7 +1179,8 @@ Defaults to disabled.
11531179
[autodetect]: autodetect.md
11541180
[azure-access-tokens]: azrepos-users-and-tokens.md
11551181
[configuration]: configuration.md
1156-
[credential-allowwindowsauth]: environment.md#credentialallowWindowsAuth
1182+
[credential-allowwindowsauth]: configuration.md#credentialallowwindowsauth
1183+
[credential-allowunsaferemotes]: configuration.md#credentialallowunsaferemotes
11571184
[credential-authority]: configuration.md#credentialauthority-deprecated
11581185
[credential-autodetecttimeout]: configuration.md#credentialautodetecttimeout
11591186
[credential-azrepos-credential-type]: configuration.md#credentialazreposcredentialtype

docs/netconfig.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,22 @@ network traffic inspection tool such as [Telerik Fiddler][telerik-fiddler]. If
191191
you are using such tools please consult their documentation for trusting the
192192
proxy root certificates.
193193

194+
---
195+
196+
## Unsafe Remote URLs
197+
198+
If you are using a remote URL that is not considered safe, such as unencrypted
199+
HTTP (remote URLs that start with `http://`), host providers may prevent you
200+
from authenticating with your credentials.
201+
202+
In this case, you should consider using a HTTPS (starting with `https://`)
203+
remote URL to ensure your credentials are transmitted securely.
204+
205+
If you accept the risks associated with using an unsafe remote URL, you can
206+
configure GCM to allow the use of unsafe remote URLS by setting the environment
207+
variable [`GCM_ALLOW_UNSAFE_REMOTES`][unsafe-envar], or by using the Git
208+
configuration option [`credential.allowUnsafeRemotes`][unsafe-config] to `true`.
209+
194210
[environment]: environment.md
195211
[configuration]: configuration.md
196212
[git-http-proxy]: https://git-scm.com/docs/git-config#Documentation/git-config.txt-httpproxy
@@ -212,3 +228,5 @@ proxy root certificates.
212228
[git-ssl-no-verify]: https://git-scm.com/book/en/v2/Git-Internals-Environment-Variables#_networking
213229
[git-http-ssl-verify]: https://git-scm.com/docs/git-config#Documentation/git-config.txt-httpsslVerify
214230
[telerik-fiddler]: https://www.telerik.com/fiddler
231+
[unsafe-envar]: environment.md#gcm_allow_unsafe_remotes
232+
[unsafe-config]: configuration.md#credentialallowunsaferemotes

src/shared/Core/Constants.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ public static class EnvironmentVariables
119119
public const string OAuthDefaultUserName = "GCM_OAUTH_DEFAULT_USERNAME";
120120
public const string GcmDevUseLegacyUiHelpers = "GCM_DEV_USELEGACYUIHELPERS";
121121
public const string GcmGuiSoftwareRendering = "GCM_GUI_SOFTWARE_RENDERING";
122+
public const string GcmAllowUnsafeRemotes = "GCM_ALLOW_UNSAFE_REMOTES";
122123
}
123124

124125
public static class Http
@@ -163,6 +164,7 @@ public static class Credential
163164
public const string MsAuthUseDefaultAccount = "msauthUseDefaultAccount";
164165
public const string GuiSoftwareRendering = "guiSoftwareRendering";
165166
public const string GpgPassStorePath = "gpgPassStorePath";
167+
public const string AllowUnsafeRemotes = "allowUnsafeRemotes";
166168

167169
public const string OAuthAuthenticationModes = "oauthAuthModes";
168170
public const string OAuthClientId = "oauthClientId";
@@ -226,6 +228,7 @@ public static class HelpUrls
226228
public const string GcmAutoDetect = "https://aka.ms/gcm/autodetect";
227229
public const string GcmDefaultAccount = "https://aka.ms/gcm/defaultaccount";
228230
public const string GcmMultipleUsers = "https://aka.ms/gcm/multipleusers";
231+
public const string GcmUnsafeRemotes = "https://aka.ms/gcm/unsaferemotes";
229232
}
230233

231234
private static Version _gcmVersion;

src/shared/Core/Settings.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,11 @@ public interface ISettings : IDisposable
189189
/// </summary>
190190
bool UseSoftwareRendering { get; }
191191

192+
/// <summary>
193+
/// Permit the use of unsafe remotes URLs such as regular HTTP.
194+
/// </summary>
195+
bool AllowUnsafeRemotes { get; }
196+
192197
/// <summary>
193198
/// Get TRACE2 settings.
194199
/// </summary>
@@ -580,6 +585,12 @@ public bool UseSoftwareRendering
580585
}
581586
}
582587

588+
public bool AllowUnsafeRemotes =>
589+
TryGetSetting(KnownEnvars.GcmAllowUnsafeRemotes,
590+
KnownGitCfg.Credential.SectionName,
591+
KnownGitCfg.Credential.AllowUnsafeRemotes,
592+
out string str) && str.ToBooleanyOrDefault(false);
593+
583594
public Trace2Settings GetTrace2Settings()
584595
{
585596
var settings = new Trace2Settings();

src/shared/TestInfrastructure/Objects/TestSettings.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ public class TestSettings : ISettings
5353

5454
public bool UseMsAuthDefaultAccount { get; set; }
5555

56+
public bool AllowUnsafeRemotes { get; set; } = false;
57+
5658
public Trace2Settings GetTrace2Settings()
5759
{
5860
return new Trace2Settings()
@@ -189,6 +191,8 @@ ProxyConfiguration ISettings.GetProxyConfiguration()
189191

190192
bool ISettings.UseSoftwareRendering => false;
191193

194+
bool ISettings.AllowUnsafeRemotes => AllowUnsafeRemotes;
195+
192196
#endregion
193197

194198
#region IDisposable

0 commit comments

Comments
 (0)