-
-
Notifications
You must be signed in to change notification settings - Fork 551
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Isolate all EF<>Identity related bits in new project Piranha.AspNetCo…
…re.Identity.EntityFrameworkCore Use standard functionality of UserManager and RoleManager classes in UserController and RoleController (so remove dependency on IDB)
- Loading branch information
tedvanderveen
committed
May 28, 2021
1 parent
9f60f19
commit 43b9eef
Showing
25 changed files
with
500 additions
and
597 deletions.
There are no files selected for viewing
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
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
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
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
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
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
37 changes: 37 additions & 0 deletions
37
identity/Piranha.AspNetCore.Identity.EntityFrameworkCore/IdentityModuleExtensions.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,37 @@ | ||
/* | ||
* Copyright (c) .NET Foundation and Contributors | ||
* | ||
* This software may be modified and distributed under the terms | ||
* of the MIT license. See the LICENSE file for details. | ||
* | ||
* http://github.com/piranhacms/piranha.core | ||
* | ||
*/ | ||
|
||
using System; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Piranha.AspNetCore.Identity.Data; | ||
|
||
namespace Piranha.AspNetCore.Identity.EntityFrameworkCore | ||
{ | ||
public static class IdentityModuleExtensions | ||
{ | ||
/// <summary> | ||
/// Adds the Piranha identity module. | ||
/// </summary> | ||
/// <param name="services">The current service collection</param> | ||
/// <param name="dbOptions">Options for configuring the database</param> | ||
/// <returns>The services</returns> | ||
public static IServiceCollection AddPiranhaIdentityEF<T>(this IServiceCollection services, Action<DbContextOptionsBuilder> dbOptions) where T : DbContext, IDb | ||
{ | ||
services.AddDbContext<T>(dbOptions); | ||
services.AddScoped<IDb, T>(); | ||
services.AddScoped<T, T>(); | ||
services.AddIdentity<User, Role>() | ||
.AddEntityFrameworkStores<T>(); | ||
|
||
return services; | ||
} | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
identity/Piranha.AspNetCore.Identity.EntityFrameworkCore/IdentityStartupExtensions.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,33 @@ | ||
/* | ||
* Copyright (c) .NET Foundation and Contributors | ||
* | ||
* This software may be modified and distributed under the terms | ||
* of the MIT license. See the LICENSE file for details. | ||
* | ||
* http://github.com/piranhacms/piranha.core | ||
* | ||
*/ | ||
|
||
using System; | ||
using Microsoft.EntityFrameworkCore; | ||
|
||
namespace Piranha.AspNetCore.Identity.EntityFrameworkCore | ||
{ | ||
public static class IdentityStartupExtensions | ||
{ | ||
/// <summary> | ||
/// Extensions method for simplified setup. | ||
/// </summary> | ||
/// <param name="serviceBuilder">The current service builder</param> | ||
/// <param name="dbOptions">The db options</param> | ||
/// <typeparam name="T">The DbContext type</typeparam> | ||
/// <returns>The builder</returns> | ||
public static PiranhaServiceBuilder UseIdentityEF<T>(this PiranhaServiceBuilder serviceBuilder, Action<DbContextOptionsBuilder> dbOptions) | ||
where T : Db<T> | ||
{ | ||
serviceBuilder.Services.AddPiranhaIdentityEF<T>(dbOptions); | ||
|
||
return serviceBuilder; | ||
} | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...tCore.Identity.EntityFrameworkCore/Piranha.AspNetCore.Identity.EntityFrameworkCore.csproj
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,21 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Razor"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net5.0</TargetFramework> | ||
<NoWarn>$(NoWarn);1591</NoWarn> | ||
<AddRazorSupportForMvc>true</AddRazorSupportForMvc> | ||
<Description>Piranha CMS security provider for AspNetCore Identity</Description> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'"> | ||
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="5.0.0" /> | ||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.0" PrivateAssets="all" /> | ||
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="all" /> | ||
<ProjectReference Include="..\Piranha.AspNetCore.Identity\Piranha.AspNetCore.Identity.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
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
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
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
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
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
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
Oops, something went wrong.