-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add deployment for Microsoft Account (#16806)
--------- Co-authored-by: Mike Alhayek <mike@crestapps.com>
- Loading branch information
1 parent
17017e3
commit 412e257
Showing
8 changed files
with
125 additions
and
35 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/AzureADStartup.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using Microsoft.AspNetCore.Authentication; | ||
using Microsoft.AspNetCore.Authentication.OpenIdConnect; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.DependencyInjection.Extensions; | ||
using Microsoft.Extensions.Options; | ||
using Microsoft.Identity.Web; | ||
using OrchardCore.Deployment; | ||
using OrchardCore.DisplayManagement.Handlers; | ||
using OrchardCore.Microsoft.Authentication.Configuration; | ||
using OrchardCore.Microsoft.Authentication.Deployment; | ||
using OrchardCore.Microsoft.Authentication.Drivers; | ||
using OrchardCore.Microsoft.Authentication.Recipes; | ||
using OrchardCore.Microsoft.Authentication.Services; | ||
using OrchardCore.Microsoft.Authentication.Settings; | ||
using OrchardCore.Modules; | ||
using OrchardCore.Navigation; | ||
using OrchardCore.Recipes; | ||
using OrchardCore.Security.Permissions; | ||
|
||
namespace OrchardCore.Microsoft.Authentication; | ||
|
||
[Feature(MicrosoftAuthenticationConstants.Features.AAD)] | ||
public sealed class AzureADStartup : StartupBase | ||
{ | ||
public override void ConfigureServices(IServiceCollection services) | ||
{ | ||
services.AddPermissionProvider<Permissions>(); | ||
|
||
services.AddSingleton<IAzureADService, AzureADService>(); | ||
services.AddRecipeExecutionStep<AzureADSettingsStep>(); | ||
|
||
services.AddSiteDisplayDriver<AzureADSettingsDisplayDriver>(); | ||
services.AddNavigationProvider<AdminMenuAAD>(); | ||
|
||
services.AddTransient<IConfigureOptions<AzureADSettings>, AzureADSettingsConfiguration>(); | ||
|
||
services.AddTransient<IConfigureOptions<AuthenticationOptions>, AzureADOptionsConfiguration>(); | ||
services.AddTransient<IConfigureOptions<MicrosoftIdentityOptions>, AzureADOptionsConfiguration>(); | ||
services.AddTransient<IConfigureOptions<PolicySchemeOptions>, AzureADOptionsConfiguration>(); | ||
services.AddTransient<IConfigureOptions<OpenIdConnectOptions>, OpenIdConnectOptionsConfiguration>(); | ||
|
||
services.AddSingleton<IPostConfigureOptions<OpenIdConnectOptions>, OpenIdConnectPostConfigureOptions>(); | ||
} | ||
} | ||
|
||
[RequireFeatures("OrchardCore.Deployment")] | ||
[Feature(MicrosoftAuthenticationConstants.Features.AAD)] | ||
public sealed class AzureADDeploymentStartup : StartupBase | ||
{ | ||
public override void ConfigureServices(IServiceCollection services) | ||
{ | ||
services.AddDeployment<AzureADDeploymentSource, AzureADDeploymentStep, AzureADDeploymentStepDriver>(); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
...dules/OrchardCore.Microsoft.Authentication/Deployment/MicrosoftAccountDeploymentSource.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System.Text.Json.Nodes; | ||
using OrchardCore.Deployment; | ||
using OrchardCore.Microsoft.Authentication.Services; | ||
using OrchardCore.Microsoft.Authentication.Settings; | ||
|
||
namespace OrchardCore.Microsoft.Authentication.Deployment; | ||
|
||
public sealed class MicrosoftAccountDeploymentSource : IDeploymentSource | ||
{ | ||
private readonly IMicrosoftAccountService _microsoftAccountService; | ||
|
||
public MicrosoftAccountDeploymentSource(IMicrosoftAccountService microsoftAccountService) | ||
{ | ||
_microsoftAccountService = microsoftAccountService; | ||
} | ||
|
||
public async Task ProcessDeploymentStepAsync(DeploymentStep step, DeploymentPlanResult result) | ||
{ | ||
if (step is not MicrosoftAccountDeploymentStep) | ||
{ | ||
return; | ||
} | ||
|
||
var microsoftAccountSettings = await _microsoftAccountService.GetSettingsAsync(); | ||
|
||
result.Steps.Add(new JsonObject | ||
{ | ||
["name"] = "Settings", | ||
[nameof(MicrosoftAccountSettings)] = JObject.FromObject(microsoftAccountSettings), | ||
}); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...Modules/OrchardCore.Microsoft.Authentication/Deployment/MicrosoftAccountDeploymentStep.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using OrchardCore.Deployment; | ||
|
||
namespace OrchardCore.Microsoft.Authentication.Deployment; | ||
|
||
public sealed class MicrosoftAccountDeploymentStep : DeploymentStep | ||
{ | ||
public MicrosoftAccountDeploymentStep() | ||
{ | ||
Name = "MicrosoftAccount"; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...s/OrchardCore.Microsoft.Authentication/Deployment/MicrosoftAccountDeploymentStepDriver.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using OrchardCore.Deployment; | ||
using OrchardCore.DisplayManagement.Handlers; | ||
using OrchardCore.DisplayManagement.Views; | ||
|
||
namespace OrchardCore.Microsoft.Authentication.Deployment; | ||
|
||
public sealed class MicrosoftAccountDeploymentStepDriver : DisplayDriver<DeploymentStep, MicrosoftAccountDeploymentStep> | ||
{ | ||
public override Task<IDisplayResult> DisplayAsync(MicrosoftAccountDeploymentStep step, BuildDisplayContext context) | ||
{ | ||
return CombineAsync( | ||
View("MicrosoftAccountDeploymentStep_Summary", step).Location("Summary", "Content"), | ||
View("MicrosoftAccountDeploymentStep_Thumbnail", step).Location("Thumbnail", "Content") | ||
); | ||
} | ||
|
||
public override IDisplayResult Edit(MicrosoftAccountDeploymentStep step, BuildEditorContext context) | ||
=> View("MicrosoftAccountDeploymentStep_Edit", step).Location("Content"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
...chardCore.Microsoft.Authentication/Views/Items/MicrosoftAccountDeploymentStep.Edit.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<h5>@T["Microsoft Account Settings"]</h5> |
3 changes: 3 additions & 0 deletions
3
...rdCore.Microsoft.Authentication/Views/Items/MicrosoftAccountDeploymentStep.Summary.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<h5>@T["Microsoft Account Settings"]</h5> | ||
|
||
<span class="hint">@T["Adds Microsoft Account settings to the plan."]</span> |
2 changes: 2 additions & 0 deletions
2
...Core.Microsoft.Authentication/Views/Items/MicrosoftAccountDeploymentStep.Thumbnail.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<h4 class="card-title">@T["Microsoft Account Settings"]</h4> | ||
<p>@T["Exports the Microsoft Account settings."]</p> |