Beispiel #1
0
        // 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();
        }
Beispiel #2
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,
                              CampDbInitializer initializer)
        {
            // log configurations

            //loggerFactory.AddConsole(_config.GetSection("Logging"));
            //loggerFactory.AddDebug();

            var logFile = _config["Logging:LogFile"];

            LogHelper.Init(logFile);

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

            app.UseMvc();

            // swagger config

            app.UseSwagger();

            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "Contacts API V1");
            });

            // initialize db

            initializer.Seed().Wait();
        }
Beispiel #3
0
        // 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();
        }
Beispiel #4
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,
                              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();

            seeder.Seed().Wait();
            identitySeeder.Seed().Wait();
        }
Beispiel #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,
                              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();
        }
Beispiel #6
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,
                              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();
        }
Beispiel #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, ILoggerFactory loggerFactory,
            CampDbInitializer dbSeeder
            )
        {
            loggerFactory.AddConsole(_configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            app.UseMvc();

            dbSeeder.Seed().Wait();
        }
Beispiel #8
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, CampDbInitializer seeder)
 {
     loggerFactory.AddConsole(Configuration.GetSection("Logging"));
     loggerFactory.AddDebug();
     app.UseStatusCodePages();
     app.UseMvc(routes =>
     {
         routes.MapRoute("MainApiRoute", "api/{controller}/{action}");
     });
     seeder.Seed().Wait();
 }
Beispiel #9
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,
                              CampDbInitializer seeder)
        {
            loggerFactory.AddConsole(_config.GetSection("Logging"));
            loggerFactory.AddDebug();

            app.UseMvc(config =>
            {
                //config.MapRoute("MainAPIRoute", "api/{controller}/{action}");
            });

            seeder.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)
        {
            loggerFactory.AddConsole(_config.GetSection("Logging"));
            loggerFactory.AddDebug();

            // app.UseApplicationInsightsRequestTelemetry();

            // app.UseApplicationInsightsExceptionTelemetry();

            app.UseMvc();
            //Initialized DB
            seeder.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)
        {
            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();
            }

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

            seeder.Seed().Wait();
        }
Beispiel #12
0
        // 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();
        }
Beispiel #13
0
        // 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)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseMvc(config =>
            {
                //config.MapRoute("MainAPIRoute","api/{controller}/{action}");
            });


            //app.UseMvc();

            seeder.Seed().Wait();
        }
Beispiel #14
0
        // 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();
        }
Beispiel #15
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,
                              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();
        }
Beispiel #16
0
        public void Configure(IApplicationBuilder app, IHostingEnvironment env,
                              ILoggerFactory loggerFactory,
                              CampDbInitializer seeder,              //LD STEP66 we add the parameter we want use in "Configure" method and the dependency injection layer will fulfill if possible
                              CampIdentityInitializer identitySeeder //LD STEP28
                              )
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            //LD STEP14
            //app.UseCors(cfg =>
            //{
            //    cfg.AllowAnyHeader()
            //       .AllowAnyMethod()
            //       .WithOrigins("http://wildermuth.com");
            //});

            //LD STEP35
            app.UseJwtBearerAuthentication(new JwtBearerOptions()
            {
                //LD we ask to the framework that if find the token then authenticate authomatically
                AutomaticAuthenticate = true,
                AutomaticChallenge    = true,
                //LD following we have the parameter that we want Bearer will use to validate the token
                TokenValidationParameters = new TokenValidationParameters()
                {
                    ValidIssuer              = Configuration["Tokens:Issuer"],
                    ValidAudience            = Configuration["Tokens:Audience"],
                    ValidateIssuerSigningKey = true,
                    IssuerSigningKey         = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(Configuration["Tokens:Key"])),
                    ValidateLifetime         = true //LD verify that the token is not expired
                }
            });

            //LD STEP19
            app.UseIdentity(); //LD we want tha "Identity" is executed before MVC, we want protect before all the MVC process

            app.UseMvc();

            //seeder.Seed().Wait(); //LD STEP77 here we just call it.
            //identitySeeder.Seed().Wait(); //LD STEP28
        }
Beispiel #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,
                              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();
        }
Beispiel #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,
                              ILoggerFactory loggerFactory,
                              CampDbInitializer seeder)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            loggerFactory.AddConsole(_config.GetSection("Logging"));
            loggerFactory.AddDebug();

            app.UseMvc(config =>
            {
                //config.MapRoute("default", "ap1/{controller}/{action}");
            });

            seeder.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();
        }
Beispiel #20
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,
                              CampDbInitializer seeder,
                              CampIdentityInitializer identitySeeder)
        {
            loggerFactory.AddConsole(_config.GetSection("Logging"));
            loggerFactory.AddDebug();

            // Global set cors
            //app.UseCors(cfg =>
            //{
            //    cfg.AllowAnyMethod()
            //       .AllowAnyHeader()
            //       .WithOrigins("http://mrdevine.co.uk");
            //});

            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 =>
            {
            });

            seeder.Seed().Wait();
            identitySeeder.Seed().Wait();
        }
Beispiel #21
0
        // 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();
        }
Beispiel #22
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,
                              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();
        }
Beispiel #23
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, 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();
        }
Beispiel #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, 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();
        }
Beispiel #25
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, CampDbInitializer seeder)
        {
            loggerFactory.AddConsole(_config.GetSection("Logging"));
            loggerFactory.AddDebug();

            // Cors, specify a cross-origin policy
            app.UseCors(policy =>
            {
                policy.WithOrigins("*");
                policy.AllowAnyHeader();
                policy.AllowAnyMethod();
            });

            app.UseMvc();

            seeder.Seed().Wait();
        }