コード例 #1
0
        protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
        {
            base.ApplicationStartup(container, pipelines);

            var announcer = new NullAnnouncer();
            var assembly = Assembly.GetExecutingAssembly();

            var migrationContext = new RunnerContext(announcer)
            {
                Namespace = "Server.Migrations"
            };

            var options = new MigrationOptions();
            var factory = new FluentMigrator.Runner.Processors.SqlServer.SqlServer2008ProcessorFactory();
            var processor = factory.Create(
                ConfigurationManager.ConnectionStrings["Simple.Data.Properties.Settings.DefaultConnectionString"].ConnectionString,
                announcer,
                options);
            var runner = new MigrationRunner(assembly, migrationContext, processor);
            runner.MigrateUp(true);

            pipelines.EnableBasicAuthentication(new BasicAuthenticationConfiguration(new UserValidator(), "CPNRealm"));

            JsonSettings.RetainCasing = true;

            StaticConfiguration.DisableErrorTraces = false;
        }
コード例 #2
0
        protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
        {
            base.ApplicationStartup(container, pipelines);

            pipelines.EnableBasicAuthentication(new BasicAuthenticationConfiguration(
                                                    container.Resolve <IUserValidator>(), "MyRealm"));
        }
コード例 #3
0
        protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
        {
            base.ApplicationStartup(container, pipelines);

            var announcer = new NullAnnouncer();
            var assembly  = Assembly.GetExecutingAssembly();

            var migrationContext = new RunnerContext(announcer)
            {
                Namespace = "Server.Migrations"
            };

            var options   = new MigrationOptions();
            var factory   = new FluentMigrator.Runner.Processors.SqlServer.SqlServer2008ProcessorFactory();
            var processor = factory.Create(
                ConfigurationManager.ConnectionStrings["Simple.Data.Properties.Settings.DefaultConnectionString"].ConnectionString,
                announcer,
                options);
            var runner = new MigrationRunner(assembly, migrationContext, processor);

            runner.MigrateUp(true);

            pipelines.EnableBasicAuthentication(new BasicAuthenticationConfiguration(new UserValidator(), "CPNRealm"));

            JsonSettings.RetainCasing = true;

            StaticConfiguration.DisableErrorTraces = false;
        }
コード例 #4
0
 protected override void ApplicationStartup(TinyIoC.TinyIoCContainer container, IPipelines pipelines)
 {
     base.ApplicationStartup(container, pipelines);
     pipelines.EnableBasicAuthentication(new BasicAuthenticationConfiguration(
         container.Resolve<IUserValidator>(),
         "NancyFx"));
 }
コード例 #5
0
ファイル: Program.cs プロジェクト: carverh/ShiftOS-1
        protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
        {
            base.ApplicationStartup(container, pipelines);

            pipelines.EnableBasicAuthentication(new BasicAuthenticationConfiguration(
                                                    container.Resolve <MUDUserValidator>(),
                                                    "MUD", UserPromptBehaviour.NonAjax));
        }
コード例 #6
0
        protected override void RequestStartup(ILifetimeScope container, IPipelines pipelines, NancyContext context)
        {
            base.RequestStartup(container, pipelines, context);


            pipelines.EnableBasicAuthentication(new BasicAuthenticationConfiguration(
                                                    container.Resolve <IUserValidator>(),
                                                    "MyRealm"));


            BindingConfig.Default.IgnoreErrors = true;
        }
コード例 #7
0
        protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
        {
            base.ApplicationStartup(container, pipelines);
            pipelines.EnableBasicAuthentication(new BasicAuthenticationConfiguration(new BasicUserValidator(), "GOIMP WebAPI"));

            pipelines.AfterRequest.AddItemToEndOfPipeline(context =>
            {
                context.Response.WithHeader("Access-Control-Allow-Origin", "*")
                .WithHeader("Access-Control-Allow-Methods", "GET, POST")
                .WithHeader("Access-Control-Allow-Headers", "Content-Type");
            });
        }
コード例 #8
0
        protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
        {
            base.ApplicationStartup(container, pipelines);
            CMSApplication.Init();
            TypeAdapterConfig <DataClassInfo, BridgeClassInfo> .NewConfig()
            .Ignore(dest => dest.AssignedSites)
            .Ignore(dest => dest.AllowedChildTypes)
            ;

            var userValidator = container.Resolve <IUserValidator>();

            pipelines.EnableBasicAuthentication(new BasicAuthenticationConfiguration(userValidator, "BridgeRealm"));
        }
コード例 #9
0
        protected override void ApplicationStartup(ILifetimeScope container, IPipelines pipelines)
        {
            base.ApplicationStartup(container, pipelines);

            pipelines.EnableBasicAuthentication(new BasicAuthenticationConfiguration(
                                                    container.Resolve <IUserValidator>(),
                                                    "Einstein",
                                                    UserPromptBehaviour.Never));

            IAppConfig appConfig = container.Resolve <IAppConfig>();

            pipelines.EnableCORS(appConfig);
        }
コード例 #10
0
        protected override void ApplicationStartup(TinyIoC.TinyIoCContainer container, IPipelines pipelines)
        {
            base.ApplicationStartup(container, pipelines);

            pipelines.EnableBasicAuthentication(new BasicAuthenticationConfiguration(
                                                    container.Resolve<IUserValidator>(),
                                                    "RateAllTheThings"));

            pipelines.OnError += (context, exception) =>
            {
                exception.SendToAirbrake();
                return null;
            };
        }
コード例 #11
0
        protected override void ApplicationStartup(TinyIoC.TinyIoCContainer container, IPipelines pipelines)
        {
            base.ApplicationStartup(container, pipelines);

            pipelines.EnableBasicAuthentication(new BasicAuthenticationConfiguration(
                                                    container.Resolve <IUserValidator>(),
                                                    "RateAllTheThings"));

            pipelines.OnError += (context, exception) =>
            {
                exception.SendToAirbrake();
                return(null);
            };
        }
コード例 #12
0
        protected override void ApplicationStartup(CompositionContainer container, IPipelines pipelines)
        {
            base.ApplicationStartup(container, pipelines);

            CookieBasedSessions.Enable(pipelines);

            pipelines.EnableBasicAuthentication(new BasicAuthenticationConfiguration(
                                                    container.GetExportedValue <IUserValidator>(),
                                                    "IDPJobManager"));

            ResourceViewLocationProvider.RootNamespaces.Add(Assembly.GetExecutingAssembly(), "IDPJobManager.Web.Views");

            ResourceViewLocationProvider.Ignore.Add(typeof(Nancy.ViewEngines.Razor.RazorViewEngine).Assembly);
        }
コード例 #13
0
        protected override void RequestStartup(TinyIoCContainer container, IPipelines pipelines, NancyContext context)
        {
            base.RequestStartup(container, pipelines, context);

            if (context.Request.Path.StartsWith("/auth"))
            {
                pipelines.EnableBasicAuthentication(
                    new BasicAuthenticationConfiguration(
                        new Auth.BasicAuthUserValidator(),
                        "H-Playground-NancyWebApi",
                        UserPromptBehaviour.Never
                        )
                    );
            }
        }
コード例 #14
0
        public void Register(IPipelines pipelines)
        {
            if (_configFileProvider.AuthenticationMethod == AuthenticationType.Forms)
            {
                RegisterFormsAuth(pipelines);
            }

            else if (_configFileProvider.AuthenticationMethod == AuthenticationType.Basic)
            {
                pipelines.EnableBasicAuthentication(new BasicAuthenticationConfiguration(_authenticationService, "Sonarr"));
            }

            pipelines.BeforeRequest.AddItemToEndOfPipeline((Func <NancyContext, Response>)RequiresAuthentication);
            pipelines.AfterRequest.AddItemToEndOfPipeline((Action <NancyContext>)RemoveLoginHooksForApiCalls);
        }
コード例 #15
0
        protected override void ApplicationStartup(IWindsorContainer container, IPipelines pipelines)
        {
            // No registrations should be performed in here, however you may
            // resolve things that are needed during application startup.

            base.ApplicationStartup(container, pipelines);

            container.Register(Component
                               .For <IUserValidator>()
                               .ImplementedBy <UserValidator>());

            pipelines.EnableBasicAuthentication(new BasicAuthenticationConfiguration(
                                                    container.Resolve <IUserValidator>(),
                                                    "MyRealm"));
        }
コード例 #16
0
        public void Register(IPipelines pipelines)
        {
            if (_configFileProvider.AuthenticationMethod == AuthenticationType.Forms)
            {
                RegisterFormsAuth(pipelines);
            }

            else if (_configFileProvider.AuthenticationMethod == AuthenticationType.Basic)
            {
                pipelines.EnableBasicAuthentication(new BasicAuthenticationConfiguration(_authenticationService, "Sonarr"));
            }

            pipelines.BeforeRequest.AddItemToEndOfPipeline((Func<NancyContext, Response>) RequiresAuthentication);
            pipelines.AfterRequest.AddItemToEndOfPipeline((Action<NancyContext>) RemoveLoginHooksForApiCalls);
        }
コード例 #17
0
        public void Register(IPipelines pipelines)
        {
            if (_configFileProvider.AuthenticationMethod == AuthenticationType.Forms)
            {
                RegisterFormsAuth(pipelines);
                pipelines.AfterRequest.AddItemToEndOfPipeline(SlidingAuthenticationForFormsAuth);
            }
            else if (_configFileProvider.AuthenticationMethod == AuthenticationType.Basic)
            {
                pipelines.EnableBasicAuthentication(new BasicAuthenticationConfiguration(_authenticationService, BuildInfo.AppName));
                pipelines.BeforeRequest.AddItemToStartOfPipeline(CaptureContext);
            }

            pipelines.BeforeRequest.AddItemToEndOfPipeline(RequiresAuthentication);
            pipelines.AfterRequest.AddItemToEndOfPipeline(RemoveLoginHooksForApiCalls);
        }
コード例 #18
0
        protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
        {
            base.ApplicationStartup(container, pipelines);

            pipelines.EnableBasicAuthentication(new BasicAuthenticationConfiguration(
                        container.Resolve<IUserValidator>(),
                        "Couchbase XDCR"));

            StaticConfiguration.EnableRequestTracing = true;

            NancyInternalConfiguration.WithOverrides(c =>
                {
                    c.StatusCodeHandlers.Clear();
                    c.StatusCodeHandlers.Add(typeof(StatusCodeHandler));
                }
            );

            container.Register<IReplicationHandler>(new XmlReplicator());
        }
コード例 #19
0
        protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
        {
            base.ApplicationStartup(container, pipelines);

            pipelines.EnableBasicAuthentication(new BasicAuthenticationConfiguration(
                                                    container.Resolve <IUserValidator>(),
                                                    "Couchbase XDCR"));

            StaticConfiguration.EnableRequestTracing = true;

            NancyInternalConfiguration.WithOverrides(c =>
            {
                c.StatusCodeHandlers.Clear();
                c.StatusCodeHandlers.Add(typeof(StatusCodeHandler));
            }
                                                     );

            container.Register <IReplicationHandler>(new XmlReplicator());
        }
コード例 #20
0
        protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
        {
            base.ApplicationStartup(container, pipelines);

            pipelines.EnableBasicAuthentication(new BasicAuthenticationConfiguration(
                                                    container.Resolve <IUserValidator>(),
                                                    "MyRealm"));

            pipelines.OnError += (ctx, e) =>
            {
                return(new Response().WithStatusCode(HttpStatusCode.InternalServerError));
            };
            pipelines.BeforeRequest += ctx =>
            {
                return(null);
            };
            pipelines.AfterRequest += ctx =>
            {
            };
        }
コード例 #21
0
        protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
        {
            base.ApplicationStartup(container, pipelines);
            SwaggerMetadataProvider.SetInfo("IDP Job APIs", "v0.1", "Our job service", new Contact()
            {
                EmailAddress = "*****@*****.**"
            });

            pipelines.AfterRequest.AddItemToEndOfPipeline(x => x.Response.Headers.Add("Access-Control-Allow-Origin", "*"));

            CookieBasedSessions.Enable(pipelines);

            pipelines.EnableBasicAuthentication(new BasicAuthenticationConfiguration(
                                                    container.Resolve <IUserValidator>(),
                                                    "IDPJobManager"));

            ResourceViewLocationProvider.RootNamespaces.Add(Assembly.GetExecutingAssembly(), "IDPJobManager.Web.Views");

            ResourceViewLocationProvider.Ignore.Add(typeof(Nancy.ViewEngines.Razor.RazorViewEngine).Assembly);
        }
コード例 #22
0
        protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
        {
            PerformanceData.Run();

            var host = TinyIoCContainer.Current.Resolve <IHost>();

            pipelines.EnableBasicAuthentication(new BasicAuthenticationConfiguration(container.Resolve <IUserValidator>(), "Servant"));
            CookieBasedSessions.Enable(pipelines);

            var sw = new Stopwatch();

            pipelines.BeforeRequest.InsertBefore("DebuggingStart", nancyContext =>
            {
                sw.Reset();
                sw.Start();

                return(nancyContext.Response);
            });

            // Irriterede mig at den ikke returnerede UTF8
            pipelines.AfterRequest.InsertAfter("EncodingFix", nancyContext =>
            {
                if (nancyContext.Response.ContentType == "text/html")
                {
                    nancyContext.Response.ContentType = "text/html; charset=utf8";
                }
            });

            pipelines.AfterRequest.InsertAfter("DebuggingEnd", ctx =>
            {
                sw.Stop();
                if (host.Debug)
                {
                    Console.ForegroundColor = ConsoleColor.DarkGray;
                    Console.WriteLine(DateTime.Now.ToLongTimeString() + ": " + ctx.Request.Method + " " + ctx.Request.Url + "(" + sw.ElapsedMilliseconds + "ms)");
                    Console.ResetColor();
                }
            });

            base.ApplicationStartup(container, pipelines);
        }
コード例 #23
0
ファイル: ServiceStartup.cs プロジェクト: r3xakead0/CakeBoss
        public void Initialize(IPipelines pipelines)
        {
            pipelines.EnableBasicAuthentication(new BasicAuthenticationConfiguration(Program.Container.GetInstance <IUserValidator>(), "CakeBoss", UserPromptBehaviour.NonAjax));

            pipelines.OnError.AddItemToEndOfPipeline((context, exception) =>
            {
                //Log Error
                ICakeLog log = Program.Container.GetInstance <ICakeLog>();

                log.Error(exception.Message);



                //Return Response
                Response response = new JsonResponse(exception.Message, Program.Container.GetInstance <ISerializer>());

                response.StatusCode = HttpStatusCode.InternalServerError;

                return(response);
            });
        }
コード例 #24
0
ファイル: Bootstrapper.cs プロジェクト: ohde/servant
        protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
        {
            PerformanceData.Run();

            var host = TinyIoCContainer.Current.Resolve<IHost>();

            pipelines.EnableBasicAuthentication(new BasicAuthenticationConfiguration(container.Resolve<IUserValidator>(), "Servant"));
            CookieBasedSessions.Enable(pipelines);
            
            var sw = new Stopwatch();

            pipelines.BeforeRequest.InsertBefore("DebuggingStart", nancyContext => 
            {
                sw.Reset();
                sw.Start();
                
                return nancyContext.Response;
            });
            
            // Irriterede mig at den ikke returnerede UTF8
            pipelines.AfterRequest.InsertAfter("EncodingFix", nancyContext =>
            {
                if (nancyContext.Response.ContentType == "text/html")
                    nancyContext.Response.ContentType = "text/html; charset=utf8";
            });

            pipelines.AfterRequest.InsertAfter("DebuggingEnd", ctx =>
            {
                sw.Stop();
                if (host.Debug)
                {
                    Console.ForegroundColor = ConsoleColor.DarkGray;
                    Console.WriteLine(DateTime.Now.ToLongTimeString() + ": " + ctx.Request.Method + " " + ctx.Request.Url + "(" + sw.ElapsedMilliseconds + "ms)");
                    Console.ResetColor();
                }
            });

            base.ApplicationStartup(container, pipelines);
        }
コード例 #25
0
        protected override void ApplicationStartup(IServiceContainer container, IPipelines pipelines)
        {
            base.ApplicationStartup(container, pipelines);

            pipelines.EnableBasicAuthentication(new BasicAuthenticationConfiguration(container.GetInstance <IUserValidator>(), "CakeBoss", UserPromptBehaviour.NonAjax));

            pipelines.OnError.AddItemToEndOfPipeline((context, exception) =>
            {
                //Log Error
                ICakeLog log = container.GetInstance <ICakeLog>();

                log.Error(exception.Message);



                //Return Response
                Response response = new JsonResponse(exception.Message, container.GetInstance <ISerializer>());

                response.StatusCode = HttpStatusCode.InternalServerError;

                return(response);
            });
        }
コード例 #26
0
 public void Register(IPipelines pipelines)
 {
     pipelines.EnableBasicAuthentication(new BasicAuthenticationConfiguration(_authenticationService, "NzbDrone"));
     pipelines.BeforeRequest.AddItemToEndOfPipeline(RequiresAuthentication);
 }
コード例 #27
0
ファイル: Bootstrapper.cs プロジェクト: Ocerra/Integration
        protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
        {
            try
            {
                JsonConvert.DefaultSettings = () => new JsonSerializerSettings
                {
                    DateFormatHandling = DateFormatHandling.IsoDateFormat,
                    DateTimeZoneHandling = DateTimeZoneHandling.Unspecified,
                    StringEscapeHandling = StringEscapeHandling.EscapeHtml,
                    NullValueHandling = NullValueHandling.Ignore,
                    Formatting = Formatting.Indented,
                    Converters = new List<JsonConverter> {
                    new OdooKeyValueJsonConverter(),
                    new OdooStringJsonConverter(),
                    new OdooDateJsonConverter(),
                    new OdooDecimalJsonConverter(),
                    new OdooObjectArrayJsonConverter()
                },
                    MaxDepth = 10,
                    ReferenceLoopHandling = ReferenceLoopHandling.Ignore
                };

                base.ApplicationStartup(container, pipelines);

                pipelines.EnableBasicAuthentication(new BasicAuthenticationConfiguration(
                    container.Resolve<IUserValidator>(),
                    "MyRealm"));

                container.Register((c, p) =>
                {
                    var httpClient = new HttpClient()
                    {
                        BaseAddress = new Uri(Settings.Default.OcerraUrl),
                    };

                    httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Settings.Default.OcerraApiKey);

                    return new OcerraClient(httpClient);
                });

                container.Register((c, p) =>
                {
                    return new OdooRpcClient(new OdooRpc.CoreCLR.Client.Models.OdooConnectionInfo
                    {
                        Database = Settings.Default.OdooDatabase,
                        Host = Settings.Default.OdooUrl,
                        Username = Settings.Default.OdooLogin,
                        Password = Settings.Default.OdooBase64Pwd.FromBase64(),
                        Port = Settings.Default.OdooPort,
                        IsSSL = Settings.Default.OdooSsl
                    });
                });

                container.Register<OdataProxy>();

                var initTask = Task.Run(async () => {
                    await InitModels(container);
                    Scheduler = new SchedulerService();
                    await Scheduler.Init(); // start scheduler here
                });

                initTask.Wait(TimeSpan.FromSeconds(15));

                if (!initTask.IsCompleted)
                    throw new Exception("Init task has not been complete");

                Bootstrapper.Container = container;
            }
            catch (Exception ex) {
                ex.LogError("There was an error in App Startup function");
            }
            

        }
コード例 #28
0
        protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
        {
            base.ApplicationStartup(container, pipelines);

            pipelines.EnableBasicAuthentication(new BasicAuthenticationConfiguration(new UserValidator(), "Nusharp", UserPromptBehaviour.Always));
        }
コード例 #29
0
        protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
        {
            base.ApplicationStartup(container, pipelines);

            pipelines.EnableBasicAuthentication(new BasicAuthenticationConfiguration(new UserValidator(), "Nusharp", UserPromptBehaviour.Always));
        }
コード例 #30
0
        protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
        {
            Register(container);
            if (_environment.Name == EnvironmentType.Production)
            {
                RegisterMonoPersistence(container);
            }
            else
            {
                RegisterPersistence(container);
            }



            RegisterRepository(container);
            RegisterCrypo(container);


            pipelines.OnError += (ctx, ex) =>
            {
                container.Resolve <IMetric>().Count("error");
                Logger.Error(ex);
                var isAjaxRequest = ctx.Request.IsAjaxRequest();

                if (isAjaxRequest)
                {
                    var result = new JObject
                    {
                        { "isSuccess", false },
                        { "data", "Internal error" }
                    };

                    var newContent = result.ToString();
                    var output     = Encoding.UTF8.GetBytes(newContent);

                    return(new Response
                    {
                        Contents = stream => stream.Write(output, 0, output.Length),
                        ContentType = "application/json",
                        StatusCode = HttpStatusCode.InternalServerError
                    });
                }

                return(null);
            };
            pipelines.AfterRequest += (ctx) =>
            {
                var isAjaxRequest  = ctx.Request.IsAjaxRequest();
                var isJsonResponse = ctx.Response.ContentType.Contains("json");

                if (isAjaxRequest && isJsonResponse)
                {
                    using (var memStream = new MemoryStream())
                    {
                        ctx.Response.Contents.Invoke(memStream);
                        var textResponse = Encoding.UTF8.GetString(memStream.ToArray());

                        var result = new JObject();
                        if (TryParseJObject(textResponse, out var jo))
                        {
                            result = new JObject
                            {
                                { "isSuccess", true },
                                { "data", jo }
                            };
                        }
                        else if (TryParseJArray(textResponse, out var ja))
                        {
                            result = new JObject
                            {
                                { "isSuccess", true },
                                { "data", ja }
                            };
                        }
                        var newContent = result.ToString();
                        var output     = Encoding.UTF8.GetBytes(newContent);

                        ctx.Response.Contents = stream => stream.Write(output, 0, output.Length);
                    }
                }
            };

            var hmacProvider       = container.Resolve <IHmacProvider>();
            var adminRepository    = container.Resolve <IAdminRepository>();
            var adminUserValidator = new AdminUserValidator(hmacProvider, adminRepository, _environment);

            pipelines.EnableBasicAuthentication(new BasicAuthenticationConfiguration(adminUserValidator, "admin"));
        }
コード例 #31
0
 protected override void ApplicationStartup(TinyIoC.TinyIoCContainer container, IPipelines pipeline)
 {
     container.Register<IAccountService, AccountService>().AsSingleton();
     base.ApplicationStartup(container, pipeline);
     pipeline.EnableBasicAuthentication(new BasicAuthenticationConfiguration(container.Resolve<IUserValidator>(),"AgbaraVOIP"));
 }
コード例 #32
0
 protected override void ApplicationStartup(TinyIoC.TinyIoCContainer container, IPipelines pipeline)
 {
     container.Register <IAccountService, AccountService>().AsSingleton();
     base.ApplicationStartup(container, pipeline);
     pipeline.EnableBasicAuthentication(new BasicAuthenticationConfiguration(container.Resolve <IUserValidator>(), "AgbaraVOIP"));
 }
コード例 #33
0
ファイル: App.cs プロジェクト: perokvist/messageVault
			protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
			{
				base.ApplicationStartup(container, pipelines);

				var configuration = new BasicAuthenticationConfiguration(
					container.Resolve<IUserValidator>(),
						"MessageVault"
						);
				pipelines.EnableBasicAuthentication(configuration);
			}
コード例 #34
0
        protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
        {
            try
            {
                base.ApplicationStartup(container, pipelines);

                pipelines.EnableBasicAuthentication(new BasicAuthenticationConfiguration(
                                                        container.Resolve <IUserValidator>(),
                                                        "MyRealm"));

                var httpClient = new HttpClient()
                {
                    BaseAddress = new Uri(ConfigurationManager.AppSettings["WorkbenchUrl"])
                };

                httpClient.DefaultRequestHeaders.Authorization = !string.IsNullOrEmpty(ConfigurationManager.AppSettings["WorkbenchApiKey"]) ?
                                                                 new AuthenticationHeaderValue("Bearer ", ConfigurationManager.AppSettings["WorkbenchApiKey"]) :
                                                                 new AuthenticationHeaderValue("Basic", (ConfigurationManager.AppSettings["WorkbenchUserName"] + ":" + ConfigurationManager.AppSettings["WorkbenchPassword"].FromBase64()).ToBase64());

                var sapClient   = ServerConnection.Current;
                var wbtrfClient = new WorkbenchTrfClient(new HttpClient());
                var client      = new Client(httpClient);
                var company     = sapClient.GetCompany();

                container.Register((c, p) =>
                {
                    return(new Client(httpClient));
                });

                container.Register((c, p) =>
                {
                    return(ServerConnection.Current);
                });

                container.Register((c, p) =>
                {
                    return(ServerConnection.Current.GetCompany());
                });


                container.Register((c, p) =>
                {
                    return(new ImportBase(client, company, wbtrfClient));
                });


                container.Register((c, p) =>
                {
                    return(new ExportBase(client, company, wbtrfClient));
                });


                container.Register((c, p) =>
                {
                    return(new ExportJobs(client, company, wbtrfClient));
                });

                container.Register((c, p) =>
                {
                    return(new ExportClient(new ExportJobs(client, company, wbtrfClient),
                                            new ExportGLJournals(client, company, wbtrfClient),
                                            new ExportAPInvoices(client, company, wbtrfClient),
                                            new ExportARInvoices(client, company, wbtrfClient)));
                });

                container.Register((c, p) =>
                {
                    return(new ExportProcessBatch(new ExportJobs(client, company, wbtrfClient),
                                                  new ExportGLJournals(client, company, wbtrfClient),
                                                  new ExportAPInvoices(client, company, wbtrfClient),
                                                  new ExportARInvoices(client, company, wbtrfClient)));
                });

                container.Register((c, p) =>
                {
                    return(new ExportAPInvoices(client, company, wbtrfClient));
                });

                current = (ExportClient)container.Resolve(typeof(ExportClient));
            }
            catch (Exception ex)
            {
                Helpers.LogAppError($"{ex.InnerException} {ex.Message}");
            }
        }
コード例 #35
0
 private static void EnableAuthentication(ILifetimeScope container, IPipelines pipelines)
 {
     pipelines.EnableBasicAuthentication(
         new BasicAuthenticationConfiguration(container.Resolve <IUserValidator>(), "Realm"));
 }
コード例 #36
0
 public void Register(IPipelines pipelines)
 {
     pipelines.EnableBasicAuthentication(new BasicAuthenticationConfiguration(_authenticationService, "NzbDrone"));
     pipelines.BeforeRequest.AddItemToEndOfPipeline(RequiresAuthentication);
 }