Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide IConfiguration extensions to configure certain modules (Lombiq Technologies: OCORE-97) #12033

Merged
merged 12 commits into from
Sep 7, 2022
58 changes: 58 additions & 0 deletions src/OrchardCore.Cms.Web/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -143,5 +143,63 @@
//"OrchardCore_HealthChecks": {
// "Url": "/health/live"
//},
//"OrchardCore_Email": {
// "DefaultSender": "",
// "DefaultSender": "Network",
// "PickupDirectoryLocation": "",
// "Host": "localhost",
// "Port": 25,
// // Uncomment if SMTP server runs through a proxy server
// //"ProxyHost": "proxy.domain.com",
// //"ProxyPort": 5050,
// "EncryptionMethod": "SSLTLS",
// "AutoSelectEncryption": false,
// "UseDefaultCredentials": false,
// "RequireCredentials": true,
// "Username": "",
// "Password": ""
//},
//"OrchardCore_ReverseProxy": {
// "ForwardedHeaders": "None"
//},
//"OrchardCore_Facebook": {
// "AppId": "",
// "AppSecret": "",
// "FBInit": false,
// "FBInitParams": "status:true,xfbml:true,autoLogAppEvents:true",
// "SdkJs": "sdk.js",
// "Version": "v3.2"
//},
//"OrchardCore_GitHub": {
// "ClientID": "",
// "ClientSecret": "",
// "CallbackPath": "/signin-github",
// "SaveTokens": false
//},
//"OrchardCore_Google": {
// "ClientID": "",
// "ClientSecret": "",
// "CallbackPath": "/signin-google",
// "SaveTokens": false
//},
//"OrchardCore_Twitter": {
// "ConsumerKey": "",
// "ConsumerSecret": "",
// "AccessToken": "",
// "AccessTokenSecret": ""
//},
//"OrchardCore_Microsoft_Authentication_MicrosoftAccount": {
// "AppId": "",
// "AppSecret": "",
// "CallbackPath": "/signin-microsoft",
// "SaveTokens": false
//},
//"OrchardCore_Microsoft_Authentication_AzureAD": {
// "DisplayName": "",
// "AppId": "",
// "TenantId": "",
// "CallbackPath": "/signin-oidc",
// "SaveTokens": false
//}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using Microsoft.Extensions.Configuration;
using OrchardCore.Environment.Shell.Configuration;
using OrchardCore.Email;

namespace Microsoft.Extensions.DependencyInjection
{
public static class OrchardCoreBuilderExtensions
{
public static OrchardCoreBuilder ConfigureEmailSettings(this OrchardCoreBuilder builder)
hishamco marked this conversation as resolved.
Show resolved Hide resolved
hishamco marked this conversation as resolved.
Show resolved Hide resolved
{
builder.ConfigureServices((tenantServices, serviceProvider) =>
{
var configurationSection = serviceProvider.GetRequiredService<IShellConfiguration>().GetSection("OrchardCore_Email");

tenantServices.PostConfigure<SmtpSettings>(settings => configurationSection.Bind(settings));
});

return builder;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using Microsoft.Extensions.Configuration;
using OrchardCore.Environment.Shell.Configuration;
using OrchardCore.Facebook.Settings;

namespace Microsoft.Extensions.DependencyInjection
{
public static class OrchardCoreBuilderExtensions
{
public static OrchardCoreBuilder ConfigureFacebookSettings(this OrchardCoreBuilder builder)
{
builder.ConfigureServices((tenantServices, serviceProvider) =>
{
var configurationSection = serviceProvider.GetRequiredService<IShellConfiguration>().GetSection("OrchardCore_Facebook");

tenantServices.PostConfigure<FacebookSettings>(settings => configurationSection.Bind(settings));
});

return builder;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using Microsoft.Extensions.Configuration;
using OrchardCore.Environment.Shell.Configuration;
using OrchardCore.GitHub.Settings;

namespace Microsoft.Extensions.DependencyInjection
{
public static class OrchardCoreBuilderExtensions
{
public static OrchardCoreBuilder ConfigureGitHubSettings(this OrchardCoreBuilder builder)
{
builder.ConfigureServices((tenantServices, serviceProvider) =>
{
var configurationSection = serviceProvider.GetRequiredService<IShellConfiguration>().GetSection("OrchardCore_GitHub");

tenantServices.PostConfigure<GitHubAuthenticationSettings>(settings => configurationSection.Bind(settings));
hishamco marked this conversation as resolved.
Show resolved Hide resolved
});

return builder;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using Microsoft.Extensions.Configuration;
using OrchardCore.Environment.Shell.Configuration;
using OrchardCore.Google.Authentication.Settings;

namespace Microsoft.Extensions.DependencyInjection
{
public static class OrchardCoreBuilderExtensions
{
public static OrchardCoreBuilder ConfigureGoogleSettings(this OrchardCoreBuilder builder)
{
builder.ConfigureServices((tenantServices, serviceProvider) =>
{
var configurationSection = serviceProvider.GetRequiredService<IShellConfiguration>().GetSection("OrchardCore_Google");

tenantServices.PostConfigure<GoogleAuthenticationSettings>(settings => configurationSection.Bind(settings));
});

return builder;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using Microsoft.Extensions.Configuration;
using OrchardCore.Environment.Shell.Configuration;
using OrchardCore.Microsoft.Authentication.Settings;

namespace Microsoft.Extensions.DependencyInjection
{
public static class OrchardCoreBuilderExtensions
{
public static OrchardCoreBuilder ConfigureMicrosoftAccountSettings(this OrchardCoreBuilder builder)
{
builder.ConfigureServices((tenantServices, serviceProvider) =>
{
var configurationSection = serviceProvider.GetRequiredService<IShellConfiguration>().GetSection("OrchardCore_Microsoft_Authentication_MicrosoftAccount");

tenantServices.PostConfigure<MicrosoftAccountSettings>(settings => configurationSection.Bind(settings));
});

return builder;
}

public static OrchardCoreBuilder ConfigureAzureADSettings(this OrchardCoreBuilder builder)
{
builder.ConfigureServices((tenantServices, serviceProvider) =>
{
var configurationSection = serviceProvider.GetRequiredService<IShellConfiguration>().GetSection("OrchardCore_Microsoft_Authentication_AzureAD");

tenantServices.PostConfigure<AzureADSettings>(settings => configurationSection.Bind(settings));
});

return builder;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using Microsoft.Extensions.Configuration;
using OrchardCore.Environment.Shell.Configuration;
using OrchardCore.ReverseProxy.Settings;

namespace Microsoft.Extensions.DependencyInjection
{
public static class OrchardCoreBuilderExtensions
{
public static OrchardCoreBuilder ConfigureReverseProxySettings(this OrchardCoreBuilder builder)
{
builder.ConfigureServices((tenantServices, serviceProvider) =>
{
var configurationSection = serviceProvider.GetRequiredService<IShellConfiguration>().GetSection("OrchardCore_ReverseProxy");

tenantServices.PostConfigure<ReverseProxySettings>(settings => configurationSection.Bind(settings));
});

return builder;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using Microsoft.Extensions.Configuration;
using OrchardCore.Environment.Shell.Configuration;
using OrchardCore.Twitter.Settings;

namespace Microsoft.Extensions.DependencyInjection
{
public static class OrchardCoreBuilderExtensions
{
public static OrchardCoreBuilder ConfigureTwitterSettings(this OrchardCoreBuilder builder)
{
builder.ConfigureServices((tenantServices, serviceProvider) =>
{
var configurationSection = serviceProvider.GetRequiredService<IShellConfiguration>().GetSection("OrchardCore_Twitter");

tenantServices.PostConfigure<TwitterSettings>(settings => configurationSection.Bind(settings));
});

return builder;
}
}
}
3 changes: 3 additions & 0 deletions src/docs/reference/core/Configuration/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ services
});
```

!!! note
Such configuration for `SmtpSettings` is already available via the `ConfigureEmailSettings` extension method, see [Email Configuration](../../modules/Email/README.md).

This will make the SMTP port use this configuration despite any other value defined in site settings. The second example's configuration value can come from e.g. an `appsettings.json` file like below:

```json
Expand Down
27 changes: 27 additions & 0 deletions src/docs/reference/modules/Email/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,33 @@ Enabling the `OrchardCore.Email` module will allow the user to set the following
!!! note
You must configure `ProxyHost` and `ProxyPort` if the SMTP server runs through a proxy server.

## Email Settings Configuration

The `OrchardCore.Email` module allows the user to use configuration values to override the settings configured from the admin area by calling the `ConfigureEmailSettings()` extension method on `OrchardCoreBuilder` when initializing the app.

The following configuration values can be customized:

```json
"OrchardCore_Email": {
"DefaultSender": "",
"DefaultSender": "Network",
"PickupDirectoryLocation": "",
"Host": "localhost",
"Port": 25,
// Uncomment if SMTP server runs through a proxy server
//"ProxyHost": "proxy.domain.com",
//"ProxyPort": 5050,
"EncryptionMethod": "SSLTLS",
"AutoSelectEncryption": false,
"UseDefaultCredentials": false,
"RequireCredentials": true,
"Username": "",
"Password": ""
}
```

For more information please refer to [Configuration](../../core/Configuration/README.md).

## Credits

### MailKit
Expand Down
21 changes: 21 additions & 0 deletions src/docs/reference/modules/Facebook/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,24 @@ It defines the following widgets:
- Quote
- Save
- Share

## Facebook Settings Configuration

The `OrchardCore.Facebook` module allows the user to use configuration values to override the settings configured from the admin area by calling the `ConfigureFacebookSettings()` extension method on `OrchardCoreBuilder` when initializing the app.

The following configuration values can be customized:

```json
"OrchardCore_Facebook": {
"AppId": "",
"AppSecret": "",
"FBInit": false,
"FBInitParams": "status:true,
xfbml:true,
autoLogAppEvents:true",
"SdkJs": "sdk.js",
"Version": "v3.2"
}
```

For more information please refer to [Configuration](../../core/Configuration/README.md).
17 changes: 17 additions & 0 deletions src/docs/reference/modules/GitHub/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,20 @@ If no value is provided, setup Authorization callback URL in GitHub app to use t

- If you want to enable new users to register to the site through their GitHub account, the `OrchardCore.Users.Registration` feature must be enabled and setup accordingly.
- An existing user can link his account to his GitHub account through the External Logins link from User menu.

## GitHub Settings Configuration

The `OrchardCore.GitHub` module allows the user to use configuration values to override the settings configured from the admin area by calling the `ConfigureGitHubSettings()` extension method on `OrchardCoreBuilder` when initializing the app.

The following configuration values can be customized:

```json
"OrchardCore_GitHub": {
"ClientID": "",
"ClientSecret": "",
"CallbackPath": "/signin-github",
"SaveTokens": false
}
```

For more information please refer to [Configuration](../../core/Configuration/README.md).
17 changes: 17 additions & 0 deletions src/docs/reference/modules/Google/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,20 @@ If no value is provided, setup Callback URL in Google API to use the default pat

+ If you want to enable new users to register to the site through their Google account, the `OrchardCore.Users.Registration` feature must be enabled and setup accordingly.
+ An existing user can link his account to his Google account through the External Logins link from User menu.

## Google Settings Configuration

The `OrchardCore.Google` module allows the user to use configuration values to override the settings configured from the admin area by calling the `ConfigureGoogleSettings()` extension method on `OrchardCoreBuilder` when initializing the app.

The following configuration values can be customized:

```json
"OrchardCore_Google": {
"ClientID": "",
"ClientSecret": "",
"CallbackPath": "/signin-google",
"SaveTokens": false
}
```

For more information please refer to [Configuration](../../core/Configuration/README.md).
27 changes: 27 additions & 0 deletions src/docs/reference/modules/Microsoft.Authentication/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,30 @@ The Azure Active Directory can be set during recipes using the settings step. He

- If you want to enable new users to register to the site through their Microsoft Account and/or Microsoft Azure AD login, the `OrchardCore.Users.Registration` feature must be enabled and setup accordingly.
- An existing user can link his account to his Microsoft Account and/or Microsoft Azure AD login through the External Logins link from User menu

## Microsoft Account & Azure Active Directory Settings Configuration

The `OrchardCore.Microsoft.Authentication` module allows the user to use configuration values to override the settings configured from the admin area by calling the `ConfigureMicrosoftAccountSettings()` or `ConfigureAzureADSettings()` extension methods on `OrchardCoreBuilder` when initializing the app.

The following configuration values can be customized:

```json
"OrchardCore_Microsoft_Authentication_MicrosoftAccount": {
"AppId": "",
"AppSecret": "",
"CallbackPath": "/signin-microsoft",
"SaveTokens": false
}
```

```json
"OrchardCore_Microsoft_Authentication_AzureAD": {
"DisplayName": "",
"AppId": "",
"TenantId": "",
"CallbackPath": "/signin-oidc",
"SaveTokens": false
}
```

For more information please refer to [Configuration](../../core/Configuration/README.md).
16 changes: 15 additions & 1 deletion src/docs/reference/modules/ReverseProxy/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Reverse Proxy (`OrchardCore.ReverseProxy`)

Enables configuration of hosting scenarios with a reverse proxy, like which HTTP headers to forward.
Enables configuration of hosting scenarios with a reverse proxy, like which HTTP headers to forward.

## Reverse Proxy Settings Configuration

The `OrchardCore.ReverseProxy` module allows the user to use configuration values to override the settings configured from the admin area by calling the `ConfigureReverseProxySettings()` extension method on `OrchardCoreBuilder` when initializing the app.

The following configuration values can be customized:

```json
"OrchardCore_ReverseProxy": {
"ForwardedHeaders": "None"
}
```

For more information please refer to [Configuration](../../core/Configuration/README.md).
Loading