示例#1
0
 protected override void ApplicationStartup(Nancy.TinyIoc.TinyIoCContainer container, Nancy.Bootstrapper.IPipelines pipelines)
 {
     base.ApplicationStartup(container, pipelines);
     //是否启用错误显示
     StaticConfiguration.DisableErrorTraces = bool.Parse(System.Configuration.ConfigurationManager.AppSettings["disableError"]);
     CookieBasedSessions.Enable(pipelines);
 }
示例#2
0
 protected override void ApplicationStartup(Nancy.TinyIoc.TinyIoCContainer container, Nancy.Bootstrapper.IPipelines pipelines)
 {
     pipelines.AfterRequest += (ctx) =>
     {
         ctx.Response.Headers.Add("Access-Control-Allow-Origin", "*");
     };
 }
示例#3
0
        protected override void ApplicationStartup(Nancy.TinyIoc.TinyIoCContainer container, Nancy.Bootstrapper.IPipelines pipelines)
        {
            try
            {
                XDocument xDoc = XDocument.Load(HttpContext.Current.Server.MapPath("~/Config/settings.xml"));

                /* Load CloudPanel Settings */
                var settings = from s in xDoc.Elements("Settings")
                               select s;

                foreach (var s in settings)
                {
                    Settings.HostingOU     = s.Element("HostingOU").Value;
                    Settings.PrimaryDC     = s.Element("DomainController").Value;
                    Settings.Username      = s.Element("Username").Value;
                    Settings.Password      = s.Element("Password").Value;
                    Settings.SuperAdmins   = s.Element("SuperAdmins").Value;
                    Settings.BillingAdmins = s.Element("BillingAdmins").Value;
                }

                /* Load Exchange Settings */
                var exchange = from s in xDoc.Elements("Exchange")
                               select s;

                foreach (var s in exchange)
                {
                    Settings.ExchangeServer   = s.Element("Server").Value;
                    Settings.ExchangePFServer = s.Element("PFServer").Value;

                    int defaultVersion = 2013;
                    int.TryParse(s.Element("Version").Value, out defaultVersion);
                    Settings.Version = defaultVersion;

                    bool defaultBool = true;
                    bool.TryParse(s.Element("SSL").Value, out defaultBool);
                    Settings.ExchangeSSL = defaultBool;

                    Settings.ExchangeConnection = s.Element("Connection").Value;
                }
            }
            catch (Exception ex)
            {
                log.Error(ex.ToString());
            }


            CookieBasedSessions.Enable(pipelines);

            base.ApplicationStartup(container, pipelines);

            /*var authenticationConfiguration =
             *  new FormsAuthenticationConfiguration
             *  {
             *      RedirectUrl = "~/login",
             *      UserMapper = container.Resolve<IUserMapper>(),
             *  };
             *
             * FormsAuthentication.Enable(pipelines, authenticationConfiguration);*/
        }
示例#4
0
        protected override void ConfigureApplicationContainer(Nancy.TinyIoc.TinyIoCContainer container)
        {
            base.ConfigureApplicationContainer(container);

            container.Register(typeof(IUserService), typeof(UserService));

            RegisterIViewProjections(container);
            RegisterICommandInvoker(container);

            container.Register(typeof(MongoDatabase), (cContainer, overloads) => Database);
        }
示例#5
0
        protected override void ApplicationStartup(Nancy.TinyIoc.TinyIoCContainer container, Nancy.Bootstrapper.IPipelines pipelines)
        {
            // Cache the settings from the config file in memory
            SettingsRequest.RetrieveSettings();

            // Cache the brandings from the config file in memory
            BrandingsRequest.RetrieveBrandings();

            // Enable cookie based sessions
            CookieBasedSessions.Enable(pipelines);

            base.ApplicationStartup(container, pipelines);
            var authenticationConfiguration =
                new FormsAuthenticationConfiguration
            {
                RedirectUrl = "~/login",
                UserMapper  = container.Resolve <IUserMapper>(),
            };

            FormsAuthentication.Enable(pipelines, authenticationConfiguration);
        }
示例#6
0
        protected override void ApplicationStartup(Nancy.TinyIoc.TinyIoCContainer container, Nancy.Bootstrapper.IPipelines pipelines)
        {
            base.ApplicationStartup(container, pipelines);

            //Enable CSRF protection
            Nancy.Security.Csrf.Enable(pipelines);

            // Enabled cookie sessions
            Nancy.Session.CookieBasedSessions.Enable(pipelines);

            //Setup frame and origin options ( https://www.owasp.org/index.php/List_of_useful_HTTP_headers )
            //may be overwritten by server (apache,ngix,iis,..) for config see https://developer.mozilla.org/en-US/docs/Web/HTTP/X-Frame-Options
            pipelines.AfterRequest.AddItemToEndOfPipeline((ctx) =>
            {
                if (ctx.Response.StatusCode == HttpStatusCode.InternalServerError)
                {
                    return;
                }

                ctx.Response.Headers.Add("X-Frame-Options", "SAMEORIGIN");
                ctx.Response.Headers.Add("X-Download-Options", "noopen"); // IE extension
                ctx.Response.Headers.Add("X-Content-Type-Options", "nosniff");
                ctx.Response.Headers.Add("X-XSS-Protection", "1; mode=block");
            });

            // Retain the casing in serialization of nancy json
            Nancy.Json.JsonSettings.RetainCasing = true;

            StaticConfiguration.CaseSensitive = false;

            // Enable debugging of nancy
            StaticConfiguration.EnableRequestTracing = false;

            // Dummy call to force the include of the Nancy.Serialization.JsonNet dll
            JsonNetSerializer a = new JsonNetSerializer();

            a.CanSerialize("{}");
        }
示例#7
0
 protected override void ApplicationStartup(Nancy.TinyIoc.TinyIoCContainer container, Nancy.Bootstrapper.IPipelines pipelines)
 {
     Wiring.Wire();
     base.ApplicationStartup(container, pipelines);
 }