Skip to content

Commit 2fbe3d6

Browse files
committed
bitbucket: support GCM_ALLOW_UNSAFE_REMOTES option
1 parent 32d205b commit 2fbe3d6

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/shared/Atlassian.Bitbucket/BitbucketHostProvider.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ public bool IsSupported(InputArguments input)
5555
return false;
5656
}
5757

58-
// We do not support unencrypted HTTP communications to Bitbucket,
59-
// but we report `true` here for HTTP so that we can show a helpful
58+
// We do not recommend unencrypted HTTP communications to Bitbucket, but it is possible.
59+
// Therefore, we report `true` here for HTTP so that we can show a helpful
6060
// error message for the user in `GetCredentialAsync`.
6161
return (StringComparer.OrdinalIgnoreCase.Equals(input.Protocol, "http") ||
6262
StringComparer.OrdinalIgnoreCase.Equals(input.Protocol, "https")) &&
@@ -81,11 +81,14 @@ public bool IsSupported(HttpResponseMessage response)
8181
public async Task<ICredential> GetCredentialAsync(InputArguments input)
8282
{
8383
// We should not allow unencrypted communication and should inform the user
84-
if (StringComparer.OrdinalIgnoreCase.Equals(input.Protocol, "http")
85-
&& BitbucketHelper.IsBitbucketOrg(input))
84+
if (!_context.Settings.AllowUnsafeRemotes &&
85+
StringComparer.OrdinalIgnoreCase.Equals(input.Protocol, "http") &&
86+
BitbucketHelper.IsBitbucketOrg(input))
8687
{
8788
throw new Trace2Exception(_context.Trace2,
88-
"Unencrypted HTTP is not supported for Bitbucket.org. Ensure the repository remote URL is using HTTPS.");
89+
"Unencrypted HTTP is not recommended for Bitbucket.org. " +
90+
"Ensure the repository remote URL is using HTTPS " +
91+
$"or see {Constants.HelpUrls.GcmUnsafeRemotes} about how to allow unsafe remotes.");
8992
}
9093

9194
var authModes = await GetSupportedAuthenticationModesAsync(input);

0 commit comments

Comments
 (0)