public AccountController( UserManager <ApplicationUser> userManager, IPersistedGrantService persistedGrantService, SignInManager <ApplicationUser> signInManager, IEmailSender emailSender, ILoggerFactory loggerFactory, IIdentityServerInteractionService interaction, IClientStore clientStore, IStringLocalizerFactory factory, IOptions <StsConfig> stsConfig, IEventService events) { _userManager = userManager; _persistedGrantService = persistedGrantService; _signInManager = signInManager; _emailSender = emailSender; _logger = loggerFactory.CreateLogger <AccountController>(); _interaction = interaction; _clientStore = clientStore; _events = events; _stsConfig = stsConfig.Value; var type = typeof(SharedResource); var assemblyName = new AssemblyName(type.GetTypeInfo().Assembly.FullName); _sharedLocalizer = factory.Create("SharedResource", assemblyName.Name); }
static void ProcessCommandLine(string[] args) { string configFile = default; // Parse command line args first. var argSyntax = ArgumentSyntax.Parse(args, syntax => { Alias = syntax.DefineOption("a|alias", "", true); configFile = syntax.DefineOption("c|config", @"configs/StsServer.conf").Value; }); // Command line arg checks. if (string.IsNullOrEmpty(Alias.Value)) { System.Console.WriteLine(argSyntax.GetHelpText()); argSyntax.ReportError($"{Alias} is required."); } // Read config file. StsConfig.Initialize(configFile); }
private void InitializeDatabase(IApplicationBuilder app) { using (var serviceScope = app.ApplicationServices.GetService <IServiceScopeFactory>().CreateScope()) { serviceScope.ServiceProvider.GetRequiredService <PersistedGrantDbContext>().Database.Migrate(); var context = serviceScope.ServiceProvider.GetRequiredService <ConfigurationDbContext>(); context.Database.Migrate(); if (!context.Clients.Any()) { foreach (var client in StsConfig.GetClients()) { context.Clients.Add(client.ToEntity()); } context.SaveChanges(); } if (!context.IdentityResources.Any()) { foreach (var resource in StsConfig.GetIdentityResources()) { context.IdentityResources.Add(resource.ToEntity()); } context.SaveChanges(); } if (!context.ApiResources.Any()) { foreach (var resource in StsConfig.GetApiResources()) { context.ApiResources.Add(resource.ToEntity()); } context.SaveChanges(); } } }