// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddDbContext <CovidTestDbContext>(opt => opt.UseInMemoryDatabase("ItemDataBaseMemory") ); IoC.AddDependency(services); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new Microsoft.OpenApi.Models.OpenApiInfo { Title = "My API", Description = "Descripcion de la My API", Version = "V1" }); }); // Auto Mapper Configurations var mappingConfig = new MapperConfiguration(mc => { mc.AddProfile(new MappingProfile()); }); IMapper mapper = mappingConfig.CreateMapper(); services.AddSingleton(mapper); services.AddControllers(); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddMvc(); // Middleware Inyección de Dependencias IoC.AddDependency(services); // Autorización y políticas services.AddAuthorization(options => { options.DefaultPolicy = new AuthorizationPolicyBuilder(JwtBearerDefaults.AuthenticationScheme) .RequireAuthenticatedUser() .Build(); }); // Autenticación var issuer = Configuration["AuthenticationSettings:Issuer"]; var audience = Configuration["AuthenticationSettings:Audience"]; var singinKey = Configuration["AuthenticationSettings:SigninKey"]; services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) .AddJwtBearer(options => { options.Audience = audience; options.TokenValidationParameters = new TokenValidationParameters() { ValidateIssuer = true, ValidIssuer = issuer, ValidateIssuerSigningKey = true, ValidateLifetime = true, IssuerSigningKey = new SymmetricSecurityKey(Encoding.ASCII.GetBytes(singinKey)) }; }); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddControllers(); services.AddDbContext <WebAppContext>(options => options.UseInMemoryDatabase(databaseName: "DI_DB")); IoC.AddDependency(services); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { //configuración de EntitiFrameworkCore services.AddDbContext <ApplicationDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"))); services.AddControllers().AddNewtonsoftJson(options => options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore); IoC.AddDependency(services); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { //Configuración de Sql Server en memoria services.AddDbContext <WebApiDbContext>(options => options.UseInMemoryDatabase(databaseName: "Patterns_DB")); services.AddControllers(); // Inyección de los servicios IoC.AddDependency(services); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { //Configuración de Sql Server services.AddDbContext <WebApiDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection") .Replace("{{DB_ENDPOINT}}", Configuration.GetValue <string>("DB_ENDPOINT")))); services.AddControllers(); IoC.AddDependency(services); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddDbContext <DataContext>(opts => opts.UseSqlServer(Configuration.GetConnectionString("CnString"))); services.AddControllersWithViews(); IoC.AddDependency(services); // In production, the Angular files will be served from this directory services.AddSpaStaticFiles(configuration => { configuration.RootPath = "ClientApp/src"; }); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddDbContext <ApplicationDbContext>((serviceProvider, options) => { options.UseMySql(Configuration.GetConnectionString("DefaultConnection")); }, ServiceLifetime.Transient); /** * con ideityserver */ services.AddDefaultIdentity <ApplicationUser>(options => { options.SignIn.RequireConfirmedAccount = false; }) .AddEntityFrameworkStores <ApplicationDbContext>(); /*con identitiserver*/ services.AddIdentityServer(options => { options.UserInteraction.LoginUrl = "/login"; //options.UserInteraction.LogoutUrl = "/logout"; }) .AddApiAuthorization <ApplicationUser, ApplicationDbContext>(); services.AddAuthentication() .AddIdentityServerJwt(); services.AddControllersWithViews(); services.AddRazorPages(); services.AddSignalR(); // In production, the React files will be served from this directory services.AddSpaStaticFiles(configuration => { configuration.RootPath = "ClientApp/build"; }); //Poder hacer peticiones desde dominio externo services.Configure <CookiePolicyOptions>(options => { options.CheckConsentNeeded = context => true; options.MinimumSameSitePolicy = Microsoft.AspNetCore.Http.SameSiteMode.None; }); //Inyeccion de dependencias MarianaoWars IoC.AddDependency(services); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddCors(options => { options.AddDefaultPolicy( builder => { builder.AllowAnyOrigin() .AllowAnyMethod() .AllowAnyHeader(); }); }); services.AddControllers(); IoC.AddDependency(services); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { // Configuración de Sql Server en memoria services.AddDbContext <SecurityContext>(options => options.UseInMemoryDatabase(databaseName: "Security_DB")); services.Configure <CookiePolicyOptions>(options => { // This lambda determines whether user consent for non-essential cookies is needed for a given request. options.CheckConsentNeeded = context => true; options.MinimumSameSitePolicy = SameSiteMode.None; }); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); services.AddAntiforgery(o => o.HeaderName = "HSRF-TOKEN"); // Middleware Inyección de Dependencias IoC.AddDependency(services); services.AddDistributedMemoryCache(); // Adds a default in-memory implementation of IDistributedCache services.AddSession( options => { options.IdleTimeout = TimeSpan.FromMinutes(10); }); services.AddAuthentication(options => { options.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme; options.DefaultChallengeScheme = CookieAuthenticationDefaults.AuthenticationScheme; }).AddCookie(options => { options.LoginPath = "/Login"; }); services.AddAuthorization(); // Agregar Antifogery-Token (XSRF / CSRF) services.AddAntiforgery(options => { // Set Cookie properties using CookieBuilder properties†. options.FormFieldName = "AntiforgeryFieldname"; options.HeaderName = "X-CSRF-TOKEN-HEADERNAME"; options.SuppressXFrameOptionsHeader = false; }); }
// This method gets called by the runtime. Use this method to add services to the container. // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 public void ConfigureServices(IServiceCollection services) { services.AddDbContext <PermisosDBContext>(); services.AddCors(); services.AddControllers(); services.Configure <IISServerOptions>(options => { options.AutomaticAuthentication = false; }); services.Configure <IISOptions>(options => { options.ForwardClientCertificate = false; }); IoC.AddDependency(services); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { //Registramos el DbContext services.AddDbContext <PruebaDbContext>( options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")) ); services.Configure <AmqpInfo>(Configuration.GetSection("amqp")); services.AddSingleton <AmqpService>(); IoC.AddDependency(services); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); services.AddCronJob <ExpiredItemsCronJobService>(c => { c.CronExpression = CronJobs.CON_EXPRESSION_REMOVE_ITEM; c.TimeZoneInfo = TimeZoneInfo.Local; }); }
public void ConfigureServices(IServiceCollection services) { var sqlConnectionString = Configuration.GetConnectionString("DefaultConnection"); services.AddDbContext <DataContext>(options => options.UseMySql(sqlConnectionString) ); services.Configure <SmtpSettings>(Configuration.GetSection("SmtpSettings")); IoC.AddDependency(services); services.AddAutoMapper(typeof(Startup)); services.Configure <CookiePolicyOptions>(options => { // This lambda determines whether user consent for non-essential cookies is needed for a given request. options.CheckConsentNeeded = context => true; options.MinimumSameSitePolicy = SameSiteMode.None; }); services.AddDistributedMemoryCache(); services.AddSession(opt => { opt.IdleTimeout = TimeSpan.FromMinutes(30); opt.Cookie.HttpOnly = true; opt.Cookie.IsEssential = true; }); var mvcBuilder = services.AddControllersWithViews(); if (Env.IsDevelopment()) { mvcBuilder.AddRazorRuntimeCompilation(); } }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddCors(options => { options.AddDefaultPolicy(builder => { builder.WithOrigins("http://luxurybuildingapp.com:1010", "http://localhost:4200") .AllowAnyMethod() .AllowAnyHeader(); }); }); // Conección con la Base de datos services.AddDbContext <ApplicationDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("defaultConnection")) .UseLazyLoadingProxies()); services.AddIdentity <ApplicationUser, IdentityRole>() .AddEntityFrameworkStores <ApplicationDbContext>() .AddDefaultTokenProviders() .AddErrorDescriber <MyErrorDescriber>(); services.Configure <IdentityOptions>(options => { // Password settings. options.Password.RequireDigit = true; options.Password.RequireLowercase = true; options.Password.RequireNonAlphanumeric = true; options.Password.RequireUppercase = true; options.Password.RequiredLength = 6; options.Password.RequiredUniqueChars = 1; }); services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) .AddJwtBearer(options => options.TokenValidationParameters = new TokenValidationParameters { ValidateIssuer = false, ValidateAudience = false, ValidateLifetime = true, ValidateIssuerSigningKey = true, IssuerSigningKey = new SymmetricSecurityKey( Encoding.UTF8.GetBytes(Configuration["jwt:key"])), ClockSkew = TimeSpan.Zero }); // Inyeccion de los servicios //services.AddAutoMapper(typeof(Startup)); services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies()); IoC.AddDependency(services); services.AddControllersWithViews() .AddNewtonsoftJson(options => options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore ); services.AddControllers(); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo { Title = "GrupoShemesh.Api", Version = "v1" }); }); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { //services.AddDbContext<SecurityContext>(options => // options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection") // .Replace("{{DB_ENDPOINT}}", Configuration.GetValue<string>("DB_ENDPOINT")))); //var contexto = services.BuildServiceProvider().GetRequiredService<SecurityContext>(); //if (Configuration.GetValue<bool>("DB_MIGRATE") == true) //{ // contexto.Database.Migrate(); //} //if (Configuration.GetValue<bool>("DB_INITIALIZE") == true) //{ // DbInit.Initialize(contexto); //} //Configuración de Sql Server en memoria services.AddDbContext <SecurityContext>(options => options.UseInMemoryDatabase(databaseName: "Security_DB")); services.Configure <CookiePolicyOptions>(options => { // This lambda determines whether user consent for non-essential cookies is needed for a given request. options.CheckConsentNeeded = context => true; options.MinimumSameSitePolicy = SameSiteMode.None; }); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); services.AddAntiforgery(o => o.HeaderName = "HSRF-TOKEN"); // Middleware Inyección de Dependencias IoC.AddDependency(services); services.AddDistributedMemoryCache(); // Adds a default in-memory implementation of IDistributedCache services.AddSession( options => { options.IdleTimeout = TimeSpan.FromMinutes(10); }); services.AddAuthentication(options => { options.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme; options.DefaultChallengeScheme = CookieAuthenticationDefaults.AuthenticationScheme; }).AddCookie(options => { options.LoginPath = "/Login"; }); services.AddAuthorization(); // Agregar Antifogery-Token (XSRF / CSRF) services.AddAntiforgery(options => { // Set Cookie properties using CookieBuilder properties†. options.FormFieldName = "AntiforgeryFieldname"; options.HeaderName = "X-CSRF-TOKEN-HEADERNAME"; options.SuppressXFrameOptionsHeader = false; }); //services.AddDefaultIdentity<ApplicationUser>() // .AddRoles<IdentityRole>() // .AddDefaultUI(UIFramework.Bootstrap4) // .AddEntityFrameworkStores<SecurityContext>(); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddDbContext <ApplicationDBContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"))); services.AddControllers(); //.AddNewtonsoftJson(options => options.SerializerSettings.ContractResolver = new DefaultContractResolver()); services.AddAuthentication(options => { options.DefaultScheme = IdentityServerAuthenticationDefaults.AuthenticationScheme; options.DefaultAuthenticateScheme = IdentityServerAuthenticationDefaults.AuthenticationScheme; options.DefaultChallengeScheme = IdentityServerAuthenticationDefaults.AuthenticationScheme; options.DefaultSignInScheme = IdentityServerAuthenticationDefaults.AuthenticationScheme; options.DefaultForbidScheme = IdentityServerAuthenticationDefaults.AuthenticationScheme; }) .AddIdentityServerAuthentication(options => { options.Authority = "http://*****:*****@gmail.com" } }); //var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.XML"; //var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile); //c.IncludeXmlComments(xmlPath); }); IoC.AddDependency(services); // Add framework services. }