示例#1
0
        internal static string ToCdnResource(string path)
        {
            if(!path.StartsWith("/") ||
               path.StartsWith("//") ||
               path.ToLowerInvariant().StartsWith("/signalr"))
            {
                return path;
            }

            var approved = new ApprovedDomainSerializer();
            var tenant = approved.Get().FirstOrDefault(x => x.GetSubtenants().Contains(TenantConvention.GetDomain()));

            if(tenant == null)
            {
                return path;
            }

            if(!string.IsNullOrWhiteSpace(tenant.CdnDomain))
            {
                var uri = FrapidHttpContext.GetCurrent().Request.Url;

                return uri.Scheme + Uri.SchemeDelimiter + tenant.CdnDomain + (uri.IsDefaultPort ? "" : ":" + uri.Port) + path;
            }

            return path;
        }
示例#2
0
        public static MvcHtmlString GetAntiForgeryToken(this HtmlHelper helper, Uri url)
        {
            var logger = Log.Logger;
            var serializer = new ApprovedDomainSerializer();
            var check = new StaticDomainCheck(logger, serializer);
            var tokenizer = new AntiforgeryTokenizer(helper);
            string currentDomain = GetDomainName(url);

            var generator = new AntiforgeryTokenGenerator(check, tokenizer, currentDomain);
            return generator.GetAntiForgeryToken();
        }
示例#3
0
        public void Execute(IJobExecutionContext context)
        {
            string url = context.JobDetail.Key.Name;
            InstallerLog.Verbose($"Installing frapid on domain {url}.");

            try
            {
                var installer = new Tenant.Installer(url);
                installer.InstallAsync().Wait();

                var site = new ApprovedDomainSerializer().Get().FirstOrDefault(x => x.DomainName.Equals(url));
                DbInstalledDomains.AddAsync(site).Wait();
                new InstalledDomainSerializer().Add(site);
            }
            catch (Exception ex)
            {
                InstallerLog.Error("Could not install frapid on {url} due to errors. Exception: {Exception}", url, ex);
                throw;
            }
        }
示例#4
0
        public static string ToCanonicalUrl(string url)
        {
            if (string.IsNullOrWhiteSpace(url))
            {
                return null;
            }

            string domain = TenantConvention.GetDomain();
            var approved = new ApprovedDomainSerializer();
            var tenant = approved.Get().FirstOrDefault(x => x.GetSubtenants().Contains(domain.ToLowerInvariant()));

            if (tenant != null)
            {
                string protocol = HttpContext.Current.Request.IsSecureConnection ? "https://" : "http://";
                string domainName = protocol + tenant.DomainName;
                url = UrlHelper.CombineUrl(domainName, url);
                return url;
            }

            return string.Empty;
        }
示例#5
0
        public ActionResult Index()
        {
            string domain = TenantConvention.GetDomain();

            var approved = new ApprovedDomainSerializer();
            var installed = new InstalledDomainSerializer();

            if(!approved.GetMemberSites().Any(x => x.Equals(domain)))
            {
                return this.HttpNotFound();
            }

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

            var setup = approved.Get().FirstOrDefault(x => x.GetSubtenants().Contains(domain.ToLowerInvariant()));
            InstallationFactory.Setup(setup); //Background job
            return this.Content("Installing frapid, please visit the site after a few minutes.");
        }
示例#6
0
 public bool IsWellKnownDb()
 {
     var serializer = new ApprovedDomainSerializer();
     var domains = serializer.Get();
     return domains.Any(domain => TenantConvention.GetTenant(domain.DomainName) == this.Tenant);
 }