Skip to content

Commit 993bafb

Browse files
authored
Revert "Add reCAPTCHA to package uploads (#8948)" (#8952)
This reverts commit afb9219.
1 parent afb9219 commit 993bafb

15 files changed

Lines changed: 14 additions & 122 deletions

File tree

src/AccountDeleter/EmptyFeatureFlagService.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -285,10 +285,5 @@ public bool ProxyGravatarEnSubdomain()
285285
{
286286
throw new NotImplementedException();
287287
}
288-
289-
public bool IsRecaptchaEnabledForUploads()
290-
{
291-
throw new NotImplementedException();
292-
}
293288
}
294289
}

src/GitHubVulnerabilities2Db/Fakes/FakeFeatureFlagService.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -284,10 +284,5 @@ public bool IsRecentPackagesNoIndexEnabled()
284284
{
285285
throw new NotImplementedException();
286286
}
287-
288-
public bool IsRecaptchaEnabledForUploads()
289-
{
290-
throw new NotImplementedException();
291-
}
292287
}
293288
}

src/NuGetGallery.Services/Configuration/FeatureFlagService.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ public class FeatureFlagService : IFeatureFlagService
5555
private const string DisplayTargetFrameworkFeatureName = GalleryPrefix + "DisplayTargetFramework";
5656
private const string ComputeTargetFrameworkFeatureName = GalleryPrefix + "ComputeTargetFramework";
5757
private const string RecentPackagesNoIndexFeatureName = GalleryPrefix + "RecentPackagesNoIndex";
58-
private const string RecaptchaEnabledForUploadsName = GalleryPrefix + "RecaptchaForUploads";
5958

6059
private const string ODataV1GetAllNonHijackedFeatureName = GalleryPrefix + "ODataV1GetAllNonHijacked";
6160
private const string ODataV1GetAllCountNonHijackedFeatureName = GalleryPrefix + "ODataV1GetAllCountNonHijacked";
@@ -375,10 +374,5 @@ public bool IsRecentPackagesNoIndexEnabled()
375374
{
376375
return _client.IsEnabled(RecentPackagesNoIndexFeatureName, defaultValue: false);
377376
}
378-
379-
public bool IsRecaptchaEnabledForUploads()
380-
{
381-
return _client.IsEnabled(RecaptchaEnabledForUploadsName, defaultValue: false);
382-
}
383377
}
384378
}

src/NuGetGallery.Services/Configuration/IFeatureFlagService.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -301,10 +301,5 @@ public interface IFeatureFlagService
301301
/// Whether or not recent packages has no index applied to block search engine indexing.
302302
/// </summary>
303303
bool IsRecentPackagesNoIndexEnabled();
304-
305-
/// <summary>
306-
/// Whether or not we have reCAPTCHA enabled for package uploads
307-
/// </summary>
308-
bool IsRecaptchaEnabledForUploads();
309304
}
310305
}

src/NuGetGallery/App_Data/Files/Content/flags.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@
3131
"NuGetGallery.MarkdigMdRendering": "Enabled",
3232
"NuGetGallery.ImageAllowlist": "Enabled",
3333
"NuGetGallery.ShowReportAbuseSafetyChanges": "Enabled",
34-
"NuGetGallery.ComputeTargetFramework": "Enabled",
35-
"NuGetGallery.RecaptchaForUploads": "Disabled"
34+
"NuGetGallery.ComputeTargetFramework": "Enabled"
3635
},
3736
"Flights": {
3837
"NuGetGallery.TyposquattingFlight": {

src/NuGetGallery/App_Start/DefaultDependenciesModule.cs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
using Autofac;
2121
using Autofac.Core;
2222
using Autofac.Extensions.DependencyInjection;
23-
using Autofac.Integration.Mvc;
2423
using Elmah;
2524
using Microsoft.ApplicationInsights.Extensibility;
2625
using Microsoft.ApplicationInsights.Extensibility.Implementation;
@@ -48,8 +47,8 @@
4847
using NuGetGallery.Cookies;
4948
using NuGetGallery.Diagnostics;
5049
using NuGetGallery.Features;
51-
using NuGetGallery.Filters;
5250
using NuGetGallery.Frameworks;
51+
using NuGetGallery.Helpers;
5352
using NuGetGallery.Infrastructure;
5453
using NuGetGallery.Infrastructure.Authentication;
5554
using NuGetGallery.Infrastructure.Lucene;
@@ -510,8 +509,6 @@ protected override void Load(ContainerBuilder builder)
510509

511510
RegisterCookieComplianceService(configuration, loggerFactory);
512511

513-
RegisterCustomMvcFilters(builder, configuration);
514-
515512
builder.RegisterType<CookieExpirationService>()
516513
.As<ICookieExpirationService>()
517514
.SingleInstance();
@@ -863,17 +860,6 @@ private static void RegisterFeatureFlagsService(ContainerBuilder builder, Config
863860
.SingleInstance();
864861
}
865862

866-
private static void RegisterCustomMvcFilters(ContainerBuilder builder, ConfigurationService configuration)
867-
{
868-
#pragma warning disable CS4014 // VerifyPackage is not awaited because this is attachment, not execution
869-
builder
870-
.Register(context => new ValidateRecaptchaResponseForUploadsAttribute(context.Resolve<IFeatureFlagService>()))
871-
.AsActionFilterFor<PackagesController>(controller => controller.VerifyPackage(default(VerifyPackageRequest)));
872-
#pragma warning restore CS4014 // VerifyPackage is not awaited because this is attachment, not execution
873-
874-
builder.RegisterFilterProvider();
875-
}
876-
877863
private static void RegisterMessagingService(ContainerBuilder builder, ConfigurationService configuration)
878864
{
879865
if (configuration.Current.AsynchronousEmailServiceEnabled)

src/NuGetGallery/Controllers/PackagesController.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,6 @@ private async Task<ActionResult> UploadSymbolsPackageInternal(SubmitPackageReque
326326
var verifyRequest = new VerifyPackageRequest(packageMetadata, accountsAllowedOnBehalfOf, existingPackageRegistration);
327327
verifyRequest.IsSymbolsPackage = true;
328328
verifyRequest.HasExistingAvailableSymbols = packageForUploadingSymbols.IsLatestSymbolPackageAvailable();
329-
verifyRequest.RecaptchaEnabled = false; // No need for recaptcha for symbols packages
330329

331330
model.InProgressUpload = verifyRequest;
332331

@@ -374,7 +373,6 @@ private async Task<ActionResult> UploadPackageInternal(SubmitPackageRequest mode
374373
verifyRequest.LicenseFileContents = await GetLicenseFileContentsOrNullAsync(packageMetadata, packageArchiveReader);
375374
verifyRequest.LicenseExpressionSegments = GetLicenseExpressionSegmentsOrNull(packageMetadata.LicenseMetadata);
376375
verifyRequest.ReadmeFileContents = await GetReadmeFileContentsOrNullAsync(packageMetadata, packageArchiveReader);
377-
verifyRequest.RecaptchaEnabled = _featureFlagService.IsRecaptchaEnabledForUploads();
378376

379377
model.InProgressUpload = verifyRequest;
380378
return View(model);
@@ -2407,7 +2405,6 @@ public virtual ActionResult CancelPendingOwnershipRequest(string id, string requ
24072405
return Redirect(Url.ManagePackageOwnership(id));
24082406
}
24092407

2410-
/// Note that for Recaptcha filtering we attach ValidateRecaptchaResponseForUploadsAttribute directly here: <see cref="DefaultDependenciesModule.RegisterCustomMvcFilters" />.
24112408
[UIAuthorize]
24122409
[HttpPost]
24132410
[RequiresAccountConfirmation("upload a package")]

src/NuGetGallery/Filters/ValidateRecaptchaResponseAttribute.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
namespace NuGetGallery.Filters
1313
{
1414
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, Inherited = true, AllowMultiple = true)]
15-
public class ValidateRecaptchaResponseAttribute : ActionFilterAttribute
15+
public sealed class ValidateRecaptchaResponseAttribute : ActionFilterAttribute
1616
{
1717
private const string RecaptchaResponseId = "g-recaptcha-response";
1818
private const string RecaptchaValidationUrl = "https://www.google.com/recaptcha/api/siteverify?secret={0}&response={1}";

src/NuGetGallery/Filters/ValidateRecaptchaResponseForUploadsAttribute.cs

Lines changed: 0 additions & 24 deletions
This file was deleted.

src/NuGetGallery/NuGetGallery.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,6 @@
220220
<Compile Include="Extensions\CakeBuildManagerExtensions.cs" />
221221
<Compile Include="Extensions\ImageExtensions.cs" />
222222
<Compile Include="Filters\AdminActionAttribute.cs" />
223-
<Compile Include="Filters\ValidateRecaptchaResponseForUploadsAttribute.cs" />
224223
<Compile Include="Helpers\AdminHelper.cs" />
225224
<Compile Include="Helpers\ValidationHelper.cs" />
226225
<Compile Include="Helpers\ViewModelExtensions\DeleteAccountListPackageItemViewModelFactory.cs" />

0 commit comments

Comments
 (0)