public static IJpProjectConfigurationBuilder AddSsoContext <TContext>(this IJpProjectConfigurationBuilder services) where TContext : class, ISsoContext, IEventStoreContext { services.Services.TryAddScoped <IEventStore, SqlEventStore>(); services.Services.TryAddScoped <IUnitOfWork, UnitOfWork>(); services.Services.AddScoped <ISsoContext, TContext>(); services.Services.TryAddScoped <IEventStoreContext>(s => s.GetService <TContext>()); services.Services.TryAddScoped <IJpEntityFrameworkStore>(x => x.GetRequiredService <TContext>()); services.Services.AddStores(); return(services); }
/// <summary> /// Configure IdentityServer4 Administration services /// </summary> public static IJpProjectConfigurationBuilder ConfigureJpAdmin <TUser>(this IJpProjectConfigurationBuilder builder) where TUser : class, ISystemUser { // Domain Bus (Mediator) builder.Services.TryAddScoped <IMediatorHandler, InMemoryBus>(); builder.Services.TryAddScoped <ISystemUser, TUser>(); builder.Services .AddApplicationServices() .AddDomainEventsServices() .AddDomainCommandsServices(); return(builder); }
public static IJpProjectConfigurationBuilder SetupDefaultIdentityServerContext <TContext>( this IJpProjectConfigurationBuilder services) where TContext : IPersistedGrantDbContext, IConfigurationDbContext { // Configure identityserver4 default database var operationalStoreOptions = new OperationalStoreOptions(); var storeOptions = new ConfigurationStoreOptions(); services.Services.AddSingleton(operationalStoreOptions); services.Services.AddSingleton(storeOptions); services.Services.TryAddScoped <IPersistedGrantDbContext>(x => x.GetRequiredService <TContext>()); services.Services.TryAddScoped <IConfigurationDbContext>(x => x.GetRequiredService <TContext>()); return(services); }
/// <summary> /// Configure SSO Services /// </summary> /// <typeparam name="THttpUser">Implementation of ISystemUser</typeparam> /// <returns></returns> public static IJpProjectConfigurationBuilder ConfigureSso <THttpUser>(this IJpProjectConfigurationBuilder builder) where THttpUser : class, ISystemUser { builder.Services.TryAddScoped <IMediatorHandler, InMemoryBus>(); builder.Services.TryAddScoped <ISystemUser, THttpUser>(); builder.Services.AddScoped <IEventSink, IdentityServerEventStore>(); builder.Services.AddScoped <IStorage, StorageService>(); builder.Services .AddApplicationServices() .AddDomainEvents() .AddDomainCommands(); return(new JpProjectBuilder(builder.Services)); }
public static IJpProjectConfigurationBuilder AddJpAdminContext(this IJpProjectConfigurationBuilder services, Action <DbContextOptionsBuilder> optionsAction, JpDatabaseOptions options = null) { if (options == null) { options = new JpDatabaseOptions(); } RegisterStorageServices(services.Services); services.Services.TryAddScoped <IUnitOfWork, UnitOfWork>(); services.Services.AddDbContext <JpProjectAdminUiContext>(optionsAction); services.Services.AddScoped <IJpEntityFrameworkStore>(x => x.GetService <JpProjectAdminUiContext>()); services.Services.AddScoped <IConfigurationDbContext>(x => x.GetService <JpProjectAdminUiContext>()); services.Services.AddScoped <IPersistedGrantDbContext>(x => x.GetService <JpProjectAdminUiContext>()); services.SetupDefaultIdentityServerContext <JpProjectAdminUiContext>(); return(services); }
public static IJpProjectConfigurationBuilder AddDefaultAspNetIdentityServices(this IJpProjectConfigurationBuilder services) { // Infra - Identity Services services.Services.AddScoped <IUserService, UserService <UserIdentity, RoleIdentity, string> >(); services.Services.AddScoped <IRoleService, RoleService <RoleIdentity, string> >(); services.Services.AddScoped <IIdentityFactory <UserIdentity>, IdentityFactory>(); services.Services.AddScoped <IRoleFactory <RoleIdentity>, IdentityFactory>(); return(services); }
public static IJpProjectConfigurationBuilder ConfigureIdentity <TUser, TRole, TKey, TRoleFactory, TUserFactory>(this IJpProjectConfigurationBuilder services) where TUser : IdentityUser <TKey>, IDomainUser where TRole : IdentityRole <TKey> where TKey : IEquatable <TKey> where TRoleFactory : class, IRoleFactory <TRole> where TUserFactory : class, IIdentityFactory <TUser> { services.Services.AddScoped <IUserService, UserService <TUser, TRole, TKey> >(); services.Services.AddScoped <IRoleService, RoleService <TRole, TKey> >(); services.Services.AddScoped <IIdentityFactory <TUser>, TUserFactory>(); services.Services.AddScoped <IRoleFactory <TRole>, TRoleFactory>(); return(services); }
public static IJpProjectConfigurationBuilder AddEventStore <TEventStore>(this IJpProjectConfigurationBuilder services) where TEventStore : class, IEventStoreContext { services.Services.AddScoped <IEventStoreContext, TEventStore>(); return(services); }
public static IJpProjectConfigurationBuilder ConfigureAdminContext <TContext, TEventStore>(this IJpProjectConfigurationBuilder services) where TContext : class, IPersistedGrantDbContext, IConfigurationDbContext, IJpEntityFrameworkStore where TEventStore : class, IEventStoreContext { RegisterStorageServices(services.Services); services.Services.TryAddScoped <IEventStoreContext>(x => x.GetRequiredService <TEventStore>()); services.Services.TryAddScoped <IConfigurationDbContext>(x => x.GetRequiredService <TContext>()); services.Services.TryAddScoped <IPersistedGrantDbContext>(x => x.GetRequiredService <TContext>()); services.Services.TryAddScoped <IJpEntityFrameworkStore>(x => x.GetRequiredService <TContext>()); return(services); }
public static IJpProjectConfigurationBuilder ConfigureJpAdminStorageServices(this IJpProjectConfigurationBuilder services) { RegisterStorageServices(services.Services); return(services); }