示例#1
0
 protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
 {
     base.ApplicationStartup(container, pipelines);
     //CookieBasedSessions.Enable(pipelines);
     StaticConfiguration.DisableErrorTraces = false;
     SSLProxy.RewriteSchemeUsingForwardedHeaders(pipelines);
 }
        protected override void RequestStartup(IWindsorContainer container, IPipelines pipelines, NancyContext context)
        {
            SSLProxy.RewriteSchemeUsingForwardedHeaders(pipelines);

#if SKIPAUTH
            var statelessAuthenticationConfiguration = new StatelessAuthenticationConfiguration(ctx =>
            {
                var userMapper = container.Resolve <IUserMapper>();
                return(userMapper.GetUserFromIdentifier(Guid.Empty, null));
            });
            StatelessAuthentication.Enable(pipelines, statelessAuthenticationConfiguration);
#else
            FormsAuthenticationConfiguration formsAuthConfiguration;
            try
            {
                var userMapper = container.Resolve <IUserMapper>();

                formsAuthConfiguration = new FormsAuthenticationConfiguration
                {
                    UserMapper  = userMapper,
                    RedirectUrl = "~/login"
                };
            }
            catch (Exception e)
            {
                this.logger.Error("Error getting user mapper", e);
                throw;
            }

            FormsAuthentication.Enable(pipelines, formsAuthConfiguration);
#endif
        }
        /// <remarks>
        /// Offloading ssl onto nginx and forwarding. The below modification to the behavior of the
        /// application bootstrapper enables Nancy to listen for the XForwardedProto header.  See
        /// http://stackoverflow.com/questions/29634033/nancyfx-ssl-how-to-make-this-requirehttps-work-on-linux
        /// </reamarks>
        protected override void RequestStartup(TinyIoCContainer requestContainer, IPipelines pipelines, NancyContext context)
        {
            var authConfiguration = new StatelessAuthenticationConfiguration(nancyContext =>
            {
                var sessionToken = (string)nancyContext.Request.Query.session_token?.Value;
                return(SessionTokenManager.GetUserClaimsFromSessionToken(sessionToken).Result);
            });

            AllowAccessToConsumingSite(pipelines);
            SSLProxy.RewriteSchemeUsingForwardedHeaders(pipelines);
            StatelessAuthentication.Enable(pipelines, authConfiguration);
        }
示例#4
0
        protected override void RequestStartup(TinyIoCContainer requestContainer, IPipelines pipelines, NancyContext context)
        {
            //pipelines.BeforeRequest.AddItemToStartOfPipeline(SecurityHooks.RequiresHttps(true, 443));
            SSLProxy.RewriteSchemeUsingForwardedHeaders(pipelines);
            // At request startup we modify the request pipelines to
            // include forms authentication - passing in our now request
            // scoped user name mapper.
            //
            // The pipelines passed in here are specific to this request,
            // so we can add/remove/update items in them as we please.
            var formsAuthConfiguration =
                new FormsAuthenticationConfiguration()
            {
                RedirectUrl = "~/admin",
                UserMapper  = requestContainer.Resolve <IUserMapper>(),
            };

            FormsAuthentication.Enable(pipelines, formsAuthConfiguration);
        }
        protected override void ApplicationStartup(ILifetimeScope container, IPipelines pipelines)
        {
            base.ApplicationStartup(container, pipelines);
            SSLProxy.RewriteSchemeUsingForwardedHeaders(pipelines);
            var consumerKeys          = container.Resolve <IConsumerKeys>();
            var unauthenticatedRoutes = new List <string>
            {
                "/authentication/login"
            };
            var anonmyousRoutes = new List <string>();

            pipelines.BeforeRequest += context =>
            {
                RequestLog.InfoNancyRequest(context);
                return(RequestAuthentication.Authenticate(context, consumerKeys, unauthenticatedRoutes, anonmyousRoutes,
                                                          ApplicationSettings.JwtIssuer, ApplicationSettings.SecretKey)
                    ? (Response)null
                    : HttpStatusCode.Unauthorized);
            };
            pipelines.AfterRequest += context => { ResponseLog.InfoNancyResponse(context); };
        }
示例#6
0
        public SSLProxyFixture()
        {
            this.pipelines = new MockPipelines();

            SSLProxy.RewriteSchemeUsingForwardedHeaders(this.pipelines);
        }
 protected override void RequestStartup(TinyIoCContainer container, IPipelines pipelines, NancyContext context)
 {
     base.RequestStartup(container, pipelines, context);
     SSLProxy.RewriteSchemeUsingForwardedHeaders(pipelines);
 }