示例#1
0
 protected override void ApplicationStartup(TinyIoCContainer container, Nancy.Bootstrapper.IPipelines pipelines)
 {
     Conventions.ViewLocationConventions.Add((viewName, model, context) =>
     {
         return(string.Concat(RinDB.VIEW_LOCATION, viewName));
     });
 }
示例#2
0
        protected override void ApplicationStartup(IWindsorContainer container, Nancy.Bootstrapper.IPipelines pipelines)
        {
            //TODO: Uncomment once deployment dashboard work resumes
            //            new DataUpgrade().ExecuteDataUpgrade();

            base.ApplicationStartup(container, pipelines);
        }
 protected override void ApplicationStartup(TinyIoCContainer container, Nancy.Bootstrapper.IPipelines pipelines)
 {
     this.Conventions.ViewLocationConventions.Add((viewName, model, context) =>
     {
         return(string.Concat("content/dist/", viewName));
     });
 }
示例#4
0
        protected override void ApplicationStartup(TinyIoCContainer container, Nancy.Bootstrapper.IPipelines pipelines)
        {
            base.ApplicationStartup(container, pipelines);

            CookieBasedSessions.Enable(pipelines);

            Conventions.ViewLocationConventions.Add((viewName, model, context) => string.Concat("views/", viewName));

            Conventions.StaticContentsConventions.Add(
                StaticContentConventionBuilder.AddDirectory("assets", @"assets")
                );

            container.Register <IFlexUserStore, FlexMembershipUserStore <User, Role> >();
            container.Register(typeof(IDocumentStore), InitDocStore());
            container.Register(typeof(IDocumentSession), (c, overloads) =>
                               c.Resolve <IDocumentStore>().OpenSession());

            var cryptographyConfiguration = new CryptographyConfiguration(
                new RijndaelEncryptionProvider(new PassphraseKeyGenerator(Configuration.EncryptionKey, new byte[] { 8, 2, 10, 4, 68, 120, 7, 14 })),
                new DefaultHmacProvider(new PassphraseKeyGenerator(Configuration.HmacKey, new byte[] { 1, 20, 73, 49, 25, 106, 78, 86 })));

            var authenticationConfiguration =
                new FormsAuthenticationConfiguration()
            {
                CryptographyConfiguration = cryptographyConfiguration,
                RedirectUrl = "/login",
                UserMapper  = container.Resolve <IUserMapper>(),
            };

            FormsAuthentication.Enable(pipelines, authenticationConfiguration);

            FlexMembershipProvider.RegisterClient(
                new GoogleOpenIdClient(),
                "Google", new Dictionary <string, object>());
        }
示例#5
0
        protected override void ApplicationStartup(IContainer container, Nancy.Bootstrapper.IPipelines pipelines)
        {
            base.ApplicationStartup(container, pipelines);

            var config            = container.GetInstance <IAsimovConfig>();
            var tempReportsFolder = Path.Combine(config.TempFolder, "AsimovTempReports");

            GenericFileResponse.SafePaths.Add(tempReportsFolder);

            Conventions.StaticContentsConventions.Add(
                StaticContentConventionBuilder.AddDirectory("temp-reports", tempReportsFolder)
                );

            pipelines.BeforeRequest.AddItemToEndOfPipeline(ctx =>
            {
                if (ctx.Request.Method == "POST")
                {
                    if (ctx.Request.Headers.Authorization != config.ApiKey)
                    {
                        return(401);
                    }
                }

                return(null);
            });
        }
        protected override void RequestStartup(TinyIoCContainer container, Nancy.Bootstrapper.IPipelines pipelines, NancyContext context)
        {
            base.RequestStartup(container, pipelines, context);

            // hooking up filters
            pipelines.BeforeRequest += CheckSomething;
            pipelines.AfterRequest  += ModifyResult;
        }
示例#7
0
        protected override void ApplicationStartup(TinyIoCContainer container, Nancy.Bootstrapper.IPipelines pipelines)
        {
            StaticConfiguration.DisableErrorTraces = false;

            SetupIoC(container);

            base.ApplicationStartup(container, pipelines);
        }
        protected override void ApplicationStartup(Ninject.IKernel container, Nancy.Bootstrapper.IPipelines pipelines)
        {
            base.ApplicationStartup(container, pipelines);


            Conventions.ViewLocationConventions.Add((viewName, model, context) => string.Concat("../../Views/", context.ModuleName.Replace("Controller", ""), "/", viewName));
            Conventions.ViewLocationConventions.Add((viewName, model, context) => string.Concat("Views/", context.ModuleName.Replace("Controller", ""), "/", viewName));
        }
示例#9
0
        protected override void ApplicationStartup(TinyIoCContainer container, Nancy.Bootstrapper.IPipelines pipelines)
        {
            base.ApplicationStartup(container, pipelines);

            var identityProvider    = container.Resolve <IIdentityProvider>();
            var statelessAuthConfig = new StatelessAuthenticationConfiguration(identityProvider.GetUserIdentity);

            StatelessAuthentication.Enable(pipelines, statelessAuthConfig);
        }
示例#10
0
 protected override void ApplicationStartup(TinyIoCContainer container, Nancy.Bootstrapper.IPipelines pipelines)
 {
     //Enable CORS
     pipelines.AfterRequest += (ctx) =>
     {
         ctx.Response.Headers.Add("Access-Control-Allow-Origin", "*");
         ctx.Response.Headers.Add("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
     };
 }
示例#11
0
        protected override void ApplicationStartup(Autofac.ILifetimeScope container, Nancy.Bootstrapper.IPipelines pipelines)
        {
            CookieBasedSessions.Enable(pipelines);
            base.ApplicationStartup(container, pipelines);

            GlobalHost.DependencyResolver = new AutofacDependencyResolver(container);
            RouteTable.Routes.MapHubs();
            PublishrBootstrapper.Init();
        }
示例#12
0
 protected override void ApplicationStartup(IUnityContainer container, Nancy.Bootstrapper.IPipelines pipelines)
 {
     base.ApplicationStartup(container, pipelines);
     Database.SetInitializer(new NoteServiceInitializer());
     AppRuntime.Instance
         .ConfigureApworks()
         .UsingUnityContainerWithDefaultSettings()
         .Create()
         .Start();
 }
示例#13
0
        protected override void ApplicationStartup(TinyIoCContainer container, Nancy.Bootstrapper.IPipelines pipelines)
        {
            base.ApplicationStartup(container, pipelines);

            Nancy.Security.Csrf.Disable(pipelines);
            Nancy.Json.JsonSettings.MaxJsonLength     = int.MaxValue;
            Nancy.Json.JsonSettings.ISO8601DateFormat = false;
            Nancy.Json.JsonSettings.RetainCasing      = true;

            pipelines.OnError.AddItemToStartOfPipeline(ReturnJsonError);
        }
        protected override void ApplicationStartup(ILifetimeScope container, Nancy.Bootstrapper.IPipelines pipelines)
        {
            base.ApplicationStartup(container, pipelines);

            var builder = new ContainerBuilder();

            builder.RegisterType <MockPlayerApplicationService> ().As <IPlayerApplicationService>();
            builder.Update(container.ComponentRegistry);

            StaticConfiguration.DisableErrorTraces = false;
        }
示例#15
0
        protected override void RequestStartup(TinyIoCContainer container, Nancy.Bootstrapper.IPipelines pipelines, NancyContext context)
        {
            base.RequestStartup(container, pipelines, context);

            // Log the API request w/ payload
            if (context.Request.Path.StartsWith("/api", StringComparison.InvariantCulture))
            {
                var todoJson = new StreamReader(context.Request.Body).ReadToEnd();
                logger.Info(context.Request.Method + " " + context.Request.Path + " -> " + todoJson);
            }
        }
示例#16
0
        protected override void RequestStartup(TinyIoC.TinyIoCContainer container, Nancy.Bootstrapper.IPipelines pipelines)
        {
            var formsAuthConfiguration =
                new FormsAuthenticationConfiguration
            {
                RedirectUrl = "~/login",
                UserMapper  = container.Resolve <IUserMapper>(),
            };

            FormsAuthentication.Enable(pipelines, formsAuthConfiguration);
            base.RequestStartup(container, pipelines);
        }
示例#17
0
        protected override void ApplicationStartup(TinyIoCContainer container, Nancy.Bootstrapper.IPipelines pipelines)
        {
            // Add a view location convention that looks for views in a folder
            //  named "views" next to the module class
            //
            this.Conventions.ViewLocationConventions.Add((viewName, model, context) => $"Website/Modules/{context.ModuleName}/views/{viewName}");

            // Add a new path for static content so our typescript files located in
            //  the 'App' folder can be served to SystemJS
            //
            this.Conventions.StaticContentsConventions.Add(StaticContentConventionBuilder.AddDirectory("App"));
        }
示例#18
0
        public static void Initialize(Nancy.Bootstrapper.IPipelines pipelines)
        {
            _apiKey = System.Environment.GetEnvironmentVariable("RHINO_COMPUTE_KEY");
            // If no key has been set as an environment variable, then limiting
            // requests based on a key is disabled
            if (string.IsNullOrWhiteSpace(_apiKey))
            {
                return;
            }

            pipelines.BeforeRequest += CheckApiKey;
        }
示例#19
0
        public static void Initialize(Nancy.Bootstrapper.IPipelines pipelines)
        {
            _apiKey = Config.ApiKey;

            // disable if empty
            if (string.IsNullOrWhiteSpace(_apiKey))
            {
                return;
            }

            pipelines.BeforeRequest += CheckApiKey;
        }
示例#20
0
        protected override void ApplicationStartup(IWindsorContainer container, Nancy.Bootstrapper.IPipelines pipelines)
        {
            base.ApplicationStartup(container, pipelines);

            container.Resolve <Barista>();

            pipelines.BeforeRequest += ctx => CreateSession(container);
            pipelines.BeforeRequest += ServeIndexPage;
            pipelines.AfterRequest  += ctx => CommitSession(container);
            pipelines.OnError       += (ctx, ex) => RollbackSession(container);
            pipelines.OnError       += InvalidOrderOperationHandler;
        }
示例#21
0
        protected override void RequestStartup(Autofac.ILifetimeScope container, Nancy.Bootstrapper.IPipelines pipelines, NancyContext context)
        {
            TokenAuthentication.Enable(pipelines, new TokenAuthenticationConfiguration(container.Resolve<ITokenizer>()));
            pipelines.AfterRequest.AddItemToEndOfPipeline(AddCorsHeaders());

            pipelines.OnError.AddItemToEndOfPipeline((ctx, err) =>
                HandleExceptions(err, ctx)
                );

        
            base.RequestStartup(container, pipelines, context);
        }
示例#22
0
        protected override void ApplicationStartup(TinyIoCContainer container, Nancy.Bootstrapper.IPipelines pipelines)
        {
            this.Conventions.ViewLocationConventions.Add((viewName, model, context) =>
            {
                if (context.ModuleName == null)
                {
                    return("Web/Views/" + viewName);
                }

                var moduleName = context.ModuleName.Replace("Web", "");
                return("Web/Views/" + moduleName + "/" + viewName);
            });
        }
示例#23
0
        protected override void ApplicationStartup(TinyIoCContainer container, Nancy.Bootstrapper.IPipelines pipelines)
        {
            base.ApplicationStartup(container, pipelines);

            // Initialize the database
            logger.Debug("ApplicationStartup: Initializing the database");
            container.Resolve <Database>().Initialize();

            //var identityProvider = container.Resolve<IIdentityProvider>();
            //var statelessAuthConfig = new StatelessAuthenticationConfiguration(identityProvider.GetUserIdentity);

            //StatelessAuthentication.Enable(pipelines, statelessAuthConfig);
        }
        protected override void RequestStartup(TinyIoCContainer requestContainer, Nancy.Bootstrapper.IPipelines pipelines, NancyContext context)
        {
            pipelines.OnError.AddItemToEndOfPipeline((nancyContext, exception) =>
            {
                var errorBytes = Encoding.UTF8.GetBytes(exception.Message);
                return(new Response
                {
                    StatusCode = HttpStatusCode.InternalServerError,
                    ContentType = "text/plain",
                    Contents = stream => stream.Write(errorBytes, 0, errorBytes.Length)
                });
            });

            base.RequestStartup(requestContainer, pipelines, context);
        }
示例#25
0
        protected override void ApplicationStartup(TinyIoCContainer container, Nancy.Bootstrapper.IPipelines pipelines)
        {
            base.ApplicationStartup(container, pipelines);

            // Initialize the database
            logger.Debug("ApplicationStartup: Initializing the database");
            container.Resolve <Database>().Initialize();

            // Register a callback so we can periodically try to register ourselves with the Service Directory.  This is
            // am improper hijack of the request pipeline, but *much* easier than setting up a real background monitor task
            // for prototype development.
            var config = container.Resolve <HostConfigurationSection>();

            pipelines.BeforeRequest.AddItemToStartOfPipeline(RegisterWithServiceDirectory.GetPipelineHook(UPP_IDENTITY, config));
        }
示例#26
0
        protected override void ApplicationStartup(TinyIoCContainer container, Nancy.Bootstrapper.IPipelines pipelines)
        {
            if (ConfigurationManager.AppSettings["RequestTracing"] != null &&
                ConfigurationManager.AppSettings["RequestTracing"].ToLower() == "true")
            {
                StaticConfiguration.EnableRequestTracing = true;
            }

            //does this actually happen after container config?
            var subscriber = container.Resolve <EventStoreSubscriber>();

            subscriber.Start();

            //log catchup progress to every 5s
            var sw        = Stopwatch.StartNew();
            var timer     = new System.Timers.Timer(5000);
            int prevTotal = 0;

            timer.Elapsed += (sender, eventArgs) =>
            {
                if (subscriber.ViewModelsReady)
                {
                    return;
                }

                var progress = subscriber.CatchUpPercentage;

                Logary.Logging.GetCurrentLogger().Info(progress.ToString());

                var last10s = progress.EventsProcessed - prevTotal;

                prevTotal = progress.EventsProcessed;

                Logary.Logging.GetCurrentLogger()
                .LogFormat(LogLevel.Info, "Events per second: Average: {0:0.#}, Last 5s: {1:0.#}",
                           progress.EventsProcessed / (sw.ElapsedMilliseconds / 1000), last10s / 5);
            };
            timer.Start();

            pipelines.BeforeRequest.AddItemToEndOfPipeline(Before);
            pipelines.AfterRequest.AddItemToEndOfPipeline(After);

            pipelines.OnError.AddItemToEndOfPipeline(Error);
            //base.ApplicationStartup(container, pipelines);
        }
示例#27
0
        protected override void ApplicationStartup(TinyIoCContainer container, Nancy.Bootstrapper.IPipelines pipelines)
        {
            base.ApplicationStartup(container, pipelines);

#if !DEBUG
            Cassette.Nancy.CassetteNancyStartup.OptimizeOutput = true;
#endif

            var docStore = container.Resolve <DocumentStore>("DocStore");

            CleanUpDB(docStore);

            pipelines.OnError += (context, exception) =>
            {
                Elmah.ErrorSignal.FromCurrentContext().Raise(exception);
                return(null);
            };
        }
        protected override void ApplicationStartup(TinyIoCContainer container, Nancy.Bootstrapper.IPipelines pipelines)
        {
            StaticConfiguration.Caching.EnableRuntimeViewUpdates = true;

            this.Conventions.ViewLocationConventions.Add((viewName, model, context) =>
            {
                //default is to just cut Model of razor view model type name
                //but we're more explicitly using ViewModel
                viewName = viewName.Replace("View", "");

                //this convention allows you to place your razor views in the same folder as your modules
                return(string.Concat(context.ModuleName, "/", viewName));
            });

            this.Conventions.StaticContentsConventions.Add(
                StaticContentConventionBuilder.AddDirectory("static", @"static")
                );
        }
示例#29
0
        protected override void ApplicationStartup(TinyIoCContainer container, Nancy.Bootstrapper.IPipelines pipelines)
        {
            base.ApplicationStartup(container, pipelines);

            // Initialize the database
            logger.Debug("ApplicationStartup: Initializing the database");
            container.Resolve <Database>().Initialize();

            // Register a callback so we can periodically try to register ourselves with the Service Directory.  This is
            // am improper hijack of the request pipeline, but *much* easier than setting up a real background monitor task
            // for prototype development.
            var config = container.Resolve <HostConfigurationSection>();

            // Add a default value hook to set the default scope to "permit.approval.{Self:Identifier}" if no scope
            // if set in the app.config or command line.
            config.SetDefaultValue(Keys.SERVICE_DIRECTORY__SCOPES, () => String.Format("permit.approval.{0}", config.Keyword(Keys.SELF__IDENTIFIER)));

            pipelines.BeforeRequest.AddItemToStartOfPipeline(RegisterWithServiceDirectory.GetPipelineHook(UPP_IDENTITY, config));
        }
示例#30
0
        protected override void RequestStartup(TinyIoCContainer container, Nancy.Bootstrapper.IPipelines pipelines, NancyContext context)
        {
            base.RequestStartup(container, pipelines, context);

            // 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 = "~/account/logon",
                UserMapper  = container.Resolve <IUserMapper>(),
            };

            FormsAuthentication.Enable(pipelines, formsAuthConfiguration);
        }