diff --git a/bitwarden_license/src/Portal/Controllers/PoliciesController.cs b/bitwarden_license/src/Portal/Controllers/PoliciesController.cs index 875246a606..ab3e5efd32 100644 --- a/bitwarden_license/src/Portal/Controllers/PoliciesController.cs +++ b/bitwarden_license/src/Portal/Controllers/PoliciesController.cs @@ -45,7 +45,7 @@ namespace Bit.Portal.Controllers } if (!_enterprisePortalCurrentContext.SelectedOrganizationDetails.UsePolicies || - !_enterprisePortalCurrentContext.AdminForSelectedOrganization) + !_enterprisePortalCurrentContext.CanManagePoliciesForSelectedOrganization) { return Redirect("~/"); } @@ -65,7 +65,7 @@ namespace Bit.Portal.Controllers } if (!_enterprisePortalCurrentContext.SelectedOrganizationDetails.UsePolicies || - !_enterprisePortalCurrentContext.AdminForSelectedOrganization) + !_enterprisePortalCurrentContext.CanManagePoliciesForSelectedOrganization) { return Redirect("~/"); } @@ -85,7 +85,7 @@ namespace Bit.Portal.Controllers } if (!_enterprisePortalCurrentContext.SelectedOrganizationDetails.UsePolicies || - !_enterprisePortalCurrentContext.AdminForSelectedOrganization) + !_enterprisePortalCurrentContext.CanManagePoliciesForSelectedOrganization) { return Redirect("~/"); } diff --git a/bitwarden_license/src/Portal/Controllers/SsoController.cs b/bitwarden_license/src/Portal/Controllers/SsoController.cs index f5e05f7f82..7757a11abd 100644 --- a/bitwarden_license/src/Portal/Controllers/SsoController.cs +++ b/bitwarden_license/src/Portal/Controllers/SsoController.cs @@ -41,7 +41,7 @@ namespace Bit.Portal.Controllers } if (!_enterprisePortalCurrentContext.SelectedOrganizationDetails.UseSso || - !_enterprisePortalCurrentContext.AdminForSelectedOrganization) + !_enterprisePortalCurrentContext.CanManageSsoForSelectedOrganization) { return Redirect("~/"); } @@ -63,7 +63,7 @@ namespace Bit.Portal.Controllers } if (!_enterprisePortalCurrentContext.SelectedOrganizationDetails.UseSso || - !_enterprisePortalCurrentContext.AdminForSelectedOrganization) + !_enterprisePortalCurrentContext.CanManageSsoForSelectedOrganization) { return Redirect("~/"); } diff --git a/bitwarden_license/src/Portal/EnterprisePortalCurrentContext.cs b/bitwarden_license/src/Portal/EnterprisePortalCurrentContext.cs index c38937337f..8d43e5aebd 100644 --- a/bitwarden_license/src/Portal/EnterprisePortalCurrentContext.cs +++ b/bitwarden_license/src/Portal/EnterprisePortalCurrentContext.cs @@ -7,6 +7,7 @@ using Bit.Core.Repositories; using System.Linq; using System.Collections.Generic; using Bit.Core.Models.Data; +using Bit.Core.Utilities; namespace Bit.Portal { @@ -37,6 +38,14 @@ namespace Bit.Portal public bool OwnerForSelectedOrganization => SelectedOrganizationDetails?.Type == Core.Enums.OrganizationUserType.Owner; + public bool CanManagePoliciesForSelectedOrganization => + AdminForSelectedOrganization || SelectedOrganizationDetailsPermissions.ManagePolicies == true; + + public bool CanManageSsoForSelectedOrganization => + AdminForSelectedOrganization || SelectedOrganizationDetailsPermissions.ManageSso == true; + + public Permissions SelectedOrganizationDetailsPermissions => CoreHelpers.LoadClassFromJsonData(SelectedOrganizationDetails?.Permissions); + public async override Task SetContextAsync(ClaimsPrincipal user) { var nameId = user.FindFirstValue(ClaimTypes.NameIdentifier); diff --git a/bitwarden_license/src/Portal/Views/Home/Index.cshtml b/bitwarden_license/src/Portal/Views/Home/Index.cshtml index 5324f15f18..2d021f3556 100644 --- a/bitwarden_license/src/Portal/Views/Home/Index.cshtml +++ b/bitwarden_license/src/Portal/Views/Home/Index.cshtml @@ -10,7 +10,7 @@
@if (EnterprisePortalCurrentContext.SelectedOrganizationDetails.UseSso && - EnterprisePortalCurrentContext.AdminForSelectedOrganization) + EnterprisePortalCurrentContext.CanManageSsoForSelectedOrganization) { \ No newline at end of file +
diff --git a/bitwarden_license/src/Portal/Views/Shared/_Layout.cshtml b/bitwarden_license/src/Portal/Views/Shared/_Layout.cshtml index c7151ea302..63a3959f5f 100644 --- a/bitwarden_license/src/Portal/Views/Shared/_Layout.cshtml +++ b/bitwarden_license/src/Portal/Views/Shared/_Layout.cshtml @@ -32,7 +32,7 @@