// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IdentitySeed identitySeed) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseSerilogRequestLogging(); app.UseCookiesPolicy(); app.UseSecureJwt(); identitySeed.Seed().Wait(); app.UseDefaultFiles(); app.UseStaticFiles(); app.UseCors(x => x.WithOrigins("https://localhost:4200", "https://localhost:44385").AllowAnyHeader().AllowAnyMethod().AllowCredentials()); app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); app.UseEndpoints(endpoints => endpoints.MapFallbackToController("Index", "Home")); }
public static void Main(string[] args) { var host = CreateWebHostBuilder(args) .Build(); using (var scope = host.Services.CreateScope()) { var services = scope.ServiceProvider; var loggerFactory = services.GetRequiredService <ILoggerFactory>(); try { //var catalogContext = services.GetRequiredService<CatalogContext>(); //CatalogContextSeed.SeedAsync(catalogContext, loggerFactory).Wait(); //var userManager = services.GetRequiredService<UserManager<ApplicationUser>>(); var RoleManager = services.GetRequiredService <RoleManager <ApplicationRole> >(); var UserManager = services.GetRequiredService <UserManager <ApplicationUser> >(); IdentitySeed.IdentitySeedAsync(UserManager, RoleManager).Wait(); } catch (Exception ex) { var logger = loggerFactory.CreateLogger <Program>(); logger.LogError(ex, "An error occurred seeding the DB."); } } host.Run(); }
public static async Task Main(string[] args) { var host = CreateHostBuilder(args).Build(); using (var scope = host.Services.CreateScope()) { var services = scope.ServiceProvider; var loggerFactory = services.GetRequiredService <ILoggerFactory>(); try { var context = services.GetRequiredService <GemsContext>(); await context.Database.MigrateAsync(); await SeedDataClass.SeedAsync(context, loggerFactory); var userManager = services.GetRequiredService <UserManager <AppUser> >(); var identityContext = services.GetRequiredService <IdentityContext>(); await identityContext.Database.MigrateAsync(); await IdentitySeed.SeedUserAsync(userManager); } catch (Exception ex) { var logger = loggerFactory.CreateLogger <Program>(); logger.LogError(ex, "An error occured during migration"); } } host.Run(); }
private static async Task StartSeedAsync(AntlContext context, UserManager <ApplicationUser> userManager, RoleManager <IdentityRole <int> > roleManager) { var applicationUserList = new ApplicationUserSeed().SeedUsers(); if (applicationUserList == null) { throw new ArgumentNullException(); } await IdentitySeed.SetIdentityRoleAsync(userManager, roleManager, applicationUserList).ConfigureAwait(false); var events = new EventSeed().SeedEvents(applicationUserList); if (events == null) { throw new ArgumentNullException(); } foreach (var appointment in events) { await context.Events.AddAsync(appointment).ConfigureAwait(false); } var group = new UserGroupSeed().SeedGroups(applicationUserList); await context.Groups.AddAsync(group).ConfigureAwait(false); var friendships = new FriendshipSeed().SeedFriendShips(applicationUserList[0], applicationUserList[1]); await context.Friendships.AddAsync(friendships).ConfigureAwait(false); await context.SaveChangesAsync().ConfigureAwait(false); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseStatusCodePages(); } // Enable static files as css and js app.UseStaticFiles(); // Allows the session system to auto associate requests with sessions when arriving from the client app.UseSession(); app.UseAuthentication(); // app.UseIdentity() will be removed app.UseMvc(routes => { //Improve routing for pagination //routes.MapRoute( // name: null, // template: "{category}/Page{productPage:int}", // defaults: new { Controller = "Product", action = "List" }); //routes.MapRoute( // name: null, // template: "Page{productPage:int}", // defaults: new { Controller = "Product", action = "List", productPage = 1 }); //routes.MapRoute( // name: null, // template: "{category}", // defaults: new { Controller = "Product", action = "List", productPage = 1 }); //routes.MapRoute( // name: null, // template: "", // defaults: new { Controller = "Product", action = "List", productPage = 1 }); //routes.MapRoute( // name: null, // template: "{controller}/{action}/{id?}"); routes.MapRoute( name: "default", template: "{controller=Product}/{action=List}/{id?}"); }); // Populate with product/ingredient SeedData.EnsurePopulated(app); new UserRoleSeed(app.ApplicationServices.GetService <RoleManager <IdentityRole> >()).Seed(); // Ensure admin user IdentitySeed.EnsurePopulated(app); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ApplicationDbContext db) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseDatabaseErrorPage(); } else { app.UseExceptionHandler("/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); endpoints.MapBlazorHub(); endpoints.MapFallbackToPage("/_Host"); }); SeedData.SeedDatabase(db); IdentitySeed.CreateAdminRoleAndAccount(app.ApplicationServices, Configuration); //IdentitySeed.EnsurePopulated(app); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ClubTreasurerContext context, RoleManager <AppRole> roleManager, UserManager <AppUser> userManager, IOptions <RCIConfig> rciConfig) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseDatabaseErrorPage(); } else { app.UseExceptionHandler("/Error"); app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseCookiePolicy(); app.UseAuthentication(); IdentitySeed.Initialize(context, userManager, rciConfig, roleManager, Configuration).Wait(); //TODO: Delete after deployment //if (env.IsDevelopment()) //{ // app.Use(async (httpContext, next) => // { // var user = httpContext.User.Identity.Name; // DeveloperLogin(httpContext).Wait(); // await next.Invoke(); // }); //} app.UseMvc(); }
/// <summary> /// Devuelve el schema de la columna en formato SQL. /// </summary> public string ToSql(Boolean sqlConstraint) { string sql = ""; sql += "[" + Name + "] "; if (!IsComputed) { if (this.IsUserDefinedType) sql += Type; else sql += "[" + Type + "]"; if (Type.Equals("binary") || Type.Equals("varbinary") || Type.Equals("varchar") || Type.Equals("char") || Type.Equals("nchar") || Type.Equals("nvarchar")) { if (Size == -1) sql += " (max)"; else { if (Type.Equals("nchar") || Type.Equals("nvarchar")) sql += " (" + (Size / 2).ToString(CultureInfo.InvariantCulture) + ")"; else sql += " (" + Size.ToString(CultureInfo.InvariantCulture) + ")"; } } if (Type.Equals("xml")) { if (!String.IsNullOrEmpty(XmlSchema)) { if (IsXmlDocument) sql += "(DOCUMENT " + XmlSchema + ")"; else sql += "(CONTENT " + XmlSchema + ")"; } } if (Type.Equals("numeric") || Type.Equals("decimal")) sql += " (" + Precision.ToString(CultureInfo.InvariantCulture) + "," + Scale.ToString(CultureInfo.InvariantCulture) + ")"; if (((Database)Parent.Parent).Info.Version >= DatabaseInfo.VersionTypeEnum.SQLServer2008) { if (Type.Equals("datetime2") || Type.Equals("datetimeoffset") || Type.Equals("time")) sql += "(" + Scale.ToString(CultureInfo.InvariantCulture) + ")"; } if ((!String.IsNullOrEmpty(Collation)) && (!IsUserDefinedType)) sql += " COLLATE " + Collation; if (IsIdentity) sql += " IDENTITY (" + IdentitySeed.ToString(CultureInfo.InvariantCulture) + "," + IdentityIncrement.ToString(CultureInfo.InvariantCulture) + ")"; if (IsIdentityForReplication) sql += " NOT FOR REPLICATION"; if (IsSparse) sql += " SPARSE"; if (IsFileStream) sql += " FILESTREAM"; if (IsNullable) sql += " NULL"; else sql += " NOT NULL"; if (IsRowGuid) sql += " ROWGUIDCOL"; } else { sql += "AS " + ComputedFormula; if (IsPersisted) sql += " PERSISTED"; } if ((sqlConstraint) && (DefaultConstraint != null)) { if (DefaultConstraint.Status != ObjectStatus.Drop) sql += " " + DefaultConstraint.ToSql().Replace("\t", "").Trim(); } return sql; }
public async static Task Main(string[] args) { var host = CreateHostBuilder(args).Build(); using (var scope = host.Services.CreateScope()) { var services = scope.ServiceProvider; var loggerFactory = services.GetRequiredService <ILoggerFactory>(); try { var context = services.GetRequiredService <ApplicationDbContext>(); var userManager = services.GetRequiredService <UserManager <ApplicationUser> >(); var roleManager = services.GetRequiredService <RoleManager <IdentityRole> >(); await IdentitySeed.SeedRolesAsync(userManager, roleManager); await IdentitySeed.SeedSuperAdminAsync(userManager, roleManager); await IdentitySeed.SeedBasicUserAsync(userManager, roleManager); } catch (Exception ex) { var logger = loggerFactory.CreateLogger <Program>(); logger.LogError(ex, "An error occurred seeding the DB."); } } host.Run(); }
public static async Task Main(string[] args) { var host = CreateHostBuilder(args).Build(); using (var scope = host.Services.CreateScope()) { var services = scope.ServiceProvider; var loggerFactory = services.GetRequiredService <ILoggerFactory>(); try { var context = services.GetRequiredService <StoreContext>(); var identityContext = services.GetRequiredService <AppIdentityDbContext>(); var userManager = services.GetRequiredService <UserManager <AppUser> >(); var roleManager = services.GetRequiredService <RoleManager <AppRole> >(); await context.Database.MigrateAsync(); await StoreContextSeed.SeedDeliveryMethods(context); await identityContext.Database.MigrateAsync(); await IdentitySeed.SeedUsers(userManager, roleManager); } catch (Exception ex) { var logger = loggerFactory.CreateLogger <Program>(); logger.LogError(ex, "An Error Occured during migration"); } } await host.RunAsync(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, UserManager <AppUser> userManager, RoleManager <AppRole> roleManager) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseRouting(); app.UseStaticFiles(); IdentitySeed.IdentityAdd(userManager, roleManager).Wait(); app.UseAuthentication(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( name: "areas", pattern: "{Area}/{Controller=Home}/{Action=Index}/{id?}" ); endpoints.MapControllerRoute( name: "default", pattern: "{Controller=Home}/{Action=Index}/{id?}" ); }); }
public void Initialize() { string file = PoolUtils.GenerateGenesisFile(); _filesCreated.Add(file); _pool = IndyDotNet.Pool.Factory.GetPool("AllCryptoTestsPool", file); _pool.Create(); _pool.Open(); WalletConfig config = new WalletConfig() { Id = "AllCryptoTestsWalletId" }; WalletCredentials credentials = new WalletCredentials() { Key = "8dvfYSt5d1taSd6yJdpjq4emkwsPDDLYxkNFysFD2cZY", KeyDerivationMethod = KeyDerivationMethod.RAW }; _wallet = IndyDotNet.Wallet.Factory.GetWallet(config, credentials); _wallet.Create(); _wallet.Open(); IdentitySeed seed = new IdentitySeed() { Seed = "00000000000000000000000000000My1" }; _senderDid = IndyDotNet.Did.Factory.CreateMyDid(_pool, _wallet, seed); }
public void UnpackPackedMessageWithMultipleRecipientsSucceeds() { ICrypto crypto = IndyDotNet.Crypto.Factory.GetCrypto(_wallet); List <IDid> recipients = new List <IDid>(); IdentitySeed seed = new IdentitySeed() { Seed = "00000000000000000000000000000My2" }; recipients.Add(IndyDotNet.Did.Factory.CreateMyDid(_pool, _wallet, seed)); seed = new IdentitySeed() { Seed = "00000000000000000000000000000My3" }; recipients.Add(IndyDotNet.Did.Factory.CreateMyDid(_pool, _wallet, seed)); PackedMessage packedMessage = crypto.PackMessage(recipients, _senderDid, MESSAGE_TO_SEND); UnpackedMessage unpackedMessage = crypto.UnpackMessage(packedMessage); Assert.IsNotNull(unpackedMessage, $"did not get back an unpacked message"); Assert.AreEqual(MESSAGE_TO_SEND, unpackedMessage.Message, "unpacked message is not the same as what was sent"); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, IdentitySeed identitySeed) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseDatabaseErrorPage(); } else { app.UseExceptionHandler("/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseCookiePolicy(); app.UseHealthChecks("/hc", new HealthCheckOptions() { Predicate = _ => true, ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse }); app.UseIdentityServer(); app.UseMvc(); identitySeed.SeedRolesAndUsers().Wait(); }
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerService logger, UserManager <ApplicationUser> userManager, RoleManager <IdentityRole> roleManager) { app.UseStatusCodePagesWithRedirects("/Error/{0}"); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler(logger); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( name: "default", pattern: "{controller=Home}/{action=Index}/{id?}"); }); IdentitySeed.Seed(userManager, roleManager).Wait(); }
public async Task <IActionResult> SeedDbAsync() { IdentitySeed seed = new IdentitySeed(); await seed.Seed(_userManager, _roleManager, _settings); return(null); }
private static async Task EnsureSeedData <TDbContext>(IServiceProvider services) where TDbContext : DbContext { using var scope = services.GetRequiredService <IServiceScopeFactory>().CreateScope(); //Identity Seed var userManager = scope.ServiceProvider.GetRequiredService <IUserManager>(); var roleManager = scope.ServiceProvider.GetRequiredService <IRoleManager>(); var usuarioDbContext = scope.ServiceProvider.GetRequiredService <TDbContext>(); await IdentitySeed.EnsureSeedData(usuarioDbContext, userManager, roleManager); }
public void CreateAndStoreDidWithSeedSuccessfully() { IdentitySeed seed = new IdentitySeed() { Seed = "00000000000000000000000000000My1" }; IDid did = IndyDotNet.Did.Factory.CreateMyDid(_pool, _wallet, seed); Assert.IsTrue(0 < did.Did.Length, $"Did was not set {did.Did}"); Assert.IsTrue(0 < did.VerKey.Length, $"VerKey was not set {did.VerKey}"); }
public void IdentitySeedSerializesCorrectly() { IdentitySeed seed = new IdentitySeed() { Seed = "1234567890" }; string json = seed.ToJson(); const string expected = @"{""cid"":false,""seed"":""1234567890""}"; Assert.AreEqual(expected, json, "IdentitySeed serialization didn't match"); }
public void IdentitySeedWithCryptoTypeSerializesCorrectly() { IdentitySeed seed = new IdentitySeed() { Seed = "1234567890", CryptoType = "ed25519" }; string json = seed.ToJson(); const string expected = @"{""cid"":false,""crypto_type"":""ed25519"",""seed"":""1234567890""}"; Assert.AreEqual(expected, json, "IdentitySeed serialization didn't match"); }
public void IdentitySeedWithDidSerializesCorrectly() { IdentitySeed seed = new IdentitySeed() { Seed = "1234567890", Did = "CnEDk9HrMnmiHXEV1WFgbVCRteYnPqsJwrTdcZaNhFVW" }; string json = seed.ToJson(); const string expected = @"{""cid"":false,""did"":""CnEDk9HrMnmiHXEV1WFgbVCRteYnPqsJwrTdcZaNhFVW"",""seed"":""1234567890""}"; Assert.AreEqual(expected, json, "IdentitySeed serialization didn't match"); }
public void GetMyDidAbbreviatedVerKeySuccessfully() { IdentitySeed seed = new IdentitySeed() { Seed = "00000000000000000000000000000My1", CID = true }; IDid did = IndyDotNet.Did.Factory.CreateMyDid(_pool, _wallet, seed); string abbreviated = did.GetAbbreviateVerkey(); Assert.IsTrue(0 < abbreviated.Length, $"abbreviated verkey was not returned {abbreviated}"); }
/// <summary> /// Devuelve el schema de la columna en formato SQL. /// </summary> public string ToSQL(Boolean sqlConstraint) { string sql = ""; sql += "\t[" + Name + "] "; if (!IsComputed) { sql += "[" + Type + "]"; if (Type.Equals("varbinary") || Type.Equals("varchar") || Type.Equals("char") || Type.Equals("nchar") || Type.Equals("nvarchar")) { sql += " (" + Size.ToString() + ")"; } if (Type.Equals("numeric") || Type.Equals("decimal")) { sql += " (" + Precision.ToString() + "," + Scale.ToString() + ")"; } if (!String.IsNullOrEmpty(Collation)) { sql += " COLLATE " + Collation; } if (Identity) { sql += " IDENTITY (" + IdentitySeed.ToString() + "," + IdentityIncrement.ToString() + ")"; } if (IdentityForReplication) { sql += " NOT FOR REPLICATION"; } if (Nullable) { sql += " NULL"; } else { sql += " NOT NULL"; } if (IsRowGuid) { sql += " ROWGUIDCOL"; } } else { sql += "AS " + computedFormula; } if ((sqlConstraint) && (constraints.Count > 0)) { sql += " " + constraints.ToSQL(); } return(sql); }
public void GetListOfDidsSuccessfully() { IdentitySeed seed = new IdentitySeed() { Seed = "00000000000000000000000000000My1" }; IDid did = IndyDotNet.Did.Factory.CreateMyDid(_pool, _wallet, seed); List <IDid> dids = IndyDotNet.Did.Factory.GetAllMyDids(_pool, _wallet); Assert.IsNotNull(dids, "list was empty"); Assert.IsTrue(0 < dids.Count, "Exptected to have more than 0 dids in list"); }
public override DbTypeBase ToGenericType() { DbTypeNumeric res = new DbTypeNumeric(); res.Precision = Precision; res.Scale = Scale; if (IsIdentity) { res.Autoincrement = true; res.SetSpecificAttribute("effiproz", "identity_increment", IdentityIncrement.ToString()); res.SetSpecificAttribute("effiproz", "identity_seed", IdentitySeed.ToString()); } return(res); }
public override DbTypeBase ToGenericType() { DbTypeInt res = new DbTypeInt(); res.Bytes = Bytes; res.Unsigned = false; if (IsIdentity) { res.Autoincrement = true; res.SetSpecificAttribute("effiproz", "identity_increment", IdentityIncrement.ToString()); res.SetSpecificAttribute("effiproz", "identity_seed", IdentitySeed.ToString()); } return(res); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); GlobalConfiguration.Configure(WebApiConfig.Register); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); OnlineCourseDb db = new OnlineCourseDb(); DataSeeder seed = new DataSeeder(db); GlobalConfiguration.Configuration.Formatters.Add(new FormMultipartEncodedMediaTypeFormatter(new MultipartFormatterSettings())); seed.SeedDefaultCountry(); seed.SeedLevels(); IdentitySeed.createRolesandUsers(); }
public void PackMessageToTwoRecipientsSucceeds() { IdentitySeed seed = new IdentitySeed() { Seed = "00000000000000000000000000000My2" }; ICrypto crypto = IndyDotNet.Crypto.Factory.GetCrypto(_wallet); List <IDid> recipients = new List <IDid>(); recipients.Add(_senderDid); recipients.Add(IndyDotNet.Did.Factory.CreateMyDid(_pool, _wallet, seed)); PackedMessage packedMessage = crypto.PackMessage(recipients, _senderDid, MESSAGE_TO_SEND); Assert.IsNotNull(packedMessage, "crypto.PackMessage failed to return PackMessage instance"); }
/** * dotnet ef migrations add InitialCreate --context SitPostgreSQLContext --output Data/Migrations/SitDb * dotnet ef migrations script --context SitPostgreSQLContext * * * Add-Migration SitDbInit -context SitPostgreSQLContext -output Data/Migrations/SitDb * Add-Migration EventSourcingDbInit -context EventStoreEventSourcingContext -output Data/Migrations/EventSourcingDb **/ private static async Task EnsureSeedData <TSitContext>(IServiceProvider services) where TSitContext : DbContext { using var scope = services.GetRequiredService <IServiceScopeFactory>().CreateScope(); //Administração Pessoa Seed. //var adminPessoaDbContext = scope.ServiceProvider.GetRequiredService<TSitContext>(); //await AdministracaoPessoaSeed.EnsureSeedData(adminPessoaDbContext); //Identity Seed // var userManager = scope.ServiceProvider.GetRequiredService<IUserManager>(); // var roleManager = scope.ServiceProvider.GetRequiredService<IRoleManager>(); // var dbContext = scope.ServiceProvider.GetRequiredService<TSitContext>(); await PermissionSeed.EnsureSeedData <TSitContext>(services); await IdentitySeed.EnsureSeedData <TSitContext>(services); await PessoaSeed.EnsureSeedData <TSitContext>(services); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, UserManager <IdentityUser> userManager) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseHsts(); } app.UseCors(builder => builder.WithOrigins("http://localhost:3000", "https://aplikacjakulinarna.azurewebsites.net", "http://aplikacjakulinarna.azurewebsites.net") .AllowAnyHeader() .AllowAnyMethod() .AllowCredentials()); app.UseAuthentication(); app.UseHttpsRedirection(); app.UseMvc(); IdentitySeed.SeedUser(userManager); }