protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
        {
            CookieBasedSessions.Enable(pipelines, CryptographyConfiguration.Default);

            StaticConfiguration.DisableErrorTraces = false;

            base.ApplicationStartup(container, pipelines);

            var settings = new SettingsServiceV2 <PlexRequestSettings>(new SettingsJsonRepository(new DbConfiguration(new SqliteFactory()), new MemoryCacheProvider()));
            var baseUrl  = settings.GetSettings().BaseUrl;
            var redirect = string.IsNullOrEmpty(baseUrl) ? "~/login" : $"~/{baseUrl}/login";

            // Enable forms auth
            var formsAuthConfiguration = new FormsAuthenticationConfiguration
            {
                RedirectUrl = redirect,
                UserMapper  = container.Resolve <IUserMapper>()
            };

            FormsAuthentication.Enable(pipelines, formsAuthConfiguration);

            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls;
            ServicePointManager.ServerCertificateValidationCallback +=
                (sender, certificate, chain, sslPolicyErrors) => true;
        }
Esempio n. 2
0
        protected override void ApplicationStartup(IKernel container, IPipelines pipelines)
        {
            Debug.WriteLine("Bootstrapper.ApplicationStartup");
            ConfigureContainer(container);

            JsonSettings.MaxJsonLength = int.MaxValue;

            CookieBasedSessions.Enable(pipelines, CryptographyConfiguration.Default);
            StaticConfiguration.DisableErrorTraces = false;

            base.ApplicationStartup(container, pipelines);


            var settings = new SettingsServiceV2 <PlexRequestSettings>(new SettingsJsonRepository(new DbConfiguration(new SqliteFactory()), new MemoryCacheProvider()));
            var baseUrl  = settings.GetSettings().BaseUrl;
            var redirect = string.IsNullOrEmpty(baseUrl) ? "~/login" : $"~/{baseUrl}/login";

            // Enable forms auth
            var config = new CustomAuthenticationConfiguration
            {
                RedirectUrl         = redirect,
                PlexUserRepository  = container.Get <IPlexUserRepository>(),
                LocalUserRepository = container.Get <IUserRepository>()
            };

            CustomAuthenticationProvider.Enable(pipelines, config);

            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls;
            ServicePointManager.ServerCertificateValidationCallback +=
                (sender, certificate, chain, sslPolicyErrors) => true;

            ServicePointManager.Expect100Continue = false;
        }
Esempio n. 3
0
        private static void SetupLogging()
        {
            var settingsService = new SettingsServiceV2 <LogSettings>(new SettingsJsonRepository(new DbConfiguration(new SqliteFactory()), new MemoryCacheProvider()));
            var logSettings     = settingsService.GetSettings();

            LoggingHelper.ReconfigureLogLevel(logSettings != null ? LogLevel.FromOrdinal(logSettings.Level) : LogLevel.FromOrdinal(4));
        }
        protected override void ConfigureConventions(NancyConventions nancyConventions)
        {
            base.ConfigureConventions(nancyConventions);

            var settings      = new SettingsServiceV2 <PlexRequestSettings>(new SettingsJsonRepository(new DbConfiguration(new SqliteFactory()), new MemoryCacheProvider()));
            var assetLocation = settings.GetSettings().BaseUrl;

            nancyConventions.StaticContentsConventions.Add(
                StaticContentConventionBuilder.AddDirectory($"{assetLocation}/Content", "Content")
                );
        }
        public static void UpdateSettings <T>(T settings) where T : Settings, new()
        {
            var service = new SettingsServiceV2 <T>(_jsonRepository);

            if (settings == null)
            {
                var existing = service.GetSettings();
                service.Delete(existing);
                return;
            }
            service.SaveSettings(settings);
        }
Esempio n. 6
0
        private static int GetStartupPort()
        {
            Log.Trace("Getting startup Port");
            var port     = 3579;
            var service  = new SettingsServiceV2 <PlexRequestSettings>(new SettingsJsonRepository(new DbConfiguration(new SqliteFactory()), new MemoryCacheProvider()));
            var settings = service.GetSettings();

            Log.Trace("Port: {0}", settings.Port);
            if (settings.Port != 0)
            {
                port = settings.Port;
            }

            return(port);
        }
Esempio n. 7
0
        protected override void ConfigureConventions(NancyConventions nancyConventions)
        {
            Debug.WriteLine("Configuring the conventions");
            base.ConfigureConventions(nancyConventions);

            var settingsService = new SettingsServiceV2 <PlexRequestSettings>(new SettingsJsonRepository(new DbConfiguration(new SqliteFactory()), new MemoryCacheProvider()));
            var settings        = settingsService.GetSettings();
            var assetLocation   = string.Empty;

            if (!string.IsNullOrEmpty(settings.BaseUrl))
            {
                assetLocation = $"{settings.BaseUrl}/";
            }

            Debug.WriteLine($"AssetLocation {assetLocation}");

            nancyConventions.StaticContentsConventions.AddDirectory($"{assetLocation}Content", "Content");
            nancyConventions.StaticContentsConventions.AddDirectory($"{assetLocation}docs", "swagger-ui");
            nancyConventions.StaticContentsConventions.AddDirectory($"{assetLocation}fonts", "Content/fonts");
        }