// This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     IocRegister.AddRegistration(services, Configuration);
     SwaggerConfig.AddRegistration(services);
     CorsConfig.AddCorsOptions(services);
     services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
 }
示例#2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            // Data Contexts
            services.AddScoped <ISecurityDbContext, SecurityDbContext>();
            services.AddDbContext <SecurityDbContext>(option => option.UseSqlServer(Configuration.GetConnectionString("CoreSecurityDB")));

            // MVC Version
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);

            // Add Sessions
            services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>();

            // Injection Dependences
            IoCRegister.AddRegistration(services);

            // Swagger
            SwaggerConfig.AddRegistration(services);

            // Enable Cors
            services.AddCors(options =>
            {
                options.AddPolicy("CorsPolicy",
                                  builder => builder.AllowAnyOrigin()
                                  .AllowAnyMethod()
                                  .AllowAnyHeader()
                                  .AllowCredentials()
                                  );
            });
        }
示例#3
0
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/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();

            // SWAGGER POR FUERA
            SwaggerConfig.AddRegistration(app);

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller=Home}/{action=Index}/{id?}");
                endpoints.MapRazorPages();
            });
        }
示例#4
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            var key = Encoding.ASCII.GetBytes(Configuration.GetValue <string>("JWT:SecretKey"));

            services.AddDbContext <ApplicationDbContext>(options =>
                                                         options.UseSqlServer(Configuration["ConnectionStrings:DefaultConnection"]));

            services.AddDefaultIdentity <IdentityUser>(options => options.SignIn.RequireConfirmedAccount = true)
            .AddEntityFrameworkStores <ApplicationDbContext>();
            services.AddControllersWithViews();
            services.AddRazorPages();

            SwaggerConfig.AddRegistration(services);

            services.AddAuthentication(x =>
            {
                x.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
                x.DefaultChallengeScheme    = JwtBearerDefaults.AuthenticationScheme;
            }).AddJwtBearer(x =>
            {
                x.RequireHttpsMetadata      = false;
                x.SaveToken                 = true;
                x.TokenValidationParameters = new TokenValidationParameters
                {
                    ValidateIssuerSigningKey = true,
                    IssuerSigningKey         = new SymmetricSecurityKey(key),
                    ValidateIssuer           = false,
                    ValidateAudience         = false
                };
            });

            services.AddMvc();

            services.AddSession();
        }
示例#5
0
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     services.AddControllers();
     services.AddTransient <IOrderRepository, OrderRepository>();
     services.AddMvc();
     SwaggerConfig.AddRegistration(services);
 }
示例#6
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            // Enable middleware to serve generated Swagger as a JSON endpoint.
            //app.UseSwagger();
            // Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.),
            // specifying the Swagger JSON endpoint.
            //app.UseSwaggerUI(conf =>
            //{
            //    conf.SwaggerEndpoint("/swagger/V1/swagger.json", "Api MLC");
            //});
            SwaggerConfig.AddRegistration(app);

            app.UseCors(option =>
            {
                option.AllowAnyHeader();
                option.AllowAnyMethod();
                option.AllowAnyOrigin();
            });

            app.UseHttpsRedirection();

            app.UseRouting();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });
        }
示例#7
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddDbContext <MovieService_DBContext>(item =>
                                                           item.UseSqlServer(Configuration.GetConnectionString("MovieServiceDBConnection")));
            services.AddScoped <ICategoryRepository, CategoryRepository>();
            services.AddScoped <IMovieRepository, MovieRepository>();
            services.AddScoped <IUserRepository, UserRepository>();
            services.AddScoped <ILoginRepository, LoginRepository>();


            services.AddCors(options =>
            {
                options.AddPolicy("CorsPolicy", builder => builder.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader().AllowCredentials().Build());
            });

            services.AddControllers();

            services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme).AddJwtBearer(options =>
            {
                options.TokenValidationParameters = new TokenValidationParameters
                {
                    ValidateIssuer           = true,
                    ValidateAudience         = true,
                    ValidateLifetime         = true,
                    ValidateIssuerSigningKey = true,
                    ValidIssuer      = Configuration["Jwt:Issuer"],
                    ValidAudience    = Configuration["Jwt:Issuer"],
                    IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(Configuration["Jwt:Key"]))
                };
            });

            SwaggerConfig.AddRegistration(services);
            services.AddMvc();
        }
示例#8
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();
            SwaggerConfig.AddRegistration(services);

            services.AddDbContext <WebApiElipgoContext>(options =>
                                                        options.UseSqlServer(Configuration["ConnectionStrings:DefaultConnection"]));
        }
示例#9
0
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     //services.AddDbContext<ConcesionarioContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
     services.AddDbContext <ConcesionarioContext>(options =>
                                                  options.UseSqlServer(Configuration.GetConnectionString("BloggingDatabase")));
     services.AddControllers();
     IoCRegister.AddRegistration(services);
     SwaggerConfig.AddRegistration(services);
 }
示例#10
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddScoped <IManagementUserDBContext, ManagementUserDBContext>();
            services.AddDbContext <ManagementUserDBContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DataBaseConnection")));

            IoCRegister.AddRegistration(services);
            SwaggerConfig.AddRegistration(services);
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
        }
示例#11
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            IoTRegister.AddRegistration(services);
            SwaggerConfig.AddRegistration(services);
            services.AddDbContext <CoworkingDbContext>(option => option.UseSqlServer(Configuration.GetConnectionString("DatabaseConnection")));


            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
        }
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddDbContext <ProyectDBContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));

            IoCRegister.AddRegistration(services);
            SwaggerConfig.AddRegistration(services);
            //services.AddMvc();//Controllers();
            services.AddControllers();
        }
示例#13
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddScoped <ICoworkingDBContext, CoworkingDBContext>();
            services.AddDbContext <CoworkingDBContext>(
                options => options.UseSqlServer(Configuration.GetConnectionString("DataBaseConnection")));

            services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies());
            IoCRegister.AddRegistration(services);
            SwaggerConfig.AddRegistration(services);
            services.AddControllers();
        }
示例#14
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddSingleton <ISodimacDBManager, SodimacDBManager>();
            services.AddHttpClient <IApiCaller, ApiCaller>();
            services.AddTransient <IOrdenCompraRepository, OrdenCompraRepository>();
            services.AddTransient <IOrdenCompraService, OrdenCompraService>();

            services.AddControllers();

            SwaggerConfig.AddRegistration(services);
            services.Configure <ApiConfig>(Configuration.GetSection("ApiConfig"));
        }
示例#15
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddDbContext <SportCenterDBContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DataBaseConnection")));

            SwaggerConfig.AddRegistration(services);
            IoCConfig.AddRegistration(services);

            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);

            // Configure the authentication
            services.AddAuthentication("BasicAuthentication")
            .AddScheme <AuthenticationSchemeOptions, BasicAuthenticationHandler>("BasicAuthentication", null);
        }
示例#16
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            SwaggerConfig.AddRegistration(app);

            app.UseEjemploMiddleware();
            app.UseLogApplicationInsights();

            app.UseAuthentication();

            app.UseMvc();
        }
示例#17
0
 // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
 public void Configure(IApplicationBuilder app, IHostingEnvironment env)
 {
     if (env.IsDevelopment())
     {
         app.UseDeveloperExceptionPage();
     }
     else
     {
         app.UseHsts();
     }
     app.UseHttpsRedirection();
     app.UseCors("AllowSpecificOrigins");
     app.UseAuthentication();
     SwaggerConfig.AddRegistration(app);
     app.UseMvc();
 }
示例#18
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }
            SwaggerConfig.AddRegistration(app);

            app.UseHttpsRedirection();
            app.UseMvc();
        }
示例#19
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory)
        {
            //Configure logs

            //loggerFactory.AddAzureWebAppDiagnostics();
            //loggerFactory.AddApplicationInsights(app.ApplicationServices, LogLevel.Trace);

            var pathBase = Configuration["PATH_BASE"];

            if (!string.IsNullOrEmpty(pathBase))
            {
                loggerFactory.CreateLogger <Startup>().LogDebug("Using PATH BASE '{pathBase}'", pathBase);
                app.UsePathBase(pathBase);
            }

            SwaggerConfig.AddRegistration(app);

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseCors("CorsPolicy");

            //app.UseHttpsRedirection();

            app.UseRouting();

            //app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapDefaultControllerRoute();
                endpoints.MapControllers();
                endpoints.MapHealthChecks("/hc", new HealthCheckOptions()
                {
                    Predicate      = _ => true,
                    ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse
                });
                endpoints.MapHealthChecks("/liveness", new HealthCheckOptions
                {
                    Predicate = r => r.Name.Contains("self")
                });
            });

            ConfigureEventBus(app);
        }
示例#20
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddSingleton <IApiCaller, ApiCaller>();

            services.AddCors(options =>
            {
                options.AddPolicy("CorsPolicy",
                                  builder => builder
                                  .AllowAnyOrigin()
                                  .AllowAnyMethod()
                                  .AllowAnyHeader());
            });

            services.AddControllers();

            SwaggerConfig.AddRegistration(services);
            services.Configure <ApiConfig>(Configuration.GetSection("ApiConfig"));
        }
示例#21
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            SwaggerConfig.AddRegistration(app);
            app.UseHttpsRedirection();

            app.UseRouting();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });
        }
示例#22
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);

            // Swagger
            SwaggerConfig.AddRegistration(services);

            // AutoMapper
            AutoMapperConfig.AddRegistration(services);

            // Inject Dependecies
            IoCRegister.AddRegistration(services);

            // JWT
            JwtAuthConfig.AddRegistration(services, _configuration);

            // Cors
            CorsConfig.AddRegistration(services);
        }
示例#23
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddCors();

            services.AddTransient <IImagePickDbContext, ImagePickDbContext>();
            services.AddDbContext <ImagePickDbContext>(options =>
                                                       options.UseSqlite(Configuration.GetConnectionString("DefaultConnection")));

            IdentityConfig.CreateIdentityIfNotCreated(services);

            AuthenticationConfig.ConfigureAuthenticationSettings(services, Configuration);

            IoCRegister.AddRegistration(services);

            SwaggerConfig.AddRegistration(services);

            services.AddControllers(options => options.RespectBrowserAcceptHeader = true)
            .AddNewtonsoftJson();
        }
示例#24
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            // Enable Cors
            app.UseCors("CorsPolicy");

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseHsts();
            }

            // Swagger
            SwaggerConfig.AddRegistration(app);

            app.UseHttpsRedirection();
            app.UseMvc();
        }
示例#25
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddTransient <ICoworkingDBContext, CoworkingDBContext>();
            IoCRegister.AddRegistration(services);

            services.AddDbContext <CoworkingDBContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DataBaseConnection")));
            services.AddApplicationInsightsTelemetry(Configuration);

            SwaggerConfig.AddRegistration(services);

            services.AddAuthentication("Bearer")
            .AddIdentityServerAuthentication(options =>
            {
                options.Authority            = "https://coworkingidentity.azurewebsites.net/";
                options.RequireHttpsMetadata = false;
                options.ApiName = "api1";
            });

            services.AddMvc();
        }
示例#26
0
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseHttpsRedirection();

            app.UseRouting();
            app.UseAuthentication();
            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });

            SwaggerConfig.AddRegistration(app);
            loggerFactory.AddFile("Logs/MovieServiceLog.txt");
        }
示例#27
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            services.AddSingleton <ISodimacDBManager, SodimacDBManager>();
            services.AddSingleton <IApiCaller, ApiCaller>();
            services.AddTransient <IASNVerifyRepository, ASNVerifyRepository>();
            services.AddTransient <IASNVerifyService, ASNVerifyService>();

            services.AddCustomMVC(Configuration)
            .AddCustomDbContext(Configuration)
            .AddCustomOptions(Configuration)
            .AddIntegrationServices(Configuration)
            .AddEventBus(Configuration)
            .AddCustomHealthCheck(Configuration);

            SwaggerConfig.AddRegistration(services);
            services.Configure <ApiConfig>(Configuration.GetSection("ApiConfig"));

            var container = new ContainerBuilder();

            container.Populate(services);

            return(new AutofacServiceProvider(container.Build()));
        }
示例#28
0
        // 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(policy =>
                                         policy.AllowAnyOrigin()
                                         .AllowAnyHeader()
                                         .AllowAnyMethod());
            });

            services.AddDbContext <ApplicationDbContext>(
                opts => opts.UseSqlServer(
                    Configuration.GetConnectionString("DataBaseConnection"),
                    x => x.MigrationsHistoryTable("__EFMigrationsHistory")
                    )
                );

            SwaggerConfig.AddRegistration(services);

            services.AddMediatR(Assembly.Load("MinInt.ModuloWeb.Personas.EventHandlers"));
            services.AddMediatR(Assembly.Load("MinInt.ModuloWeb.Personas.Queries"));

            services.AddAutoMapper(Assembly.Load("MinInt.ModuloWeb.Personas.Queries"));

            //var httpClientHandler = new HttpClientHandler
            //{
            //    ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator
            //};

            //services.AddGrpcClient<Mailer.MailerClient>(c => c.Address = new Uri(Configuration["EmailsServiceEndpoint"]))
            //    .ConfigureChannel(opt => opt.HttpClient = new HttpClient(httpClientHandler));

            services.Configure <UrlsConfig>(Configuration);

            services.AddControllers()
            .AddJsonOptions(opt => opt.JsonSerializerOptions.PropertyNamingPolicy = null);
        }
示例#29
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseHsts();
            }
            // Swagger
            SwaggerConfig.AddRegistration(app);

            // JWT
            JwtAuthConfig.AddRegistration(app, this._configuration);

            // Cors
            CorsConfig.AddRegistration(app);

            app.UseHttpsRedirection();
            app.UseAuthentication();
            app.UseHttpsRedirection();
            app.UseMvc();
        }
示例#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)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseHsts();
            }
            // Enable Cors
            app.UseCors("CorsPolicy");  // CorsPolicy

            ////Add User session
            //app.UseSession();

            ////Add JWToken to all incoming HTTP Request Header
            //app.Use(async (context, next) =>
            //{
            //    var JWToken = context.Session.GetString("JWToken");
            //    if (!string.IsNullOrEmpty(JWToken))
            //    {
            //        context.Request.Headers.Add("Authorization", "Bearer " + JWToken);
            //    }
            //    await next();
            //});

            // JWT
            app.UseAuthentication();

            // Swagger
            SwaggerConfig.AddRegistration(app);

            app.UseHttpsRedirection();
            app.UseMvc();
        }