forked from brunobritodev/JPProject.IdentityServer4.AdminUI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIdentityConfig.cs
More file actions
34 lines (29 loc) · 1.58 KB
/
IdentityConfig.cs
File metadata and controls
34 lines (29 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using IdentityServer4.EntityFramework.Options;
using Jp.Infra.CrossCutting.Identity.Context;
using Jp.Infra.CrossCutting.Identity.Entities.Identity;
using Jp.Infra.Data.Context;
using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using System.Reflection;
namespace Jp.Infra.Data.Sqlite.Configuration
{
public static class IdentityConfig
{
public static IServiceCollection AddIdentitySqlite(this IServiceCollection services, string connectionString)
{
var migrationsAssembly = typeof(IdentityConfig).GetTypeInfo().Assembly.GetName().Name;
var operationalStoreOptions = new OperationalStoreOptions();
services.AddSingleton(operationalStoreOptions);
var storeOptions = new ConfigurationStoreOptions();
services.AddSingleton(storeOptions);
services.AddEntityFrameworkSqlite().AddDbContext<ApplicationIdentityContext>(options => options.UseSqlite(connectionString, sql => sql.MigrationsAssembly(migrationsAssembly)));
services.AddDbContext<JpContext>(options => options.UseSqlite(connectionString, sql => sql.MigrationsAssembly(migrationsAssembly)));
services.AddDbContext<EventStoreContext>(options => options.UseSqlite(connectionString, sql => sql.MigrationsAssembly(migrationsAssembly)));
services.AddIdentity<UserIdentity, UserIdentityRole>()
.AddEntityFrameworkStores<ApplicationIdentityContext>()
.AddDefaultTokenProviders();
return services;
}
}
}