|
20 | 20 | using Autofac; |
21 | 21 | using Autofac.Core; |
22 | 22 | using Autofac.Extensions.DependencyInjection; |
| 23 | +using Autofac.Integration.Mvc; |
23 | 24 | using Elmah; |
24 | 25 | using Microsoft.ApplicationInsights.Extensibility; |
25 | 26 | using Microsoft.ApplicationInsights.Extensibility.Implementation; |
|
47 | 48 | using NuGetGallery.Cookies; |
48 | 49 | using NuGetGallery.Diagnostics; |
49 | 50 | using NuGetGallery.Features; |
| 51 | +using NuGetGallery.Filters; |
50 | 52 | using NuGetGallery.Frameworks; |
51 | | -using NuGetGallery.Helpers; |
52 | 53 | using NuGetGallery.Infrastructure; |
53 | 54 | using NuGetGallery.Infrastructure.Authentication; |
54 | 55 | using NuGetGallery.Infrastructure.Lucene; |
@@ -509,6 +510,8 @@ protected override void Load(ContainerBuilder builder) |
509 | 510 |
|
510 | 511 | RegisterCookieComplianceService(configuration, loggerFactory); |
511 | 512 |
|
| 513 | + RegisterCustomMvcFilters(builder, configuration); |
| 514 | + |
512 | 515 | builder.RegisterType<CookieExpirationService>() |
513 | 516 | .As<ICookieExpirationService>() |
514 | 517 | .SingleInstance(); |
@@ -860,6 +863,17 @@ private static void RegisterFeatureFlagsService(ContainerBuilder builder, Config |
860 | 863 | .SingleInstance(); |
861 | 864 | } |
862 | 865 |
|
| 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 | + |
863 | 877 | private static void RegisterMessagingService(ContainerBuilder builder, ConfigurationService configuration) |
864 | 878 | { |
865 | 879 | if (configuration.Current.AsynchronousEmailServiceEnabled) |
|
0 commit comments