// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, CampDbInitializer seeder, CampIdentityInitializer identitySeeder, ILoggerFactory loggerFactory) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseIdentity(); //Token based authentication app.UseAuthentication(); app.UseMvcWithDefaultRoute(); app.UseMvc(config => { }); seeder.Seed().Wait(); identitySeeder.Seed().Wait(); loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); }
// 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, CampDbInitializer seeder, CampIdentityInitializer identitySeeder) { loggerFactory.AddConsole(_config.GetSection("Logging")); loggerFactory.AddDebug(); app.UseIdentity(); // here we are using the Identity service. note: this must be before UseMvc // use the middleware for security tokens app.UseJwtBearerAuthentication(new JwtBearerOptions() { AutomaticAuthenticate = true, AutomaticChallenge = true, TokenValidationParameters = new TokenValidationParameters() { ValidIssuer = _config["Tokens:Issuer"], ValidAudience = _config["Tokens:Audience"], ValidateIssuerSigningKey = true, IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_config["Tokens:Key"])), ValidateLifetime = true } }); app.UseMvc(); seeder.Seed().Wait(); identitySeeder.Seed().Wait(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, CampDbInitializer seeder, CampIdentityInitializer identitySeeder, ILoggerFactory loggerFactory) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseIdentity(); app.UseMvc(config => { //config.MapRoute("MainAPIRoute","api/{controller}/{action}"); }); //app.UseCors(cfg => { // cfg.AllowAnyHeader() // .AllowAnyMethod() // .AllowAnyOrigin(); //}); //_env = env; //app.UseMvc(); seeder.Seed().Wait(); identitySeeder.Seed().Wait(); loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); }
// 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, CampDbInitializer seeder, CampIdentityInitializer identitySeeder) { loggerFactory.AddConsole(_configuration.GetSection("Logging")); loggerFactory.AddDebug(); //app.UseCors(cfg => //{ // cfg.AllowAnyHeader(); // cfg.AllowAnyMethod(); // cfg.AllowAnyOrigin(); //}); app.UseIdentity(); app.UseJwtBearerAuthentication(new JwtBearerOptions { AutomaticAuthenticate = true, AutomaticChallenge = true, TokenValidationParameters = new TokenValidationParameters { ValidIssuer = _configuration["Tokens:Issuer"], ValidAudience = _configuration["Tokens:Audience"], ValidateIssuerSigningKey = true, IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_configuration["Tokens:Key"])), ValidateLifetime = true } }); app.UseMvc(); seeder.Seed().Wait(); identitySeeder.Seed().Wait(); }
// 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, CampDbInitializer seeder, CampIdentityInitializer identitySeeder) { loggerFactory.AddConsole(_config.GetSection("Logging")); loggerFactory.AddDebug(); //app.UseCors(cfg => //{ // cfg.AllowAnyHeader() // .AllowAnyMethod() // .WithOrigins("http://wildermuth.com"); //}); app.UseIdentity(); app.UseMvc(config => { //config.MapRoute("MainAPIRoute", "api/{controller}/{action}"); }); seeder.Seed().Wait(); identitySeeder.Seed().Wait(); }
// 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, CampDbInitializer seeder, CampIdentityInitializer identitySeeder) { loggerFactory.AddConsole(_config.GetSection("Logging")); loggerFactory.AddDebug(); app.UseIdentity(); app.UseJwtBearerAuthentication(new JwtBearerOptions() { AutomaticAuthenticate = true, AutomaticChallenge = true, TokenValidationParameters = new TokenValidationParameters() { ValidIssuer = _config["Tokens:Issuer"], ValidAudience = _config["Tokens:Audience"], ValidateIssuerSigningKey = true, IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_config["Tokens:Key"])), ValidateLifetime = true, } }); app.UseMvc(config => { //config.MapRoute("MainAPIRoute", "api/{controller}/{action}"); }); seeder.Seed().Wait(); identitySeeder.Seed().Wait(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app , IHostingEnvironment env , CampDbInitializer dbSeeder , CampIdentityInitializer identitySeeder , ILoggerFactory loggerFactory) { loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); // this is a global config, if we want to config separately we need to use polices app.UseCors(config => { //config.AllowAnyHeader() //.AllowAnyMethod() //.WithOrigins("http://linalekova.com"); }); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseAuthentication(); app.UseMvc(); dbSeeder.Seed().Wait(); identitySeeder.Seed().Wait(); }
// Executed once, as the server starts public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, CampDbInitializer dbSeeder, CampIdentityInitializer identitySeeder) { loggerFactory.AddConsole(_config.GetSection("Logging")); loggerFactory.AddDebug(); /* moved to CampsController * app.UseCors(cfg => * { * cfg.AllowAnyHeader() * .AllowAnyMethod() * .WithOrigins("http://github.com/t4rn"); * }); */ app.UseIdentity(); // JWT app.UseJwtBearerAuthentication(new JwtBearerOptions() { AutomaticAuthenticate = true, AutomaticChallenge = true, TokenValidationParameters = new TokenValidationParameters() { ValidIssuer = _config["Tokens:Issuer"], ValidAudience = _config["Tokens:Audience"], ValidateIssuerSigningKey = true, IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_config["Tokens:Key"])), ValidateLifetime = true } }); app.UseMvc(x => { //x.MapRoute("MainAPIRoute", "api/{controller}/{action}"); }); dbSeeder.Seed().Wait(); identitySeeder.Seed().Wait(); }
// 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, CampDbInitializer seeder, CampIdentityInitializer identitySeeder) { loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } // app.UseIdentity() is obsolete. // Also, this must be added before UseMvc() app.UseAuthentication(); app.UseMvc(); seeder.Seed().Wait(); identitySeeder.Seed().Wait(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, CampDbInitializer seeder, ILoggerFactory loggerFactory, CampIdentityInitializer identitySeeder) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } loggerFactory.AddConsole(_config.GetSection("Logging")); loggerFactory.AddDebug(); //identity before mvc app.UseAuthentication(); app.UseMvc(); seeder.Seed().Wait(); //async identitySeeder.Seed().Wait(); }
// 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, CampDbInitializer seeder, CampIdentityInitializer identitySeeder) { loggerFactory.AddConsole(_config.GetSection("Logging")); loggerFactory.AddDebug(); //app.UseCors(cfg => //{ // cfg.AllowAnyHeader() // .AllowAnyMethod() // .WithOrigins("http://wildermuth.com"); //}); app.UseIdentity(); app.UseAuthentication(); app.UseMvcWithDefaultRoute(); //app.UseJwtBearerAuthentication(new JwtBearerOptions() //{ // AutomaticAuthenticate = true, // AutomaticChallenge = true, // TokenValidationParameters = new TokenValidationParameters() // { // ValidIssuer = _config["Tokens:Issuer"], // ValidAudience = _config["Tokens:Audience"], // ValidateIssuerSigningKey = true, // IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_config["Tokens:Key"])), // ValidateLifetime = true // } //}); app.UseMvc(config => { //config.MapRoute("MainAPIRoute", "api/{controller}/{action}"); }); seeder.Seed().Wait(); identitySeeder.Seed().Wait(); }
// 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, CampDbInitializer seeder, CampIdentityInitializer identitySeeder) { loggerFactory.AddConsole(_config.GetSection("Logging")); loggerFactory.AddDebug(); // Configuring Cors to be used globally. //app.UseCors(config => //{ // config.AllowAnyHeader() // .AllowAnyMethod() // .WithOrigins("http://www.google.com"); //}); app.UseIdentity(); app.UseJwtBearerAuthentication(new JwtBearerOptions() { AutomaticAuthenticate = true, AutomaticChallenge = true, TokenValidationParameters = new TokenValidationParameters() { ValidIssuer = _config["Tokens:Issuer"], ValidAudience = _config["Tokens:Audience"], ValidateIssuerSigningKey = true, IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_config["Tokens:Key"])), ValidateLifetime = true } }); app.UseMvc(config => { //config.MapRoute("MainAPIRoute", "api/{controller}/{action}"); }); // If there's no data in our Db then the injected db initializer will seed the db. seeder.Seed().Wait(); identitySeeder.Seed().Wait(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. // setup how requests are being handled. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, CampDbInitializer seeder, CampIdentityInitializer IdentiySeeder) { // all middleware that must occur before mvc deals with a request must come before app.UseMvc(); loggerFactory.AddConsole(_config.GetSection("Logging")); loggerFactory.AddDebug(); app.UseApplicationInsightsRequestTelemetry(); app.UseApplicationInsightsExceptionTelemetry(); app.UseIdentity(); app.UseJwtBearerAuthentication(new JwtBearerOptions() { // if token is found, use it to authenticate AutomaticAuthenticate = true, // it token not found or token is invalid, respond as a challenge AutomaticChallenge = true, TokenValidationParameters = new TokenValidationParameters() { ValidIssuer = _config["Tokens:Issuer"], ValidAudience = _config["Token:Audience"], // check is signing key is valid ValidateIssuerSigningKey = true, IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_config["Tokens:Key"])), // check if token is expired ValidateLifetime = true } }); app.UseMvc(); // Seed is async task. use Wait to make it synchronous. seeder.Seed().Wait(); IdentiySeeder.Seed().Wait(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env , CampDbInitializer seeder, CampIdentityInitializer identitySeeder) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseCors(cfg => { // cfg.AllowAnyHeader() // .AllowAnyMethod() // .WithOrigins(); }); app.UseAuthentication(); app.UseMvc( // m => { m.MapRoute("MainAPIRoute", "api/{controller}/{action}"); } ); seeder.Seed().Wait(); identitySeeder.Seed().Wait(); }
// 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, CampDbInitializer campDbInit, CampIdentityInitializer campIdInit) { loggerFactory.AddConsole(_config.GetSection("Logging")); loggerFactory.AddDebug(); app.UseIdentity(); /*app.UseCors(cfg => * { * cfg.AllowAnyHeader() * .AllowAnyMethod() * .AllowAnyOrigin(); * });*/ app.UseJwtBearerAuthentication(new JwtBearerOptions() { AutomaticAuthenticate = true, AutomaticChallenge = true, TokenValidationParameters = new Microsoft.IdentityModel.Tokens.TokenValidationParameters() { ValidIssuer = _config["Tokens:Issuer"], ValidAudience = _config["Tokens:Audience"], ValidateIssuerSigningKey = true, IssuerSigningKey = new Microsoft.IdentityModel.Tokens.SymmetricSecurityKey(Encoding.UTF8.GetBytes(_config["Tokens:Key"])), ValidateLifetime = true } }); app.UseMvc(); campDbInit.Seed().Wait(); campIdInit.Seed().Wait(); }