Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/OrchardCore.Cms.Web/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,8 @@
//}
//"OrchardCore_ReverseProxy": {
// "ForwardedHeaders": "None",
// "KnownNetworks": ["192.168.1.100/4", "192.168.1.101/4"],
// "KnownProxies": ["192.168.1.200", "192.168.1.201"],
// "KnownNetworks": ["192.168.1.0/24"],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's th wrong with this example :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From a network perspective, this example doesn't make any sense. In addition, the change adjusts the example to match the documentation.

// "KnownProxies": ["192.168.1.200", "192.168.1.201"]
//},
//"OrchardCore_Facebook": {
// "AppId": "",
Expand Down
14 changes: 6 additions & 8 deletions src/OrchardCore.Modules/OrchardCore.ReverseProxy/AdminMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,12 @@ protected override ValueTask BuildAsync(NavigationBuilder builder)

builder
.Add(S["Settings"], settings => settings
.Add(S["Security"], S["Security"].PrefixPosition(), security => security
.Add(S["Reverse Proxy"], S["Reverse Proxy"].PrefixPosition(), proxy => proxy
.AddClass("reverseproxy")
.Id("reverseproxy")
.Action("Index", "Admin", _routeValues)
.Permission(Permissions.ManageReverseProxySettings)
.LocalNav()
)
.Add(S["Reverse Proxy"], S["Reverse Proxy"].PrefixPosition(), proxy => proxy
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is fine for me.

.AddClass("reverseproxy")
.Id("reverseproxy")
.Action("Index", "Admin", _routeValues)
.Permission(Permissions.ManageReverseProxySettings)
.LocalNav()
)
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using Microsoft.Extensions.Options;
using OrchardCore.ReverseProxy.Settings;

namespace OrchardCore.ReverseProxy.Services;
namespace OrchardCore.ReverseProxy.Configuration;

public sealed class ForwardedHeadersOptionsConfiguration : IConfigureOptions<ForwardedHeadersOptions>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
using Microsoft.Extensions.Options;
using OrchardCore.ReverseProxy.Settings;
using OrchardCore.Settings;

namespace OrchardCore.ReverseProxy.Services;
namespace OrchardCore.ReverseProxy.Configuration;

public class ReverseProxySettingsConfiguration : IConfigureOptions<ReverseProxySettings>
{
private readonly ReverseProxyService _reverseProxyService;
private readonly ISiteService _siteService;

public ReverseProxySettingsConfiguration(ReverseProxyService reverseProxyService)
=> _reverseProxyService = reverseProxyService;
public ReverseProxySettingsConfiguration(ISiteService siteService)
=> _siteService = siteService;

public void Configure(ReverseProxySettings options)
{
var settings = _reverseProxyService.GetSettingsAsync()
.GetAwaiter()
.GetResult();
var settings = _siteService.GetSettings<ReverseProxySettings>();

options.ForwardedHeaders = settings.ForwardedHeaders;
options.KnownNetworks = settings.KnownNetworks;
options.KnownProxies = settings.KnownProxies;
}
}

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
Expand Down

This file was deleted.

5 changes: 1 addition & 4 deletions src/OrchardCore.Modules/OrchardCore.ReverseProxy/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
using OrchardCore.DisplayManagement.Handlers;
using OrchardCore.Modules;
using OrchardCore.Navigation;
using OrchardCore.ReverseProxy.Configuration;
using OrchardCore.ReverseProxy.Drivers;
using OrchardCore.ReverseProxy.Services;
using OrchardCore.ReverseProxy.Settings;
using OrchardCore.Security.Permissions;
using OrchardCore.Settings.Deployment;
Expand All @@ -29,10 +29,7 @@ public override void ConfigureServices(IServiceCollection services)
services.AddPermissionProvider<Permissions>();
services.AddSiteDisplayDriver<ReverseProxySettingsDisplayDriver>();

services.AddSingleton<ReverseProxyService>();

services.AddTransient<IConfigureOptions<ReverseProxySettings>, ReverseProxySettingsConfiguration>();

services.AddTransient<IConfigureOptions<ForwardedHeadersOptions>, ForwardedHeadersOptionsConfiguration>();
}
}
Expand Down