Exemplo n.º 1
0
        /// <summary>
        /// Checks if the specified path is configured as a secure path which required SSL access.
        /// </summary>
        private bool PathRequiresSecureConnection(string path)
        {
            // Check if this exact path is listed as a secure path
            if (SecurePages.Contains(path))
            {
                return(true);
            }

            // Get all secure paths (these are stored as secure pages, but end with *)
            // Eg. to secure the admin section, we'd have ~/admin/*
            List <String> securePaths = SecurePages.FindAll(page => page.EndsWith("*"));

            // Iterate through the secure paths
            foreach (string page in securePaths)
            {
                // Get the path without the preceding star
                // Eg ~/admin/* => ~/admin/
                string pg = page.Substring(0, page.Length - 1);

                // Check if the current path starts with this
                if (path.StartsWith(pg, true, CultureInfo.InvariantCulture))
                {
                    return(true);
                }
            }

            // None matched so return false
            return(false);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Secure page access
        /// </summary>
        /// <param name="page">Curent page</param>
        /// <returns>True or False</returns>
        public static bool HasPageAccess(SecurePages page)
        {
            switch (page)
            {
            case SecurePages.SiteSettings:
                return(UserProfile.CurrentUser.HasPermission(AccessPermissions.PORTAL_ADMINISTRATION) ||
                       UserProfile.CurrentUser.HasPermission(AccessPermissions.PORTAL_THEME_AND_LAYOUT_ADMINISTRATION));

            case SecurePages.PageManager:
                return(UserProfile.CurrentUser.HasPermission(AccessPermissions.PAGE_LIST) || UserProfile.CurrentUser.HasPermission(AccessPermissions.PAGE_CREATION) || UserProfile.CurrentUser.HasPermission(AccessPermissions.PAGE_DELETION) || UserProfile.CurrentUser.HasPermission(AccessPermissions.PAGE_EDITING));
            }
            return(false);
        }