public AccountController( UserManager <User> userManager, SignInManager <User> signInManager, IIdentityServerInteractionService interaction, IClientStore clientStore, IAuthenticationSchemeProvider schemeProvider, IEventService events, IdentityServerTools tools, //ConfigurationDbContext configurationDbContext, IConfiguration configuration, INotificationHelper notificationHelper, UserProfileService userProfileService, OtpKey otpKey, TssIdentityDbContext tssIdentityDbContext) { _userManager = userManager; _signInManager = signInManager; _interaction = interaction; _clientStore = clientStore; _schemeProvider = schemeProvider; _events = events; _tools = tools; //_configurationDbContext = configurationDbContext; _configurationRoot = (IConfigurationRoot)configuration; _notificationHelper = notificationHelper; _userProfileService = userProfileService; _otpKey = otpKey; _tssIdentityDbContext = tssIdentityDbContext; }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { var migrationsAssembly = typeof(Startup).GetTypeInfo().Assembly.GetName().Name; services.AddCors(); services.AddControllersWithViews().AddRazorRuntimeCompilation(); // configure strongly typed settings objects services.AddHttpContextAccessor(); services.AddTransient <IPrincipal>( provider => provider.GetService <IHttpContextAccessor>().HttpContext.User); services.AddDbContext <TssIdentityDbContext>(options => { options.UseSqlServer(Configuration.GetConnectionString("IdentityDb"), b => b.MigrationsHistoryTable("_Migrations")); }); services.AddIdentity <User, Role>() .AddEntityFrameworkStores <TssIdentityDbContext>() .AddDefaultTokenProviders(); services.AddIdentityServer() .AddAspNetIdentity <User>() .AddResourceOwnerValidator <ResourceOwnerPasswordValidator>() .AddDeveloperSigningCredential() .AddInMemoryApiResources(Config.GetApiResources()) .AddInMemoryClients(Config.GetClients()) .AddInMemoryIdentityResources(Config.GetIdentityResources()) //.AddConfigurationStore(options => //{ // options.ConfigureDbContext = builder => // builder.UseSqlServer(Configuration.GetConnectionString("AuthSSDb"), b => // { // b.MigrationsHistoryTable("_ConfigurationMigrations"); // b.MigrationsAssembly(migrationsAssembly); // }); //}) ////this adds the operational data from DB (codes, tokens, consents) //.AddOperationalStore(options => //{ // options.ConfigureDbContext = builder => // builder.UseSqlServer(Configuration.GetConnectionString("AuthSSDb"), b => // { // b.MigrationsHistoryTable("_PersistedGrantMigrations"); // b.MigrationsAssembly(migrationsAssembly); // }); // // this enables automatic token cleanup. this is optional. // options.EnableTokenCleanup = true; // options.TokenCleanupInterval = 30; //}) .AddProfileService <UserProfileService>(); services.AddDataProtection().SetApplicationName("IdentityApp") .PersistKeysToAzureBlobStorage(CloudStorageAccount, Configuration["DataProtectionKeyBlobPath"]) .ProtectKeysWithAzureKeyVault(Configuration["DataProtectionKeyProtectorVaultKey"], Configuration["AzureKeyVault:ClientId"], Configuration["AzureKeyVault:ClientSecret"]); services.AddScoped <INotificationHelper, NotificationHelper>(); services.AddScoped <UserProfileService, UserProfileService>(); var otpKey = new OtpKey() { Key = Configuration["OtpKey"] }; services.AddSingleton <OtpKey>(otpKey); services.AddSpaStaticFiles(configuration => { configuration.RootPath = "MFRegistration"; }); services.AddSpaStaticFiles(configuration => { configuration.RootPath = "ProductManagement"; }); services.AddSpaStaticFiles(configuration => { configuration.RootPath = "UserManagement"; }); services.AddSpaStaticFiles(configuration => { configuration.RootPath = "VendorManagement"; }); services.AddSpaStaticFiles(configuration => { configuration.RootPath = "OrderManagement"; }); services.AddSpaStaticFiles(configuration => { configuration.RootPath = "Dashboard"; }); }
public ResourceOwnerPasswordValidator(TssIdentityDbContext identityServerDbContext, OtpKey otpKey) { _tssDbContext = identityServerDbContext; _otpKey = otpKey; }