예제 #1
0
        // 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"));
        }
예제 #2
0
        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();
        }
예제 #3
0
        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();
        }
예제 #4
0
        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);
        }
예제 #5
0
        // 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);
        }
예제 #7
0
        // 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();
        }
예제 #8
0
 /// <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;
 }
예제 #9
0
        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();
        }
예제 #10
0
        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();
        }
예제 #11
0
        // 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?}"

                    );
            });
        }
예제 #12
0
        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);
        }
예제 #13
0
        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");
        }
예제 #14
0
        // 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();
        }
예제 #15
0
        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();
        }
예제 #16
0
        public async Task <IActionResult> SeedDbAsync()
        {
            IdentitySeed seed = new IdentitySeed();

            await seed.Seed(_userManager, _roleManager, _settings);

            return(null);
        }
예제 #17
0
        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);
        }
예제 #18
0
        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}");
        }
예제 #19
0
        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");
        }
예제 #20
0
        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");
        }
예제 #21
0
        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");
        }
예제 #22
0
        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}");
        }
예제 #23
0
        /// <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);
        }
예제 #24
0
        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");
        }
예제 #25
0
        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);
        }
예제 #26
0
        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);
        }
예제 #27
0
        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();
        }
예제 #28
0
        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");
        }
예제 #29
0
        /**
         * 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);
        }
예제 #30
0
 // 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);
 }