AspNetMvcAuthSample.Startup.Configure C# (CSharp) Метод

Configure() публичный Метод

public Configure ( IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory ) : void
app IApplicationBuilder
env IHostingEnvironment
loggerFactory ILoggerFactory
Результат void
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseDeveloperExceptionPage();

            app.UseStaticFiles();

            app.UseMultitenancy<AppTenant>();

            app.UsePerTenant<AppTenant>((ctx, builder) =>
            {
                builder.UseCookieAuthentication(new CookieAuthenticationOptions()
                {
                    AuthenticationScheme = "Cookies",
                    LoginPath = new PathString("/account/login"),
                    AccessDeniedPath = new PathString("/account/forbidden"),
                    AutomaticAuthenticate = true,
                    AutomaticChallenge = true,
                    CookieName = $"{ctx.Tenant.Id}.AspNet.Cookies"
                });

                // only register for google if ClientId and ClientSecret both exist
                var clientId = Configuration[$"{ctx.Tenant.Id}:GoogleClientId"];
                var clientSecret = Configuration[$"{ctx.Tenant.Id}:GoogleClientSecret"];

                if (!string.IsNullOrWhiteSpace(clientId) && !string.IsNullOrWhiteSpace(clientSecret))
                {
                    builder.UseGoogleAuthentication(new GoogleOptions()
                    {
                        AuthenticationScheme = "Google",
                        SignInScheme = "Cookies",

                        ClientId = clientId,
                        ClientSecret = clientSecret

                    });
                }
            });

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
        }