public void ConfigureServices(IServiceCollection services) { try { component.helper.SolutionConfiguration.Init(HostEnvironment.WebRootPath); services.AddCorsMiddleware(Configuration); services.AddMvcCore().AddNewtonsoftJson(); services.AddMvc(config => { config.Filters.Add(new ActionFilterAttribute()); }); services.AddAuthentication(Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerDefaults.AuthenticationScheme).AddJwtBearer(options => { options.TokenValidationParameters = new Microsoft.IdentityModel.Tokens.TokenValidationParameters { ValidateIssuer = true, ValidateAudience = true, ValidateLifetime = true, ValidateIssuerSigningKey = true, ValidIssuer = component.helper.SolutionConfiguration.Configuration.Token.Issuer.ToLower(), ValidAudience = component.helper.SolutionConfiguration.Configuration.Token.Audience.ToLower(), IssuerSigningKey = new Microsoft.IdentityModel.Tokens.SymmetricSecurityKey(System.Text.Encoding.UTF8.GetBytes(component.helper.SolutionConfiguration.Configuration.Token.SecurityKey)) }; }); Mapper.Configuration.Initialize(); SwaggerExtension.ConfigureService(services, Configuration); ConfigureServicesCollection(services); ConfigureMessaging(services); services.AddControllers(); component.helper.DependencyResolver.Init(services); } catch (Exception ex) { LogStartupError(services, ex); } }
public void ConfigureServices(IServiceCollection services) { try { component.helper.SolutionConfiguration.Init(HostEnvironment.WebRootPath); services.AddCorsMiddleware(Configuration); services.AddMvcCore().AddNewtonsoftJson(); services.AddMvc(config => { config.Filters.Add(new ActionFilterAttribute()); }); services.Configure <ApiBehaviorOptions>(options => { options.SuppressModelStateInvalidFilter = true; }); services.AddAuthentication(IdentityServerAuthenticationDefaults.AuthenticationScheme).AddIdentityServerAuthentication("CompanyUser", o => { o.Authority = component.helper.SolutionConfiguration.Configuration.Token.Authority; o.ApiName = component.helper.SolutionConfiguration.Configuration.Token.ApiName; o.ApiSecret = component.helper.SolutionConfiguration.Configuration.Token.ApiSecret; o.EnableCaching = component.helper.SolutionConfiguration.Configuration.Token.EnableCaching; o.CacheDuration = TimeSpan.FromMinutes(component.helper.SolutionConfiguration.Configuration.Token.CacheDurationMinutes); o.RequireHttpsMetadata = component.helper.SolutionConfiguration.Configuration.Token.RequireHttpsMetadata; }); services.AddAuthentication(Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerDefaults.AuthenticationScheme).AddJwtBearer("Mobile", options => { options.TokenValidationParameters = new Microsoft.IdentityModel.Tokens.TokenValidationParameters { ValidateIssuer = true, ValidateAudience = true, ValidateLifetime = true, ValidateIssuerSigningKey = true, ValidIssuer = component.helper.SolutionConfiguration.Configuration.Token.Issuer.ToLower(), ValidAudience = component.helper.SolutionConfiguration.Configuration.Token.Audience.ToLower(), IssuerSigningKey = new Microsoft.IdentityModel.Tokens.SymmetricSecurityKey(System.Text.Encoding.UTF8.GetBytes(component.helper.SolutionConfiguration.Configuration.Token.SecurityKey)) }; }); services.AddAuthentication(Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerDefaults.AuthenticationScheme).AddJwtBearer("Admin", options => { options.TokenValidationParameters = new Microsoft.IdentityModel.Tokens.TokenValidationParameters { ValidateIssuer = true, ValidateAudience = true, ValidateLifetime = true, ValidateIssuerSigningKey = true, ValidIssuer = component.helper.SolutionConfiguration.Configuration.Token.Issuer.ToLower(), ValidAudience = component.helper.SolutionConfiguration.Configuration.Token.Audience.ToLower(), IssuerSigningKey = new Microsoft.IdentityModel.Tokens.SymmetricSecurityKey(System.Text.Encoding.UTF8.GetBytes(component.helper.SolutionConfiguration.Configuration.Token.SecurityKey)) }; }); Mapper.Configuration.Initialize(); SwaggerExtension.ConfigureService(services, Configuration); ConfigureServicesCollection(services); ConfigureMessaging(services); services.AddControllers(); ConfigureHangfireSettings(services); component.helper.DependencyResolver.Init(services); } catch (Exception ex) { LogStartupError(services, ex); } }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { try { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseCorsMiddleware(); SwaggerExtension.Configure(app); app.UseStaticFiles(); app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); app.UseHeaderkeyAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); } catch (Exception ex) { var log = app.ApplicationServices.GetService <component.services.loghandler.Logger>(); if (log != null) { log.FatalLog(ex.ToString(), ex); } } }
// 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(); } //app.UseHttpsRedirection(); app.UseRouting(); AuthenticationExtension.Configure(app); CorsExtension.Configure(app); app.UseStaticFiles(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); SwaggerExtension.Configure(app); SignalRExtension.Configure(app); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddOptions(); CorsExtensions.Add(services, Configuration); SwaggerExtension.Add(services); BLL.Configuration.Add(services); services.AddControllers(); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { DependencyInjectionExtension.ConfigureService(services); CorsExtension.ConfigureService(services); AuthenticationExtension.ConfigureService(services); MediatRExtension.ConfigureService(services); SwaggerExtension.ConfigureService(services); ControllersExtension.ConfigureService(services); SignalRExtension.ConfigureService(services); }
public void ConfigureServices(IServiceCollection services) { services.AddControllers(); var repositoriesInitializer = new RepositoriesInitializer(); repositoriesInitializer.InitializeRepositories(services); var initializer = new Initializer(); initializer.Initialize(services, Configuration.GetConnectionString("DefaultConnection")); services.AddTransient <IJwtHelper, JwtHelper>(); JwtExtensions.AddJwt(services, Configuration); CorsExtensions.Add(services, Configuration); SwaggerExtension.Add(services, Configuration); services.AddMvcCore().AddApiExplorer(); }
public void Configure(IApplicationBuilder app, DataBaseInitialization dataBaseInitialization) { dataBaseInitialization.InitializeAll(); app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseCors(CorsConstants.OriginPolicy); app.UseRouting(); app.UseSwagger(); SwaggerExtension.Use(app, Configuration); app.UseAuthentication(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); app.UseMiddleware <LoggerMiddleware>(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IServiceProvider serviceProvider) { try { GlobalConfiguration.Configuration .UseActivator(new HangfireActivator(serviceProvider)); app.UseHangfireServer(new BackgroundJobServerOptions { WorkerCount = Environment.ProcessorCount }); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseCorsMiddleware(); SwaggerExtension.Configure(app); app.UseStaticFiles(); app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); app.UseHeaderkeyAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); if (Convert.ToBoolean(component.helper.SolutionConfiguration.Configuration.HangFire.Enabled.ToString())) { StartHangFireBackgroundJobs(); } } catch (Exception ex) { var log = app.ApplicationServices.GetService <component.services.loghandler.Logger>(); if (log != null) { log.FatalLog(ex.ToString(), ex); } } }