Example #1
0
        /// <summary>
        /// The Startup configuration sets up a pipeline with three middleware components, the first two displaying diagnostic information
        /// and the last one responding to events (and also displaying diagnostic information).  The PrintCurrentIntegratedPipelineStage 
        /// method displays the integrated pipeline event this middleware is invoked on and a message.
        /// </summary>
        public void Configuration(IAppBuilder app)
        {
            app.Use((context, next) =>
            {
                PrintCurrentIntegratedPipelineStage(context, "Middleware 1");
                return next.Invoke();
            });
            app.Use((context, next) =>
            {
                PrintCurrentIntegratedPipelineStage(context, "2nd MW");
                return next.Invoke();
            });
            // You can mark OMCs to execute at specific stages of the pipeline by using the IAppBuilder UseStageMarker() extension method.
            // To run a set of middleware components during a particular stage, insert a stage marker right after the last component is the set
            // during registration. There are rules on which stage of the pipeline you can execute middleware and the order components must run
            // (The rules are explained later in the tutorial). Add the UseStageMarker method to the Configuration code as shown below:
            app.UseStageMarker(PipelineStage.Authenticate);

            app.Run(context =>
            {
                PrintCurrentIntegratedPipelineStage(context, "3rd MW");
                return context.Response.WriteAsync("Hello world");
            });
            app.UseStageMarker(PipelineStage.ResolveCache);
        }
Example #2
0
        protected virtual void Start(IAppBuilder app, IContainer container)
        {
            var config = CreateHttpConfiguration();

            ConfigureWebApi(config, container);

            if (Settings.ShowExceptionDetails)
            {
                app.UseErrorPage(new ErrorPageOptions
                {
                    ShowExceptionDetails = true,
                    ShowSourceCode = true
                });
            }

            app.UseAutofacMiddleware(container);
            app.UseStageMarker(PipelineStage.Authenticate);

            app.UseAutofacWebApi(config);
            app.UseWebApi(config);
            RegisterSignalR(container, app);

            app.UseStageMarker(PipelineStage.MapHandler);

            RegisterServices(container, app, config);

            RegisterShutdown(app, container);

            StartIndexingIfConfigured(container);
        }
Example #3
0
 /// <summary>
 /// OWIN start up method
 /// </summary>
 /// <param name="app">The app.</param>
 public void Configuration(IAppBuilder app)
 {
     var config = new System.Web.Http.HttpConfiguration();
     app.Use((context, next) =>
     {
         return next.Invoke();
     });
     app.UseStageMarker(PipelineStage.Authenticate);
     Swashbuckle.Bootstrapper.Init(config);
     WebApiConfig.Register(config);
     app.UseWebApi(config);
     app.UseStageMarker(PipelineStage.MapHandler);
 }
Example #4
0
 public void Configuration(IAppBuilder app)
 {
     Common.Setup.AutoMapper.Initialize();
     app.MapSignalR();
     app.UseNancy();
     app.UseStageMarker(PipelineStage.MapHandler);
 }    
Example #5
0
        public void Configuration(IAppBuilder app)
        {
            /* // Note: Enable only for debugging. This slows down the perf tests.
            app.Use((context, next) =>
            {
                var req = context.Request;
                context.TraceOutput.WriteLine("{0} {1}{2} {3}", req.Method, req.PathBase, req.Path, req.QueryString);
                return next();
            });*/

            app.UseErrorPage(new ErrorPageOptions { SourceCodeLineCount = 20 });
            // app.Use(typeof(AutoTuneMiddleware), app.Properties["Microsoft.Owin.Host.HttpListener.OwinHttpListener"]);
            app.UseSendFileFallback();
            app.Use<CanonicalRequestPatterns>();

            app.UseStaticFiles(new StaticFileOptions()
            {
                RequestPath = new PathString("/static"),
                FileSystem = new PhysicalFileSystem("public")
            });
            app.UseDirectoryBrowser(new DirectoryBrowserOptions()
            {
                RequestPath = new PathString("/static"),
                FileSystem = new PhysicalFileSystem("public")
            });
            app.UseStageMarker(PipelineStage.MapHandler);

            FileServerOptions options = new FileServerOptions();
            options.EnableDirectoryBrowsing = true;
            options.StaticFileOptions.ServeUnknownFileTypes = true;

            app.UseWelcomePage("/Welcome");
        }
Example #6
0
        public void Configuration(IAppBuilder app)
        {
            var httpConfiguration = new HttpConfiguration();

            // Configure Web API Routes:
            // - Enable Attribute Mapping
            // - Enable Default routes at /api.
            httpConfiguration.MapHttpAttributeRoutes();
            httpConfiguration.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );

            app.UseWebApi(httpConfiguration);

            // Make ./public the default root of the static files in our Web Application.
            app.UseFileServer(new FileServerOptions
            {
                RequestPath = new PathString(string.Empty),
                FileSystem = new PhysicalFileSystem("./public"),
                EnableDirectoryBrowsing = true,
            });

            app.UseStageMarker(PipelineStage.MapHandler);
        }
Example #7
0
        public void Configuration(IAppBuilder app)
        {
            ConfigureLogger();

            var builder = new ContainerBuilder();
            builder.RegisterLogger();
            builder.RegisterByAttributes(typeof (Startup).Assembly);
            builder.RegisterAssemblyModules(typeof (Startup).Assembly);
            builder.RegisterHubs(typeof (Startup).Assembly);
            var container = builder.Build();

            // config hubs
            var config = new HubConfiguration();
            config.Resolver = new AutofacDependencyResolver(container);

            app.UseJwtTokenAuthentication(container.Resolve<IssuerSetting>(),
                                          container.Resolve<AudienceSetting>(),
                                          container.Resolve<ClientSecretSetting>(),
                                          container.Resolve<ICurrentUserProvider>());

            app.MapSignalR(config);

            app.UseNancy(new NancyOptions
            {
                Bootstrapper = new NancyBootstrapper(container)
            });
            app.UseStageMarker(PipelineStage.MapHandler);
            app.UseCors(CorsOptions.AllowAll);

            JsonSettings.RetainCasing = false;

            SeedData(container);
        }
Example #8
0
 public void DefaultStaticFiles(IAppBuilder app)
 {
     app.Use((context, next) => { context.Response.Headers["PassedThroughOWIN"] = "True"; return next(); });
     app.UseStaticFiles();
     app.Run(context => { context.Response.StatusCode = 402; return context.Response.WriteAsync("Fell Through"); });
     app.UseStageMarker(PipelineStage.MapHandler);
 }
Example #9
0
        public void Configuration(IAppBuilder app)
        {
            var httpConfiguration = new HttpConfiguration();

            // set response formatters
            httpConfiguration.Formatters.Clear();
            SetWebApiResponseAsJson(httpConfiguration);

            // Configure Web API Routes:
            // - Enable Attribute Mapping
            // - Enable Default routes at /api.
            httpConfiguration.MapHttpAttributeRoutes();
            httpConfiguration.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}"
                );

            httpConfiguration.Routes.MapHttpRoute(
                name: "Default",
                routeTemplate: "r/{hashId}",
                defaults: new { controller = "RedirectUrl" }
                );

            app.UseWebApi(httpConfiguration);

            // Make ./public the default root of the static files in our Web Application.
            app.UseFileServer(new FileServerOptions
            {
                RequestPath = new PathString(string.Empty),
                FileSystem = new PhysicalFileSystem("./App/www"),
                EnableDirectoryBrowsing = true,
            });

            app.UseStageMarker(PipelineStage.MapHandler);
        }
        public void Configuration(IAppBuilder app)
        {
            var httpConfiguration = new HttpConfiguration();

            // Configure Web API Routes:
            // - Enable Attribute Mapping
            // - Enable Default routes at /api.
            httpConfiguration.MapHttpAttributeRoutes();
            httpConfiguration.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );

            httpConfiguration.Formatters.Clear();
            httpConfiguration.Formatters.Add(new JsonMediaTypeFormatter());
            httpConfiguration.Formatters.JsonFormatter.SerializerSettings =
            new JsonSerializerSettings
            {
                ContractResolver = new CamelCasePropertyNamesContractResolver()
            };

            app.UseWebApi(httpConfiguration);

            // Make ./public the default root of the static files in our Web Application.
            app.UseFileServer(new FileServerOptions
            {
                RequestPath = new PathString(string.Empty),
                FileSystem = new PhysicalFileSystem("./"),
                EnableDirectoryBrowsing = true,

            });

            app.UseStageMarker(PipelineStage.MapHandler);
        }
Example #11
0
        public void Configuration(IAppBuilder app)
        {
            #if DEBUG
            //when things go south
            app.UseErrorPage();
            #endif

            FileServerOptions fileServerOptions = new FileServerOptions()
            {
                RequestPath = PathString.Empty,
                FileSystem = new PhysicalFileSystem(@".\\public"),
            };

            //In order to serve json files
            fileServerOptions.StaticFileOptions.ServeUnknownFileTypes = true;
            fileServerOptions.StaticFileOptions.DefaultContentType = "text";

            // Remap '/' to '.\public\'.
            // Turns on static files and public files.
            app.UseFileServer(fileServerOptions);

            app.UseStageMarker(PipelineStage.MapHandler);

            //Web Api
            HttpConfiguration config = new HttpConfiguration();
            config.MapHttpAttributeRoutes();

            //Cause all the cool kids use JSON
            config.Formatters.JsonFormatter.UseDataContractJsonSerializer = true;
            config.Formatters.Remove(config.Formatters.XmlFormatter);

            app.UseWebApi(config);
        }
        public void MiddlewaresAtDifferentStagesConfiguration(IAppBuilder app)
        {
            app.Use((context, next) =>
            {
                //Create a custom object in the dictionary to push middlewareIds. 
                context.Set<Stack<int>>("stack", new Stack<int>());
                return next.Invoke();
            });

            var stageTuples = new Tuple<RequestNotification, PipelineStage>[]
                        {
                            new Tuple<RequestNotification, PipelineStage>(RequestNotification.AuthenticateRequest, PipelineStage.Authenticate),
                            new Tuple<RequestNotification, PipelineStage>(RequestNotification.AuthenticateRequest, PipelineStage.PostAuthenticate),
                            new Tuple<RequestNotification, PipelineStage>(RequestNotification.AuthorizeRequest, PipelineStage.Authorize),
                            new Tuple<RequestNotification, PipelineStage>(RequestNotification.AuthorizeRequest, PipelineStage.PostAuthorize),
                            new Tuple<RequestNotification, PipelineStage>(RequestNotification.ResolveRequestCache, PipelineStage.ResolveCache),
                            new Tuple<RequestNotification, PipelineStage>(RequestNotification.ResolveRequestCache, PipelineStage.PostResolveCache),
                            new Tuple<RequestNotification, PipelineStage>(RequestNotification.MapRequestHandler, PipelineStage.MapHandler),
                            new Tuple<RequestNotification, PipelineStage>(RequestNotification.MapRequestHandler, PipelineStage.PostMapHandler),
                            new Tuple<RequestNotification, PipelineStage>(RequestNotification.AcquireRequestState, PipelineStage.AcquireState),
                            new Tuple<RequestNotification, PipelineStage>(RequestNotification.AcquireRequestState, PipelineStage.PostAcquireState),
                            new Tuple<RequestNotification, PipelineStage>(RequestNotification.PreExecuteRequestHandler, PipelineStage.PreHandlerExecute),
                        };

            for (int middlewareId = 0; middlewareId < stageTuples.Length; middlewareId++)
            {
                var stage = stageTuples[middlewareId];
                app.Use<IntegratedPipelineMiddleware>(stage.Item1, middlewareId);
                app.UseStageMarker(stage.Item2);
            }
        }
 public void Configuration(IAppBuilder app)
 {
     app.UseNancy();
     // todo: uncomment to invoke non-default Bootstrapper ctor
     //app.UseNancy(new NancyOptions() { Bootstrapper = new CustomBootstrapper(str: "hi") });
     app.UseStageMarker(PipelineStage.MapHandler);//required to display Nancy assets on IIS
 }
Example #14
0
        public void Configuration(IAppBuilder app)
        {
            JwtSecurityTokenHandler.InboundClaimTypeMap.Clear();

            app.UseIdentityServerBearerTokenAuthentication(new IdentityServerBearerTokenAuthenticationOptions
            {
                Authority = "https://localhost:44333/core",
                RequiredScopes = new[] { "api" },
                NameClaimType = "name",
                RoleClaimType = "role",

                // client credentials for the introspection endpoint
                ClientId = "angularMaterial",
                ClientSecret = Guid.NewGuid().ToString()
            });

            var configuration = new HttpConfiguration();
            configuration.MapHttpAttributeRoutes();

            var jsonFormatter = configuration.Formatters.OfType<JsonMediaTypeFormatter>().FirstOrDefault();

            if (jsonFormatter != null)
            {
                jsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
            }

            app.UseResourceAuthorization(new AuthorizationManager());

            app.UseWebApi(configuration);

            app.UseNancy();
            app.UseStageMarker(PipelineStage.MapHandler);
        }
 public void Configuration(IAppBuilder app)
 {
     var config = new HttpConfiguration();
     config.MapHttpAttributeRoutes();
     app.UseWebApi(config);
     app.UseNancy();
     app.UseStageMarker(PipelineStage.MapHandler);
 }
Example #16
0
        public void Configuration(IAppBuilder app)
        {
            var builder = new ContainerBuilder();
            builder.RegisterAssemblyModules(GetType().Assembly);
            var container = builder.Build();

            app.Use(typeof(StubJwtBearerAuthenticationMiddleware), app, new StubJwtBearerAuthenticationOptions("jwt"));
            app.UseStageMarker(PipelineStage.Authenticate);
            app.UseNancy(options =>
            {
                var bootstrapper = new FlogNancyBootstrapper()
                    .UseContainer(container);

                options.Bootstrapper = bootstrapper;
            });
            app.UseStageMarker(PipelineStage.MapHandler);
        }
	public void Configuration(IAppBuilder app)
	{
		// set the AI key
		Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration.Active.InstrumentationKey =
				ConfigurationManager.AppSettings["AiInstrumentationKey"];

		app.UseNancy();
		app.UseStageMarker(PipelineStage.MapHandler);
	}
Example #18
0
 public void Configuration(IAppBuilder app)
 {
     app.UseWebApi(Models.Config.GetHttpConfiguration());
     app.UseErrorPage();
     // the next line is needed for handling the UriPathExtensionMapping...
     app.UseStageMarker(PipelineStage.MapHandler);
     app.UseStaticFiles();
     app.UseFileServer(true);
 }
Example #19
0
        public void Configuration(IAppBuilder app)
        {
            var application = new Application(new Settings());
            if (_configurer != null) _configurer(application);

            MidFunc middleware = next => application.GetAppFunc();
            app.Use(middleware);
            app.UseStageMarker(PipelineStage.MapHandler);
        }
Example #20
0
        public void Configuration(IAppBuilder app)
        {
            var configuration = new StaticFilesConfiguration("htdocs");
            configuration.AddIgnoredExtension(".ts");

            app.UseStaticFiles(configuration);

            app.UseStageMarker(PipelineStage.MapHandler);
        }
        public void Configuration(IAppBuilder app)
        {
            HttpConfiguration = new HttpConfiguration();
            Container = AutofacConfig.BuildAndRegisterContainer(app, HttpConfiguration);
            WebApiConfig.Configure(app, HttpConfiguration);
            NancyConfig.Configure(app, Container);
            FileSystemConfig.Configure(app);

            app.UseStageMarker(PipelineStage.MapHandler);
        }
Example #22
0
        public void Configuration(IAppBuilder app)
        {
            var httpConfiguration = new HttpConfiguration();

            httpConfiguration.AddODataQueryFilter();

            // Configure Web API Routes:
            // - Enable Attribute Mapping
            // - Enable Default routes at /api.
            //httpConfiguration.MapHttpAttributeRoutes();
            //httpConfiguration.Routes.MapHttpRoute(
            //    name: "DefaultApi",
            //    //routeTemplate: "api/{controller}/{id}",
            //    routeTemplate: "api/{namespace}/{controller}/{id}",
            //    defaults: new { id = RouteParameter.Optional }
            //);

            //httpConfiguration.Services.Replace(typeof(IHttpControllerSelector), new VersionHttpControllerSelector(httpConfiguration));

            ODataConventionModelBuilder builder = new ODataConventionModelBuilder();

            //var route = httpConfiguration.Routes.Where(r => r is System.Web.Http.OData.Routing.ODataRoute).First();
            //var odataRoute = route as System.Web.Http.OData.Routing.ODataRoute;

            //httpConfiguration.MapODataServiceRoute(
            //    routeName: "OrdersRoute",
            //    routePrefix: "odata",
            //    model: builder.GetEdmModel(),
            //    pathHandler: odataRoute.Constraints.PathHandler,
            //    routingConventions: odataRoute.PathRouteConstraint.RoutingConventions);

            builder.EntitySet<Order>("Orders");
            builder.EntitySet<OrderItem>("OrderItems");
            builder.EntitySet<OrderItemOption>("OrderItemOptions");

            // mock the route prefix to api/v1 until the proper versioning is implemented
            httpConfiguration.MapODataServiceRoute("OData", "api/v1", builder.GetEdmModel()); //, new DefaultODataBatchHandler(GlobalConfiguration.DefaultServer));

            app.UseWebApi(httpConfiguration);

            var odataFormatters = ODataMediaTypeFormatters.Create(new NullSerializerProvider(), new DefaultODataDeserializerProvider());
            httpConfiguration.Formatters.InsertRange(0, odataFormatters);

            httpConfiguration.EnsureInitialized();

            // Make ./public the default root of the static files in our Web Application.
            app.UseFileServer(new FileServerOptions
            {
                RequestPath = new PathString(string.Empty),
                FileSystem = new PhysicalFileSystem("./public"),
                EnableDirectoryBrowsing = true,
            });

            app.UseStageMarker(PipelineStage.MapHandler);
        }
Example #23
0
        public void Configuration(IAppBuilder app)
        {
            StaticConfiguration.EnableRequestTracing = true;

            app.UseNancy(new Nancy.Owin.NancyOptions()
            {
                Bootstrapper = new NancyBootstrapper(),
                //PerformPassThrough = c => { return c.Response.StatusCode == HttpStatusCode.NotFound; },
            });
            app.UseStageMarker(PipelineStage.MapHandler);
        }
Example #24
0
 public void Ololo(IAppBuilder app)
 {
     app.Use((context, next) =>
     {
         PrintCurrentIntegratedPipelineStage(context, "Middleware 1");
         return next.Invoke();
     });
     app.Use((context, next) =>
     {
         PrintCurrentIntegratedPipelineStage(context, "2nd MW");
         return next.Invoke();
     });
     app.UseStageMarker(PipelineStage.Authenticate);
     app.Run(context =>
     {
         PrintCurrentIntegratedPipelineStage(context, "3rd MW");
         return context.Response.WriteAsync("Hello world");
     });
     app.UseStageMarker(PipelineStage.ResolveCache);
 }
        private static void SetupNancy(IKernel kernel, IAppBuilder app)
        {
            var bootstrapper = new SimpleRestoreNinjectNancyBootstrapper(kernel);
            app.UseNancy(options => 
                         {
                            options.Bootstrapper = bootstrapper;
                            options.PassThroughWhenStatusCodesAre(HttpStatusCode.NotFound);
                         });

            app.UseStageMarker(PipelineStage.MapHandler);
        }
        public void Configuration(IAppBuilder appBuilder)
        {
            var container = IoC.GetContainer();

            appBuilder.UseNancy(new NancyOptions
            {
                Bootstrapper = new Bootstrapper(container)
            });

            appBuilder.UseStageMarker(PipelineStage.MapHandler);
        }
Example #27
0
        public void Configuration(IAppBuilder app)
        {
            app.Use<Middleware>();
            app.UseCassette();
            app.UseStaticFiles();

            app.UseNancy();

            app.UseStageMarker(PipelineStage.MapHandler);


        }
        public static void RequireAspNetSession(IAppBuilder app)
        {
            app.Use((context, next) =>
            {
                var httpContext = context.Get<HttpContextBase>(typeof (HttpContextBase).FullName);
                httpContext.SetSessionStateBehavior(SessionStateBehavior.Required);
                return next();
            });

            // To make sure the above `Use` is in the correct position:
            app.UseStageMarker(PipelineStage.MapHandler);
        }
Example #29
0
        public void Configuration(IAppBuilder app)
        {
            app.Map("/scim", builder =>
            {
                builder.UseScimServer(config =>
                {
                    config.RequireSsl = false;
                    config.EnableEndpointAuthorization = false;
                });
            });

            app.UseStageMarker(PipelineStage.MapHandler);
        }
        public static IAppBuilder UseJwtTokenAuthentication(this IAppBuilder app,
                                                            JwtTokenAuthenticationOptions options,
                                                            ICurrentUserProvider currentUserProvider)
        {
            if (app == null)
            {
                throw new ArgumentNullException(nameof(app));
            }
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            app.Use(typeof(JwtTokenAuthenticationMiddleware), app, options, currentUserProvider);
            app.UseStageMarker(PipelineStage.Authenticate);
            return(app);
        }
Example #31
0
        public void ConfigureAuth(IAppBuilder app)
        {
            app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);

            app.UseCookieAuthentication(new CookieAuthenticationOptions());

            app.UseWsFederationAuthentication
            (
                new WsFederationAuthenticationOptions
            {
                Wtrealm         = strRealm,
                MetadataAddress = strMetadata
            }
            );

            app.UseStageMarker(PipelineStage.Authenticate);
        }
Example #32
0
 /// <summary>Addes the Swagger generator and Swagger UI to the OWIN pipeline.</summary>
 /// <param name="app">The app.</param>
 /// <param name="controllerTypes">The Web API controller types.</param>
 /// <param name="settings">The Swagger generator settings.</param>
 /// <param name="schemaGenerator">The schema generator.</param>
 /// <returns>The app builder.</returns>
 public static IAppBuilder UseSwaggerUi(
     this IAppBuilder app,
     IEnumerable <Type> controllerTypes,
     SwaggerUiOwinSettings settings,
     SwaggerJsonSchemaGenerator schemaGenerator)
 {
     app.Use <RedirectMiddleware>(settings.ActualSwaggerUiRoute, settings.ActualSwaggerRoute);
     app.Use <SwaggerMiddleware>(settings.ActualSwaggerRoute, controllerTypes, settings, schemaGenerator);
     app.Use <SwaggerUiIndexMiddleware>(settings.ActualSwaggerUiRoute + "/index.html", settings);
     app.UseFileServer(new FileServerOptions
     {
         RequestPath = new PathString(settings.ActualSwaggerUiRoute),
         FileSystem  = new EmbeddedResourceFileSystem(typeof(SwaggerExtensions).Assembly, "NSwag.AspNet.Owin.SwaggerUi")
     });
     app.UseStageMarker(PipelineStage.MapHandler);
     return(app);
 }
Example #33
0
        private void SamlConfiguration(IAppBuilder app)
        {
            var cookieOptions = new CookieAuthenticationOptions
            {
                LoginPath          = new PathString("/Account/Login"),
                AuthenticationType = "Application",
                AuthenticationMode = AuthenticationMode.Passive
            };

            app.UseCookieAuthentication(cookieOptions);

            app.SetDefaultSignInAsAuthenticationType(cookieOptions.AuthenticationType);

            app.UseSaml2Authentication(CreateSaml2Options());

            app.UseStageMarker(PipelineStage.Authenticate);
        }
Example #34
0
        public void Configuration(IAppBuilder app)
        {
            var path   = Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, @"dav-store");
            var davCfg = new WebdavConfig(new Owin.Webdav.StaticDataStore(path))
            {
                AllowDirectoryBrowsing = true,
                Log = new TraceLog(System.Diagnostics.TraceLevel.Verbose)
            };

            //app.Map("/davroot", map =>
            //{
            //    map.Use<WebdavMiddleware>(davCfg);
            //});
            app.Use <WebdavMiddleware>(davCfg);
            // required to make sure requests don't get caught by IIS static file handler
            app.UseStageMarker(PipelineStage.MapHandler);
        }
Example #35
0
        public static IAppBuilder UseKachingApiKeyAuthentication(
            this IAppBuilder app,
            KachingApiAuthenticationOptions options)
        {
            if (app == null)
            {
                throw new ArgumentNullException(nameof(app));
            }

            app.Use(
                typeof(KachingApiAuthenticationMiddleware),
                app,
                options ?? new KachingApiAuthenticationOptions());
            app.UseStageMarker(PipelineStage.Authenticate);

            return(app);
        }
        /// <summary>
        /// Entry point from framework. Here we start the ball rolling in terms of configuring Owin Middleware.
        /// </summary>
        public static void Configuration(IAppBuilder app)
        {
            var physicalFileSystem = new PhysicalFileSystem(@"..\..\..\site");

            var options = new FileServerOptions
            {
                EnableDefaultFiles = true,
                FileSystem         = physicalFileSystem,
            };

            options.StaticFileOptions.FileSystem            = physicalFileSystem;
            options.StaticFileOptions.ServeUnknownFileTypes = true;
            options.DefaultFilesOptions.DefaultFileNames    = new[] { "index.html" };
            app.UseFileServer(options);

            app.UseStageMarker(PipelineStage.MapHandler);
        }
        /// <summary>
        /// Configures an Owin application to use API key authentication; the API key should be
        /// provided in the authorization header on every request, e.g. <c>'Authorization: ApiKey 123'</c>.
        /// </summary>
        /// <param name="app">The web application builder</param>
        /// <param name="options">Options which control the behaviour of the authentication middleware</param>
        /// <returns></returns>
        public static IAppBuilder UseApiKeyAuthentication(this IAppBuilder app, ApiKeyAuthenticationOptions options = null)
        {
            if (app == null)
            {
                throw new ArgumentNullException(nameof(app));
            }

            if (options == null)
            {
                options = new ApiKeyAuthenticationOptions();
            }

            app.Use <ApiKeyAuthenticationMiddleware>(app, options);
            app.UseStageMarker(PipelineStage.Authenticate);

            return(app);
        }
Example #38
0
        private void OpenIdConfiguration(IAppBuilder app)
        {
            app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);

            app.UseCookieAuthentication(new CookieAuthenticationOptions());

            app.UseOpenIdConnectAuthentication
            (
                new OpenIdConnectAuthenticationOptions
            {
                ClientId              = strClientId,
                Authority             = strAuthority,
                PostLogoutRedirectUri = strRedirectUri
            }
            );

            app.UseStageMarker(PipelineStage.Authenticate);
        }
        void PostConstruct(IServiceRegistry serviceRegistry, IAppBuilder appBuilder)
        {
            var requestContext = serviceRegistry.GetService <HttpRequestContext>();

            appBuilder.Use(async(context, next) =>
            {
                try
                {
                    requestContext.Activate();
                    await next();
                }
                finally
                {
                    requestContext.Deactivate();
                }
            });
            appBuilder.UseStageMarker(PipelineStage.MapHandler);
        }
Example #40
0
        // This method is required by Katana:
        public void Configuration(IAppBuilder app)
        {
            var webApiConfiguration = ConfigureWebApi();

            app.UseCors(new Microsoft.Owin.Cors.CorsOptions());

            // Use the extension method provided by the WebApi.Owin library:
            app.UseWebApi(webApiConfiguration);

            app.UseFileServer(new FileServerOptions
            {
                RequestPath             = new PathString(string.Empty),
                FileSystem              = new PhysicalFileSystem("./public"),
                EnableDirectoryBrowsing = true
            });

            app.UseStageMarker(PipelineStage.MapHandler);
        }
Example #41
0
        /// <summary>
        /// Configures authentication.
        /// </summary>
        /// <param name="app">The application.</param>
        private void ConfigureAuth(IAppBuilder app)
        {
            app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
            app.UseCookieAuthentication(new CookieAuthenticationOptions());

            app.UseOpenIdConnectAuthentication(
                new OpenIdConnectAuthenticationOptions
            {
                // Generate the metadata address using the tenant and policy information
                MetadataAddress       = VeracityIntegrationOptions.MetaDataAddress,
                Authority             = VeracityIntegrationOptions.Authority,
                ClientId              = VeracityIntegrationOptions.ClientId,
                RedirectUri           = VeracityIntegrationOptions.RedirectUri,
                PostLogoutRedirectUri = VeracityIntegrationOptions.PostLogoutRedirectUri,
                Notifications         = new OpenIdConnectAuthenticationNotifications
                {
                    AuthorizationCodeReceived = this.OnAuthorizationCodeReceivedAsync,
                    AuthenticationFailed      = this.OnAuthenticationFailed
                },
                ResponseType = OpenIdConnectResponseType.CodeIdToken,
                TokenValidationParameters = new TokenValidationParameters
                {
                    ValidateIssuer  = true,
                    IssuerValidator = (issuer, token, tokenValidationParameters) =>
                    {
                        if (issuer.StartsWith(VeracityIntegrationOptions.Issuer, System.StringComparison.OrdinalIgnoreCase))
                        {
                            return(issuer);
                        }

                        throw new SecurityTokenInvalidIssuerException("Invalid issuer");
                    },
                    NameClaimType = "UserId"
                },
                Scope = $"openid offline_access {VeracityIntegrationOptions.VeracityPlatformServiceScopes}"
            });

            // set the OWIN pipeline stage to Authenticate - this allows for authorization to be set in web.config
            // e.g. To only allow authenticated users add the following
            // <authorization>
            //     <deny users = "?" />
            // </authorization>
            app.UseStageMarker(PipelineStage.Authenticate);
        }
Example #42
0
        public void Configuration(IAppBuilder app)
        {
            var httpConfiguration = new HttpConfiguration();

            // Configure Web API Routes:
            // - Enable Attribute Mapping
            // - Enable Default routes at /api.
            httpConfiguration.MapHttpAttributeRoutes();
            httpConfiguration.Routes.MapHttpRoute(
                name: "AlgorithmApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
                );

            var builder = new ContainerBuilder();

            builder.RegisterApiControllers(Assembly.GetExecutingAssembly());
            builder.RegisterHubs(Assembly.GetExecutingAssembly());

            var config = new HubConfiguration();

            Bootstrap(builder);

            var container = builder.Build();

            httpConfiguration.DependencyResolver = new AutofacWebApiDependencyResolver(container);
            config.Resolver = new AutofacDependencyResolver(container);

            app.UseAutofacMiddleware(container);
            app.UseAutofacWebApi(httpConfiguration);
            app.UseWebApi(httpConfiguration);

            app.MapSignalR("/signalr", config);

            // Make ./public the default root of the static files in our Web Application.
            app.UseFileServer(new FileServerOptions
            {
                RequestPath             = new PathString(string.Empty),
                FileSystem              = new PhysicalFileSystem("./public"),
                EnableDirectoryBrowsing = true,
            });

            app.UseStageMarker(PipelineStage.MapHandler);
        }
Example #43
0
        public void Configuration(IAppBuilder app)
        {
            var application = new Application(new Settings());

            var assemblies = application.FindAssemblies();

            foreach (var assembly in assemblies)
            {
                foreach (var conf in assembly.SafeGetInstances <IConfigurator>())
                {
                    conf.Configure(application);
                }
            }

            MidFunc middleware = next => application.GetAppFunc();

            app.Use(middleware);
            app.UseStageMarker(PipelineStage.MapHandler);
        }
        public void ConfigureAuth(IAppBuilder app)
        {
            app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);

            app.UseCookieAuthentication(new CookieAuthenticationOptions());

            // Definition of options
            //https://www.microsoftpressstore.com/articles/article.aspx?p=2473126&seqNum=2
            app.UseOpenIdConnectAuthentication(
                new OpenIdConnectAuthenticationOptions
            {
                ClientId                  = clientId,
                Authority                 = authority,
                PostLogoutRedirectUri     = postLogoutRedirectUri,
                TokenValidationParameters =
                {
                    NameClaimType = "name"
                },
                UseTokenLifetime = false,     // tells the cookie middleware that the session it creates should have the same duration and validity window as the id_token received from the authority. If you want to decouple the session validity window from the token (which, by the way, Azure AD sets to one hour), you must set this property to false

                Notifications = new OpenIdConnectAuthenticationNotifications()
                {
                    AuthenticationFailed = (context) =>
                    {
                        //context.OwinContext.Response.Redirect("/Home/Error");
                        //context.HandleResponse();
                        return(Task.FromResult(0));
                    },
                    SecurityTokenValidated     = OnSecurityTokenValidated,
                    RedirectToIdentityProvider = OnRedirectToIdentityProvider,
                    SecurityTokenReceived      = (arg) =>
                    {
                        // if you want to test whether the id token has been signed, grab the value from the "arg.ProtocolMessage.IdToken", paste it into https://www.jsonwebtoken.io/,
                        // tamper with the Payload, copy the new JWT string back into the "arg.ProtocolMessage.IdToken".  The AUthenticationFailed Event should fire and give an appropriate error.
                        return(Task.FromResult(0));
                    }
                }
            }
                );

            // This makes any middleware defined above this line run before the Authorization rule is applied in web.config
            app.UseStageMarker(PipelineStage.Authenticate);
        }
        /// <summary>
        /// UseWebApi method.
        /// </summary>
        /// <returns></returns>
        public static void UseHttpConfig(IAppBuilder app)
        {
            if (new Feature_RestApi().FeatureEnabled)
            {
                Logger.Info("FEATURE :: WEB API --> ENABLED");
                Logger.Trace("UseWebApi Begin");

                var config = CreateHttpConfiguration();

                app.UseStageMarker(PipelineStage.MapHandler);
                app.UseWebApi(config);
            }
            else
            {
                Logger.Warn("FEATURE :: WEB API --> DISABLED");
            }

            Logger.Trace("UseWebApi Complete");
        }
Example #46
0
        public void Configuration(IAppBuilder app)
        {
            // --- START COPY FROM HERE --- //
            app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);

            app.UseCookieAuthentication(new CookieAuthenticationOptions());

            app.UseOpenIdConnectAuthentication(
                new OpenIdConnectAuthenticationOptions
            {
                ClientId              = System.Web.Configuration.WebConfigurationManager.AppSettings["ida:ClientId"],
                Authority             = System.Web.Configuration.WebConfigurationManager.AppSettings["ida:AADInstance"] + System.Web.Configuration.WebConfigurationManager.AppSettings["ida:TenantId"],
                PostLogoutRedirectUri = "https://localhost:44374/",
            }
                );

            app.UseStageMarker(PipelineStage.Authenticate);
            // --- END COPY --- //
        }
Example #47
0
        public void Configuration(IAppBuilder app)
        {
            String cs = @"Server=172.31.25.70;uid=sa;pwd=stagingsa;Trusted_Connection=False;Application Name=MachinesLocalDebuggingApplication;";
            //Set initial configuration for application.

            //Set all the application settings here.
            IApplicationSetting appSet = new ApplicationSetting(100, 4, cs, cs);

            GlobalContext.Add(appSet);


            var httpConfiguration = new HttpConfiguration();

            // Configure Web API Routes:
            // - Enable Attribute Mapping
            // - Enable Default routes at /api.
            httpConfiguration.MapHttpAttributeRoutes();
            httpConfiguration.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
                );

//#if DEBUG
            //Allow cros just for debug mode.
            app.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll);
//#endif

            app.UseWebApi(httpConfiguration);

            //app.

            // Make ./public the default root of the static files in our Web Application.
            app.UseFileServer(new FileServerOptions
            {
                RequestPath             = new PathString(string.Empty),
                FileSystem              = new PhysicalFileSystem("./public"),
                EnableDirectoryBrowsing = true,
            });

            app.UseStageMarker(PipelineStage.MapHandler);
        }
        [Inject] void Configure(IServiceRegistry serviceRegistry, IAppBuilder appBuilder)
        {
            appBuilder.Use((context, next) =>
            {
                HttpContext.Current.SetSessionStateBehavior(SessionStateBehavior.Required);
                return(next());
            });
            appBuilder.UseStageMarker(PipelineStage.MapHandler);

            var sessionContext = serviceRegistry.GetService <HttpSessionContext>();

            appBuilder.Use((context, next) =>
            {
                if (HttpContext.Current.Session != null && !sessionContext.IsActive)
                {
                    sessionContext.Activate();
                }
                return(next());
            });
        }
Example #49
0
        public void Configuration(IAppBuilder app)
        {
            var physicalFileSystem = new PhysicalFileSystem(@".\"); //. = root, Web = your physical directory that contains all other static content, see prev step
            var options            = new FileServerOptions
            {
                EnableDefaultFiles = true,
                FileSystem         = physicalFileSystem
            };

            options.StaticFileOptions.FileSystem            = physicalFileSystem;
            options.StaticFileOptions.ServeUnknownFileTypes = true;
            app.UseFileServer(options);

            app.UseNancy(NancyConfig);
            app.UseStageMarker(PipelineStage.MapHandler);
            context    = new AlgoTestContext();
            leagueRepo = new DataRepository(context);
            csvHandler = new Utils.CsvHandler <LeagueData, Utils.LeagueDataMap>();
            JobManager.Initialize(new Schedule.WeeklyRegistry());
        }
        private static void UseUmbracoBackOfficeCookieAuthenticationInternal(this IAppBuilder app, CookieAuthenticationOptions options, ApplicationContext appContext, PipelineStage stage)
        {
            if (app == null)
            {
                throw new ArgumentNullException("app");
            }

            //First the normal cookie middleware
            app.Use(typeof(CookieAuthenticationMiddleware), app, options);
            //don't apply if app isnot ready
            if (appContext.IsUpgrading || appContext.IsConfigured)
            {
                //Then our custom middlewares
                app.Use(typeof(ForceRenewalCookieAuthenticationMiddleware), app, options, new SingletonUmbracoContextAccessor());
                app.Use(typeof(FixWindowsAuthMiddlware));
            }

            //Marks all of the above middlewares to execute on Authenticate
            app.UseStageMarker(stage);
        }
Example #51
0
        public void Configuration(IAppBuilder app)
        {
            var httpConfiguration = new HttpConfiguration();

            // Configure Web API Routes:
            // - Enable Attribute Mapping
            // - Enable Default routes at /api.
            httpConfiguration.MapHttpAttributeRoutes();
            httpConfiguration.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
                );

            app.UseWebApi(httpConfiguration);

            app.UseHtml5Mode("dist", "/index.html");

            app.UseStageMarker(PipelineStage.MapHandler);
        }
        public void Configuration(IAppBuilder app)
        {
            //app.UseStaticFiles(new StaticFileOptions
            //{
            //    FileSystem = new PhysicalFileSystem(@"App"),
            //    RequestPath = new PathString("/App"),
            //    ServeUnknownFileTypes = true
            //});
            //app.UseStaticFiles(new StaticFileOptions
            //{
            //    FileSystem = new PhysicalFileSystem(@"bower_components"),
            //    RequestPath = new PathString("/bower_components")
            //});

            app.UseStageMarker(PipelineStage.MapHandler);

            StaticConfiguration.DisableErrorTraces = false;

            //Token Verification
            //app.UseIdentityServerBearerTokenAuthentication(new IdentityServerBearerTokenAuthenticationOptions
            //{
            //    Authority = "http://localhost:9091",
            //    RequiredScopes = new[] { "api1" }
            //});

            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = "Cookies"
            });

            app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions
            {
                Authority    = "http://localhost:9091/identity",
                ClientId     = "mvc",
                RedirectUri  = "http://localhost:9091/",
                ResponseType = "id_token",

                SignInAsAuthenticationType = "Cookies"
            });
            //app.UseNancy();
        }
Example #53
0
        public void ConfigureAuth(IAppBuilder app)
        {
            app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);

            app.UseCookieAuthentication(new CookieAuthenticationOptions {
            });

            // instead of using the default validation (validating against a single issuer value, as we do in line of business apps),
            // we inject our own multitenant validation logic
            app.UseOpenIdConnectAuthentication(
                new OpenIdConnectAuthenticationOptions
            {
                ClientId  = clientId,
                Authority = authority,
                TokenValidationParameters = new System.IdentityModel.Tokens.TokenValidationParameters
                {
                    ValidateIssuer = false,
                    // If the app needs access to the entire organization, then add the logic
                    // of validating the Issuer here.
                    // IssuerValidator
                },
                Notifications = new OpenIdConnectAuthenticationNotifications()
                {
                    SecurityTokenValidated = (context) =>
                    {
                        // If your authentication logic is based on users
                        return(Task.FromResult(0));
                    },
                    AuthenticationFailed = (context) =>
                    {
                        // Pass in the context back to the app
                        context.HandleResponse();
                        // Suppress the exception
                        return(Task.FromResult(0));
                    }
                }
            });

            // This makes any middleware defined above this line run before the Authorization rule is applied in web.config
            app.UseStageMarker(PipelineStage.Authenticate);
        }
Example #54
0
        /// <summary>
        /// Uses the HTTP configuration.
        /// </summary>
        /// <param name="app">The application.</param>
        public static void UseHttpConfig(this IAppBuilder app)
        {
            var config = new HttpConfiguration();

            config.EnableCors(new EnableCorsAttribute(origins: "*", headers: "*", methods: "* "));

            config.MapHttpAttributeRoutes();
            config.MessageHandlers.Add(new RequireHttpsHandler());

            config.Formatters.JsonFormatter.SerializerSettings.Converters.Add(new Newtonsoft.Json.Converters.StringEnumConverter());
            config.Formatters.JsonFormatter.AddUriPathExtensionMapping("json", "application/json");
            config.Formatters.JsonFormatter.SerializerSettings.Formatting = Newtonsoft.Json.Formatting.Indented;
            config.Formatters.JsonFormatter.AddQueryStringMapping("format", "json", "application/json");
            config.Formatters.JsonFormatter.AddRequestHeaderMapping("ReturnType", "json", StringComparison.InvariantCultureIgnoreCase, false, "application/json");
            config.Formatters.XmlFormatter.AddUriPathExtensionMapping("xml", "application/xml");
            config.Formatters.XmlFormatter.AddQueryStringMapping("format", "xml", "application/xml");
            config.Formatters.XmlFormatter.AddRequestHeaderMapping("ReturnType", "xml", StringComparison.InvariantCultureIgnoreCase, false, "application/xml");

            config.EnsureInitialized();

            config.EnableSwagger(c =>
            {
                c.DescribeAllEnumsAsStrings();
                c.SingleApiVersion(Constants.AppInfo.ApiVersion, Constants.AppInfo.AppName);

                var authorityUri = new Uri(System.Configuration.ConfigurationManager.AppSettings["Authority"]);

                c.OAuth2("oauth")
                .AuthorizationUrl(authorityUri.ToString())
                .TokenUrl(new Uri(authorityUri, "connect/token").ToString())
                .Flow("resource_manager");
            })
            .EnableSwaggerUi();

            app.UseStageMarker(PipelineStage.MapHandler);

            config.CacheOutputConfiguration().RegisterCacheOutputProvider(() => new MemoryCacheDefault());
            //config.CacheOutputConfiguration().RegisterCacheOutputProvider(() => new LoggingCacheOutputProviderDecorator(new MemoryCacheDefault()));

            app.UseWebApi(config);
        }
        public void ConfigureAuth(IAppBuilder app)
        {
            app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);

            app.UseCookieAuthentication(new CookieAuthenticationOptions());

            app.UseOpenIdConnectAuthentication(
                new OpenIdConnectAuthenticationOptions
            {
                ClientId  = clientId,
                Authority = authority,
                TokenValidationParameters = new Microsoft.IdentityModel.Tokens.TokenValidationParameters()
                {
                    SaveSigninToken = true
                },
                PostLogoutRedirectUri = postLogoutRedirectUri,
                Notifications         = new OpenIdConnectAuthenticationNotifications()
                {
                    //
                    // If there is a code in the OpenID Connect response, redeem it for an access token and refresh token, and store those away.
                    //
                    AuthorizationCodeReceived = (context) =>
                    {
                        var code = context.Code;
                        string signedInUserID               = context.AuthenticationTicket.Identity.FindFirst(ClaimTypes.NameIdentifier).Value;
                        AuthenticationContext authContext   = new AuthenticationContext(authority, new TokenCache());
                        X509Certificate2 cert               = Utilities.ReadCertificateFromStore(thumbprint);
                        ClientAssertionCertificate certCred = new ClientAssertionCertificate(clientId, cert);

                        AuthenticationResult result = authContext.AcquireTokenByAuthorizationCodeAsync(
                            code, new Uri(HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Path)), certCred, graphResourceId).Result;

                        return(Task.FromResult(0));
                    }
                }
            }
                );

            // This makes any middleware defined above this line run before the Authorization rule is applied in web.config.
            app.UseStageMarker(PipelineStage.Authenticate);
        }
Example #56
0
        /// <summary>
        /// Entry point from framework. Here we start the ball rolling in terms of configuring Owin Middleware.
        /// </summary>
        public static void Configuration(IAppBuilder app)
        {
            var physicalFileSystem = new PhysicalFileSystem(@"..\..\..\WebDataEntry.Web");

            var options = new FileServerOptions
            {
                EnableDefaultFiles = true,
                FileSystem         = physicalFileSystem,
            };

            options.StaticFileOptions.FileSystem            = physicalFileSystem;
            options.StaticFileOptions.ServeUnknownFileTypes = true;
            options.DefaultFilesOptions.DefaultFileNames    = new[] { "default.html" };
            app.UseFileServer(options);

            app.UseStageMarker(PipelineStage.MapHandler);

            var httpConfiguration = MvcWebApiConfiguration.Configure();

            app.UseWebApi(httpConfiguration);
        }
Example #57
0
        public void Configuration(IAppBuilder app)
        {
            var pathsToIgnore = new[]
            {
                "/",
                "/app/**/*.js",
                "/app/**/*.html",
                "/login",
                "/content",
                "/content/*.*",
                "/fonts/*.*",
                "/scripts/*.js",
            };

            app.RequiresStatelessAuth(new SecureTokenValidator(),
                                      new StatelessAuthOptions {
                IgnorePaths = pathsToIgnore
            });
            app.UseNancy();
            app.UseStageMarker(PipelineStage.MapHandler);
        }
Example #58
0
        public void Configuration(IAppBuilder app)
        {
            var config = new HttpConfiguration();

            // Web API
            app.UseWebApi(config);
            ApiStartup.Register(config);

            // JSON payload by default.
            var appXmlType = config.Formatters.XmlFormatter.SupportedMediaTypes.FirstOrDefault(t => t.MediaType == "application/xml");

            config.Formatters.XmlFormatter.SupportedMediaTypes.Remove(appXmlType);

            app.UseFileServer(new FileServerOptions
            {
                RequestPath = new PathString(string.Empty),
                FileSystem  = new PhysicalFileSystem("./public")
            });

            app.UseStageMarker(PipelineStage.MapHandler);
        }
        // This code configures Web API. The Startup class is specified as a type
        // parameter in the WebApp.Start method.
        public void Configuration(IAppBuilder appBuilder)
        {
            appBuilder.Use((context, next) =>
            {
                context.Response.Headers.Remove("Server");
                return(next.Invoke());
            });
            appBuilder.UseStageMarker(PipelineStage.PostAcquireState);

            // Configure Web API for self-host.
            HttpConfiguration config = new HttpConfiguration();

            //// Web API routes
            config.MapHttpAttributeRoutes();
            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
                );
            appBuilder.UseWebApi(config);
        }
Example #60
-1
        public void Configuration(IAppBuilder app)
        {
            JwtSecurityTokenHandler.InboundClaimTypeMap = new Dictionary<string, string>();

            app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationType = "Cookies" });
            app.UseOpenIdConnectAuthentication(this.OpenIdConnectOptions());
            app.Use(typeof(StatusCodeLoggingMiddleware));
            app.UseNancy();
            app.UseStageMarker(PipelineStage.MapHandler);
        }