From 37af5eceac70f41237a878b64d6e25c7def9637a Mon Sep 17 00:00:00 2001 From: robvde Date: Wed, 11 Jul 2012 18:18:13 +0400 Subject: [PATCH] More granularity to the available roles: Available roles now in the platform: Administrator, Reseller, User, PlatformCSR, PlatformHelpdesk, ResellerCSR, ResellerHelpdesk. The platform CSR and Helpdesk are peer accounts on platform root level. The names can be used within the websitepanel_pages.config on Page and Module level. On module level the roles can be specified on the viewRoles attribute and readOnlyRoles attribute. When specifying the later all controls will be disabled within the Modile, the viewRoles just show the page or not. When nothing specified the page is just shown --- .../Common/BusinessErrorCodes.cs | 1 + .../Security/DemandAccount.cs | 6 +- .../Users/UserRole.cs | 6 +- .../Code/Common/SecurityContext.cs | 55 +++++- .../Code/Packages/PackageController.cs | 4 +- .../App_Data/WebsitePanel_Pages.config | 163 +++++++++--------- .../WebsitePanel.WebPortal/Code/PageModule.cs | 7 + .../Code/PortalConfiguration.cs | 4 + .../App_LocalResources/Peers.ascx.resx | 7 +- .../PeersEditPeer.ascx.resx | 7 +- .../Code/Framework/WebsitePanelControlBase.cs | 40 +++++ .../WebsitePanel/Code/Helpers/UsersHelper.cs | 1 + .../DesktopModules/WebsitePanel/Peers.ascx | 7 +- .../DesktopModules/WebsitePanel/Peers.ascx.cs | 30 +++- .../WebsitePanel/Peers.ascx.designer.cs | 34 +++- .../WebsitePanel/PeersEditPeer.ascx | 18 +- .../WebsitePanel/PeersEditPeer.ascx.cs | 85 ++++++++- .../PeersEditPeer.ascx.designer.cs | 30 +++- .../WebsitePanel/SpaceDetails.ascx.cs | 6 +- .../WebsitePanel/UserAccountDetails.ascx.cs | 3 +- .../WebsitePanel.WebPortal/Global.asax.cs | 36 ++-- 21 files changed, 423 insertions(+), 127 deletions(-) diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/Common/BusinessErrorCodes.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/Common/BusinessErrorCodes.cs index f709a65b..703eae8a 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/Common/BusinessErrorCodes.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/Common/BusinessErrorCodes.cs @@ -62,6 +62,7 @@ namespace WebsitePanel.EnterpriseServer public const int ERROR_USER_WRONG_USERNAME = -109; public const int ERROR_USER_WRONG_PASSWORD = -110; public const int ERROR_INVALID_USER_NAME = -111; + public const int ERROR_USER_ACCOUNT_NOT_ENOUGH_PERMISSIONS = -112; #endregion #region Packages diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/Security/DemandAccount.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/Security/DemandAccount.cs index a4807a65..720f6bd4 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/Security/DemandAccount.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/Security/DemandAccount.cs @@ -38,6 +38,10 @@ namespace WebsitePanel.EnterpriseServer NotDemo = 0x1, IsActive = 0x2, IsAdmin = 0x4, - IsReseller = 0x8 + IsReseller = 0x8, + IsPlatformCSR = 0x10, + IsPlatformHelpdesk = 0x20, + IsResellerCSR = 0x40, + IsResellerHelpdesk = 0x80, } } diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/Users/UserRole.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/Users/UserRole.cs index a58e4289..c83a3abb 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/Users/UserRole.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/Users/UserRole.cs @@ -37,6 +37,10 @@ namespace WebsitePanel.EnterpriseServer { Administrator = 1, Reseller = 2, - User = 3 + User = 3, + ResellerCSR = 4, + PlatformCSR = 5, + ResellerHelpdesk = 6, + PlatformHelpdesk = 7 } } diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/Common/SecurityContext.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/Common/SecurityContext.cs index fd457ab1..bd037cd7 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/Common/SecurityContext.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/Common/SecurityContext.cs @@ -45,6 +45,10 @@ namespace WebsitePanel.EnterpriseServer public const string ROLE_ADMINISTRATOR = "Administrator"; public const string ROLE_RESELLER = "Reseller"; public const string ROLE_USER = "User"; + public const string ROLE_PLATFORMCSR = "PlatformCSR"; + public const string ROLE_PLATFORMHELPDESK = "PlatformHelpdesk"; + public const string ROLE_RESELLERCSR = "ResellerCSR"; + public const string ROLE_RESELLERHELPDESK = "ResellerHelpdesk"; public const string CONTEXT_USER_INFO = "CONTEXT_USER_INFO"; @@ -62,8 +66,26 @@ namespace WebsitePanel.EnterpriseServer // set roles array List roles = new List(); roles.Add(SecurityContext.ROLE_USER); + + if (user.Role == UserRole.Reseller || user.Role == UserRole.Administrator || + user.Role == UserRole.PlatformHelpdesk || user.Role == UserRole.ResellerHelpdesk) + roles.Add(SecurityContext.ROLE_RESELLERHELPDESK); + + if (user.Role == UserRole.Reseller || user.Role == UserRole.Administrator || + user.Role == UserRole.PlatformCSR || user.Role == UserRole.ResellerCSR) + roles.Add(SecurityContext.ROLE_RESELLERCSR); + + if (user.Role == UserRole.Reseller || user.Role == UserRole.Administrator || + user.Role == UserRole.PlatformHelpdesk) + roles.Add(SecurityContext.ROLE_PLATFORMHELPDESK); + + if (user.Role == UserRole.Reseller || user.Role == UserRole.Administrator || + user.Role == UserRole.PlatformCSR) + roles.Add(SecurityContext.ROLE_PLATFORMCSR); + if (user.Role == UserRole.Reseller || user.Role == UserRole.Administrator) roles.Add(SecurityContext.ROLE_RESELLER); + if (user.Role == UserRole.Administrator) roles.Add(SecurityContext.ROLE_ADMINISTRATOR); @@ -152,9 +174,40 @@ namespace WebsitePanel.EnterpriseServer { // should make a check if the account has Admin role if (!User.IsInRole(ROLE_RESELLER)) - return BusinessErrorCodes.ERROR_USER_ACCOUNT_SHOULD_BE_RESELLER; + return BusinessErrorCodes.ERROR_USER_ACCOUNT_NOT_ENOUGH_PERMISSIONS; } + if ((demand & DemandAccount.IsPlatformCSR) == DemandAccount.IsPlatformCSR) + { + // should make a check if the account has Admin role + if (!User.IsInRole(ROLE_PLATFORMCSR)) + return BusinessErrorCodes.ERROR_USER_ACCOUNT_NOT_ENOUGH_PERMISSIONS; + } + + if ((demand & DemandAccount.IsPlatformHelpdesk) == DemandAccount.IsPlatformHelpdesk) + { + // should make a check if the account has Admin role + if (!User.IsInRole(ROLE_PLATFORMHELPDESK)) + return BusinessErrorCodes.ERROR_USER_ACCOUNT_NOT_ENOUGH_PERMISSIONS; + } + + + if ((demand & DemandAccount.IsResellerHelpdesk) == DemandAccount.IsResellerHelpdesk) + { + // should make a check if the account has Admin role + if (!User.IsInRole(ROLE_RESELLERHELPDESK)) + return BusinessErrorCodes.ERROR_USER_ACCOUNT_NOT_ENOUGH_PERMISSIONS; + } + + + if ((demand & DemandAccount.IsResellerCSR) == DemandAccount.IsResellerCSR) + { + // should make a check if the account has Admin role + if (!User.IsInRole(ROLE_RESELLERCSR)) + return BusinessErrorCodes.ERROR_USER_ACCOUNT_NOT_ENOUGH_PERMISSIONS; + } + + return 0; } diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/Packages/PackageController.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/Packages/PackageController.cs index d336dfa0..7b2b322d 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/Packages/PackageController.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/Packages/PackageController.cs @@ -399,7 +399,7 @@ namespace WebsitePanel.EnterpriseServer // check account result.Result = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive - | DemandAccount.IsReseller); + | DemandAccount.IsResellerCSR); if (result.Result < 0) return result; // check if domain exists @@ -652,7 +652,7 @@ namespace WebsitePanel.EnterpriseServer { // check account result.Result = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive - | DemandAccount.IsReseller); + | DemandAccount.IsResellerCSR); if (result.Result < 0) return result; int packageId = -1; diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/App_Data/WebsitePanel_Pages.config b/WebsitePanel/Sources/WebsitePanel.WebPortal/App_Data/WebsitePanel_Pages.config index d9a76036..be8e97cf 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/App_Data/WebsitePanel_Pages.config +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/App_Data/WebsitePanel_Pages.config @@ -9,25 +9,25 @@ -