Exemplo n.º 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,
            ILoggerFactory loggerFactory, IServiceProvider provider, IDeliveryQueueData deliveryQueueData, IDistributedCache cache, Serilog.ILogger logger)
        {

            // Add serilog and catch any internal errors
            loggerFactory.AddSerilog();
            Serilog.Debugging.SelfLog.Enable(msg => Console.WriteLine(msg));

            // Set logging based on enviroments
            if (env.IsEnvironment("local") || env.IsEnvironment("development"))
            {
                app.UseDeveloperExceptionPage();
                app.UseBrowserLink();
                loggerFactory.AddConsole(Configuration.GetSection("Logging"));
                loggerFactory.AddDebug();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");                 
            }

            // server static files
            app.UseStaticFiles();

            app.UseSignalR();

            var appSettings = Configuration.Get<AppSettings>("Application");
            // Configure the OWIN pipeline to use cookie auth.
            app.UseCookieAuthentication(new CookieAuthenticationOptions()
            {
                AuthenticationScheme = "Cookies",
                AutomaticAuthenticate = true,
                ExpireTimeSpan = TimeSpan.FromMinutes(int.Parse(appSettings.SessionExpirationTimeMinutes)),
                SlidingExpiration = true
            });

            // Configure the OWIN pipeline to use OpenID Connect auth.
            AppSettings settings = Configuration.Get<AppSettings>("Application");
            app.UseOpenIdConnectAuthentication(new OpenIdConnectOptions
            {
                ClientId = settings.AzureAd.ClientId,
                Authority = String.Format(settings.AzureAd.AadInstance, settings.AzureAd.Tenant),
                ResponseType = OpenIdConnectResponseType.IdToken,
                PostLogoutRedirectUri = settings.AzureAd.PostLogoutRedirectUri,
                Events = new OpenIdConnectEvents
                {
                    OnAuthenticationFailed = cx =>  AuthenticationFailed(cx),
                    OnRemoteFailure = cx=> RemoteFailure(cx),
                    OnTokenValidated = cx => TokenValidated(cx)
                },             
                CallbackPath = "/signin-oidc"
            });

            app.UseSession();
            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
          
            ConnectionManager = provider.GetService<IConnectionManager>();
            AutomaticViewRefresher automaticViewRefresher = new AutomaticViewRefresher(deliveryQueueData,logger);
            automaticViewRefresher.Start(10);
        }
Exemplo n.º 2
0
 public AutomaticViewRefresher(IDeliveryQueueData viewformatter, ILogger logger)
 {
     this.viewformatter = viewformatter;
     _logger            = logger;
 }