示例#1
0
        public void Register()
        {
            try
            {
                var installed = new DomainSerializer("DomainsInstalled.json");

                foreach (var repository in
                    from domain in installed.Get()
                    let catalog = DbConvention.GetDbNameByConvention(domain.DomainName)
                    select new AddInstalledDomainProcedure
                    {
                        DomainName = domain.DomainName,
                        AdminEmail = domain.AdminEmail,
                        SkipValidation = true,
                        _Catalog = catalog
                    })
                {
                    repository.Execute();
                }
            }
            catch (NpgsqlException ex)
            {
                Log.Error("Could not execute AddInstalledDomainProcedure. Exception: {Exception}", ex);
            }
        }
示例#2
0
        public static bool IsValidCatalog(string catalog = "")
        {
            if (string.IsNullOrWhiteSpace(catalog))
            {
                catalog = GetDbNameByConvention(catalog);
            }

            var serializer = new DomainSerializer("domains-approved.json");

            return serializer.Get().Select(GetDbNameByConvention).Any(c => catalog.Equals(c));
        }
示例#3
0
        public static bool IsValidCatalog(string catalog = "")
        {
            if (string.IsNullOrWhiteSpace(catalog))
            {
                catalog = GetDbNameByConvention(catalog);
            }

            var serializer = new DomainSerializer("DomainsApproved.json");

            return serializer.Get().Any(domain => GetDbNameByConvention(domain.DomainName) == catalog);
        }
示例#4
0
        private ActionResult RedirectToInstallationPage()
        {
            string domain = DbConvention.GetDomain();

            var approved = new DomainSerializer("DomainsApproved.json");
            var installed = new DomainSerializer("DomainsInstalled.json");

            bool isApproved = approved.Get().Any(x => x.DomainName.Equals(domain));
            bool isInstalled = installed.Get().Any(x => x.DomainName.Equals(domain));

            if (isApproved && !isInstalled)
            {
                return Redirect("/install");
            }

            return Content("Frapid cannot be installed due configuration errors. Please check application log for more information.");
        }
示例#5
0
        public static string GetDbNameByConvention(string domain = "")
        {
            if (string.IsNullOrWhiteSpace(domain))
            {
                domain = GetDomain();
            }

            Log.Verbose($"Getting tenant name for domain \"{domain}\"");

            var approved = new DomainSerializer("DomainsApproved.json");
            var tenant   = approved.Get().FirstOrDefault(x => x.GetSubtenants().Contains(domain.ToLowerInvariant()));

            if (tenant != null)
            {
                Log.Verbose($"Tenant found for domain \"{domain}\". Tenant domain: \"{tenant.DomainName}\".");
                return(ConvertToDbName(tenant.DomainName));
            }

            return(ConvertToDbName(domain));
        }
示例#6
0
        public ActionResult Index()
        {
            string domain = DbConvention.GetDomain();

            var approved = new DomainSerializer("domains-approved.json");
            var installed = new DomainSerializer("domains-installed.json");

            if (!approved.Get().Contains(domain))
            {
                return this.HttpNotFound();
            }

            if (installed.Get().Contains(domain))
            {
                return this.Redirect("/");
            }

            InstallationFactory.Setup(domain); //Background job
            return this.Content("Installing frapid, please visit the site after a few minutes.");
        }
示例#7
0
        public static string GetBaseDomain(HttpContextBase context, bool includeScheme)
        {
            string domain = context.Request.Url?.DnsSafeHost;

            if (string.IsNullOrWhiteSpace(domain))
            {
                return(string.Empty);
            }

            var    approved   = new DomainSerializer("DomainsApproved.json");
            var    tenant     = approved.Get().FirstOrDefault(x => x.GetSubtenants().Contains(domain.ToLowerInvariant()));
            string domainName = domain;

            if (tenant != null && includeScheme)
            {
                string scheme = context.Request.IsSecureConnection ? "https://" : "http://";
                domainName = scheme + tenant.DomainName;
            }

            return(domainName);
        }
示例#8
0
        public static bool IsValidDomain(string domain = "")
        {
            if (string.IsNullOrWhiteSpace(domain))
            {
                domain = GetDomain();
                Log.Verbose($"The empty domain was automatically resolved to \"{domain}\".");
            }

            var serializer = new DomainSerializer("DomainsApproved.json");


            bool result = serializer.GetTenantMembers().Any(d => d == domain);

            if (!result)
            {
                Log.Information(
                    $"The domain \"{domain}\" was not found on list of approved domains. Please check your configuration");
            }

            return(result);
        }
示例#9
0
        public static bool IsValidTenant(string tenant = "")
        {
            if (string.IsNullOrWhiteSpace(tenant))
            {
                tenant = GetDbNameByConvention(tenant);
                Log.Verbose($"The tenant for empty domain was automatically resolved to \"{tenant}\".");
            }

            var serializer = new DomainSerializer("DomainsApproved.json");


            bool result = serializer.Get().Any(domain => GetDbNameByConvention(domain.DomainName) == tenant);

            if (!result)
            {
                Log.Information(
                    $"The tenant \"{tenant}\" was not found on list of approved domains. Please check your configuration");
            }

            return(result);
        }
示例#10
0
        public ActionResult Index()
        {
            string domain = DbConvention.GetDomain();

            var approved = new DomainSerializer("DomainsApproved.json");
            var installed = new DomainSerializer("DomainsInstalled.json");
           
            if (!approved.Get().Any(x => x.DomainName.Equals(domain)))
            {
                return this.HttpNotFound();
            }

            if (installed.Get().Any(x => x.DomainName.Equals(domain)))
            {
                return this.Redirect("/");
            }

            var setup = approved.Get().FirstOrDefault(x => x.DomainName.Equals(domain));
            InstallationFactory.Setup(setup); //Background job
            return this.Content("Installing frapid, please visit the site after a few minutes.");
        }
示例#11
0
        public static List <string> GetTenants()
        {
            var serializer = new DomainSerializer("DomainsApproved.json");

            return(serializer.Get().Select(member => GetDbNameByConvention(member.DomainName)).ToList());
        }
示例#12
0
        public static List <ApprovedDomain> GetDomains()
        {
            var serializer = new DomainSerializer("DomainsApproved.json");

            return(serializer.Get());
        }
示例#13
0
 public bool IsWellKnownDb()
 {
     var serializer = new DomainSerializer("DomainsApproved.json");
     var domains = serializer.Get();
     return domains.Any(domain => DbConvention.GetCatalog(domain.DomainName) == this.Catalog);
 }