Skip to content

Commit 4c090b6

Browse files
committed
scrap custom code in favor of just setting FORWARDEDHEADERS_ENABLED
1 parent ae409c2 commit 4c090b6

12 files changed

+113
-506
lines changed

src/Configuration/src/CloudFoundry/CloudFoundryConfigurationProvider.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ private void Process()
7373

7474
LoadData("vcap:application", applicationData.GetChildren(), data);
7575
AddDiegoVariables(data);
76+
77+
// Enable evaluation of X-Forwarded headers so that ASP.NET Core works automatically behind Gorouter.
78+
// Equivalent to setting ASPNETCORE_FORWARDEDHEADERS_ENABLED to true.
79+
data["FORWARDEDHEADERS_ENABLED"] = "true";
7680
}
7781

7882
string? servicesJson = _settingsReader.ServicesJson;

src/Configuration/src/CloudFoundry/CloudFoundryServiceCollectionExtensions.cs

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// The .NET Foundation licenses this file to you under the Apache 2.0 License.
33
// See the LICENSE file in the project root for more information.
44

5-
using Microsoft.AspNetCore.Builder;
6-
using Microsoft.AspNetCore.HttpOverrides;
75
using Microsoft.Extensions.DependencyInjection;
86
using Microsoft.Extensions.DependencyInjection.Extensions;
97
using Microsoft.Extensions.Options;
@@ -43,44 +41,4 @@ public static IServiceCollection AddCloudFoundryOptions(this IServiceCollection
4341

4442
return services;
4543
}
46-
47-
/// <summary>
48-
/// Configures <see cref="ForwardedHeadersOptions" /> to use forwarded headers as they are provided in Cloud Foundry. Includes
49-
/// <see cref="ForwardedHeaders.XForwardedHost" /> and <see cref="ForwardedHeaders.XForwardedProto" />, and allows headers from proxy servers on any
50-
/// network unless KnownNetworks is configured in
51-
/// <c>
52-
/// Steeltoe:ForwardedHeaders:KnownNetworks
53-
/// </c>
54-
/// or on <see cref="ForwardedHeadersOptions" />, or
55-
/// <c>
56-
/// Steeltoe:ForwardedHeaders:TrustAllNetworks
57-
/// </c>
58-
/// is set to <c>false</c>.
59-
/// </summary>
60-
/// <param name="services">
61-
/// The <see cref="IServiceCollection" /> to configure.
62-
/// </param>
63-
/// <returns>
64-
/// The same <see cref="IServiceCollection" /> instance, for chaining.
65-
/// </returns>
66-
/// <remarks>
67-
/// IMPORTANT: <see cref="ForwardedHeadersExtensions.UseForwardedHeaders(IApplicationBuilder)" /> must be called separately to activate these options.
68-
/// </remarks>
69-
/// <exception cref="ArgumentNullException">
70-
/// Thrown if <paramref name="services" /> is <c>null</c>.
71-
/// </exception>
72-
public static IServiceCollection ConfigureForwardedHeadersOptionsForCloudFoundry(this IServiceCollection services)
73-
{
74-
ArgumentNullException.ThrowIfNull(services);
75-
76-
#pragma warning disable S4792 // Configuring loggers is security-sensitive
77-
services.AddLogging();
78-
#pragma warning restore S4792 // Configuring loggers is security-sensitive
79-
80-
services.AddOptions<ForwardedHeadersSettings>().BindConfiguration(ForwardedHeadersSettings.ConfigurationKey);
81-
services.AddOptions<ForwardedHeadersOptions>();
82-
services.TryAddEnumerable(ServiceDescriptor.Singleton<IConfigureOptions<ForwardedHeadersOptions>, ConfigureForwardedHeadersOptions>());
83-
84-
return services;
85-
}
8644
}

src/Configuration/src/CloudFoundry/ConfigureForwardedHeadersOptions.cs

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

src/Configuration/src/CloudFoundry/ForwardedHeadersSettings.cs

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

src/Configuration/src/CloudFoundry/Properties/AssemblyInfo.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,3 @@
1111
[assembly: InternalsVisibleTo("Steeltoe.Configuration.ConfigServer.Test")]
1212
[assembly: InternalsVisibleTo("Steeltoe.Connectors.Test")]
1313
[assembly: InternalsVisibleTo("Steeltoe.Discovery.HttpClients.Test")]
14-
[assembly: InternalsVisibleTo("Steeltoe.Security.Authorization.Certificate.Test")]

src/Configuration/src/CloudFoundry/PublicAPI.Unshipped.txt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ static Steeltoe.Configuration.CloudFoundry.CloudFoundryHostBuilderExtensions.Add
1111
static Steeltoe.Configuration.CloudFoundry.CloudFoundryHostBuilderExtensions.AddCloudFoundryConfiguration(this Microsoft.Extensions.Hosting.IHostBuilder! builder) -> Microsoft.Extensions.Hosting.IHostBuilder!
1212
static Steeltoe.Configuration.CloudFoundry.CloudFoundryHostBuilderExtensions.AddCloudFoundryConfiguration(this Microsoft.Extensions.Hosting.IHostBuilder! builder, Microsoft.Extensions.Logging.ILoggerFactory! loggerFactory) -> Microsoft.Extensions.Hosting.IHostBuilder!
1313
static Steeltoe.Configuration.CloudFoundry.CloudFoundryServiceCollectionExtensions.AddCloudFoundryOptions(this Microsoft.Extensions.DependencyInjection.IServiceCollection! services) -> Microsoft.Extensions.DependencyInjection.IServiceCollection!
14-
static Steeltoe.Configuration.CloudFoundry.CloudFoundryServiceCollectionExtensions.ConfigureForwardedHeadersOptionsForCloudFoundry(this Microsoft.Extensions.DependencyInjection.IServiceCollection! services) -> Microsoft.Extensions.DependencyInjection.IServiceCollection!
1514
static Steeltoe.Configuration.CloudFoundry.ServiceBindings.ConfigurationBuilderExtensions.AddCloudFoundryServiceBindings(this Microsoft.Extensions.Configuration.IConfigurationBuilder! builder) -> Microsoft.Extensions.Configuration.IConfigurationBuilder!
1615
static Steeltoe.Configuration.CloudFoundry.ServiceBindings.ConfigurationBuilderExtensions.AddCloudFoundryServiceBindings(this Microsoft.Extensions.Configuration.IConfigurationBuilder! builder, Steeltoe.Configuration.CloudFoundry.ServiceBindings.IServiceBindingsReader! serviceBindingsReader) -> Microsoft.Extensions.Configuration.IConfigurationBuilder!
1716
static Steeltoe.Configuration.CloudFoundry.ServiceBindings.ConfigurationBuilderExtensions.AddCloudFoundryServiceBindings(this Microsoft.Extensions.Configuration.IConfigurationBuilder! builder, System.Predicate<string!>! ignoreKeyPredicate, Steeltoe.Configuration.CloudFoundry.ServiceBindings.IServiceBindingsReader! serviceBindingsReader, Microsoft.Extensions.Logging.ILoggerFactory! loggerFactory) -> Microsoft.Extensions.Configuration.IConfigurationBuilder!
@@ -82,12 +81,6 @@ Steeltoe.Configuration.CloudFoundry.CloudFoundryServicesOptions.CloudFoundryServ
8281
Steeltoe.Configuration.CloudFoundry.CloudFoundryServicesOptions.GetAllServices() -> System.Collections.Generic.IList<Steeltoe.Configuration.CloudFoundry.CloudFoundryService!>!
8382
Steeltoe.Configuration.CloudFoundry.CloudFoundryServicesOptions.GetServicesOfType(string! serviceType) -> System.Collections.Generic.IList<Steeltoe.Configuration.CloudFoundry.CloudFoundryService!>!
8483
Steeltoe.Configuration.CloudFoundry.CloudFoundryServicesOptions.Services.get -> System.Collections.Generic.IDictionary<string!, System.Collections.Generic.IList<Steeltoe.Configuration.CloudFoundry.CloudFoundryService!>!>!
85-
Steeltoe.Configuration.CloudFoundry.ForwardedHeadersSettings
86-
Steeltoe.Configuration.CloudFoundry.ForwardedHeadersSettings.ForwardedHeadersSettings() -> void
87-
Steeltoe.Configuration.CloudFoundry.ForwardedHeadersSettings.KnownNetworks.get -> string?
88-
Steeltoe.Configuration.CloudFoundry.ForwardedHeadersSettings.KnownNetworks.set -> void
89-
Steeltoe.Configuration.CloudFoundry.ForwardedHeadersSettings.TrustAllNetworks.get -> bool
90-
Steeltoe.Configuration.CloudFoundry.ForwardedHeadersSettings.TrustAllNetworks.set -> void
9184
Steeltoe.Configuration.CloudFoundry.ICloudFoundrySettingsReader
9285
Steeltoe.Configuration.CloudFoundry.ICloudFoundrySettingsReader.ApplicationJson.get -> string?
9386
Steeltoe.Configuration.CloudFoundry.ICloudFoundrySettingsReader.InstanceId.get -> string?

0 commit comments

Comments
 (0)