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); } }
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)); }
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); }
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."); }
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)); }
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."); }
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); }
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); }
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); }
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."); }
public static List <string> GetTenants() { var serializer = new DomainSerializer("DomainsApproved.json"); return(serializer.Get().Select(member => GetDbNameByConvention(member.DomainName)).ToList()); }
public static List <ApprovedDomain> GetDomains() { var serializer = new DomainSerializer("DomainsApproved.json"); return(serializer.Get()); }
public bool IsWellKnownDb() { var serializer = new DomainSerializer("DomainsApproved.json"); var domains = serializer.Get(); return domains.Any(domain => DbConvention.GetCatalog(domain.DomainName) == this.Catalog); }