-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
registry: speed up auto-detect and make more robust
Speed up the auto-detection mechanism in the HostProviderRegistry by setting a short(er) timeout on the probing network call (2 seconds). The default value from the framework is otherwise 100 seconds(!). We introduce a setting for the user to be able to configure this timeout value with the granularity of 1 millisecond. Another problem that occured with this network call was crashes due to TLS configuration issues. The network call was not wrapped in a try-catch block which meant that the entire process would crash if there was a problem. This isn't ideal for what is supposed to be a "best effort" feature. Here we wrap the HEAD call in a try-catch and display an appropriate warning message to the user. For completeness, add documentation that explains the auto-detection feature, how to configure the timeout, and how to disable this network call.
- Loading branch information
1 parent
05c63b0
commit 18aa081
Showing
8 changed files
with
335 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# Host provider auto-detection | ||
|
||
Git Credential Manager (GCM) supports authentication with multiple different Git | ||
host providers including: GitHub, Bitbucket, and Azure Repos. As well as the | ||
hosted/cloud offerings, GCM can also work with the self-hosted or "on-premises" | ||
versions of these services: GitHub Enterprise Server, Bitbucket DC Server, and | ||
Azure DevOps Server (TFS). | ||
|
||
By default, GCM will attempt to automatically detect which particular provider | ||
is behind the Git remote URL you're interacting with. For the cloud versions of | ||
the supported providers this is done by matching the hostname of the remote URL | ||
to the well-known hostnames of the services. For example "github.com" or | ||
"dev.azure.com". | ||
|
||
## Self-hosted/on-prem detection | ||
|
||
In order to detect which host provider to use for a self-hosted instance, each | ||
provider can provide some heuristic matching of the hostname. For example any | ||
hostname that begins "github.*" will be matched to the GitHub host provider. | ||
|
||
If a heuristic matches incorrectly, you can always [explicitly configure](#explicit-configuration) | ||
GCM to use a particular provider. | ||
|
||
## Remote URL probing | ||
|
||
In addition to heuristic matching, GCM will make a network call to the remote | ||
URL and inspect HTTP response headers to try and detect a self-hosted instance. | ||
|
||
This network call is only performed if neither an exact nor fuzzy match by | ||
hostname can be made. Only one HTTP `HEAD` call is made per credential request | ||
recieved by Git. To avoid this network call, please [explicit configure](#explicit-configuration) | ||
the host provider for your self-hosted instance. | ||
|
||
### Timeout | ||
|
||
You can control how long GCM will wait for a response to the remote network call | ||
by setting the [`GCM_AUTODETECT_TIMEOUT`](environment.md#GCM_AUTODETECT_TIMEOUT) | ||
environment variable, or the [`credential.autoDetectTimeout`](configuration.md#credentialautodetecttimeout) | ||
Git configuration setting to the maximum number of milliseconds to wait. | ||
|
||
The default value is 2000 milliseconds (2 seconds). You can prevent the network | ||
call altogether by setting a zero or negative value, for example -1. | ||
|
||
## Explicit configuration | ||
|
||
If the auto-detection mechanism fails to select the correct host provider, or | ||
if the remote probing network call is causing performance issues, you can | ||
configure GCM to always use a particular host provider, for a given remote URL. | ||
|
||
You can either use the the [`GCM_PROVIDER`](environment.md#GCM_PROVIDER) | ||
environment variable, or the [`credential.provider`](configuration.md#credentialprovider) | ||
Git configuration setting for this purpose. | ||
|
||
For example to tell GCM to always use the GitHub host provider for the | ||
"ghe.example.com" hostname, you can run the following command: | ||
|
||
```shell | ||
git config --global credential.ghe.example.com.provider github | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.