Skip to content

Commit

Permalink
Move identity to infra (#125)
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-goldman authored Nov 16, 2023
1 parent 2e08e19 commit ce31e91
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 19 deletions.
12 changes: 10 additions & 2 deletions Src/Infrastructure/DependencyInjection.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// using Microsoft.AspNetCore.Hosting;
// using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
Expand Down Expand Up @@ -53,5 +52,14 @@ private static void AddIdentity(IServiceCollection services, IConfiguration conf
services.AddScoped<IUserManager, UserManagerService>();

services.AddScoped<ApplicationDbContextInitializer>();

services.AddAuthentication()
.AddBearerToken(IdentityConstants.BearerScheme);

services.AddAuthorizationBuilder();

services.AddIdentityCore<ApplicationUser>()
.AddEntityFrameworkStores<ApplicationDbContext>()
.AddApiEndpoints();
}
}
12 changes: 4 additions & 8 deletions Src/Infrastructure/Infrastructure.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,8 @@
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.0" />
<PackageReference Include="Bogus" Version="34.0.2"/>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Identity.Core" Version="8.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" version="8.0.0" />
</ItemGroup>

<ItemGroup>
Expand All @@ -30,4 +24,6 @@
<Folder Include="Identity\Migrations\" />
</ItemGroup>



</Project>
8 changes: 0 additions & 8 deletions Src/WebUI/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using Microsoft.AspNetCore.Identity;
using Northwind.Application;
using Northwind.Infrastructure;
using Northwind.Infrastructure.Identity;
Expand All @@ -13,13 +12,6 @@
builder.Services.AddApplication();
builder.Services.AddInfrastructure(builder.Configuration);

// TODO: Move this to infrastructure later (https://github.com/SSWConsulting/Northwind365/issues/104)
builder.Services.AddAuthentication().AddBearerToken(IdentityConstants.BearerScheme);
builder.Services.AddAuthorizationBuilder();
builder.Services.AddIdentityCore<ApplicationUser>()
.AddEntityFrameworkStores<ApplicationDbContext>()
.AddApiEndpoints();

var app = builder.Build();

app.MapIdentityApi<ApplicationUser>();
Expand Down
1 change: 0 additions & 1 deletion Src/WebUI/WebUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Identity.Core" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="8.0.0" />
<PackageReference Include="FluentValidation.AspNetCore" Version="11.3.0"/>
Expand Down

0 comments on commit ce31e91

Please sign in to comment.