diff --git a/src/Api/AdminConsole/Controllers/OrganizationUsersController.cs b/src/Api/AdminConsole/Controllers/OrganizationUsersController.cs index 2ccc1b97db..426a41a17e 100644 --- a/src/Api/AdminConsole/Controllers/OrganizationUsersController.cs +++ b/src/Api/AdminConsole/Controllers/OrganizationUsersController.cs @@ -35,6 +35,7 @@ namespace Bit.Api.AdminConsole.Controllers; [Route("organizations/{orgId}/users")] [Authorize("Application")] +[Authorize] public class OrganizationUsersController : Controller { private readonly IOrganizationRepository _organizationRepository; @@ -137,7 +138,7 @@ public class OrganizationUsersController : Controller return response; } - [Authorize] + [Authorize] [HttpGet("mini-details")] public async Task> GetMiniDetails(Guid orgId) { diff --git a/src/Core/AdminConsole/OrganizationFeatures/MemberOrProviderRequirement.cs b/src/Core/AdminConsole/OrganizationFeatures/MemberOrProviderRequirement.cs new file mode 100644 index 0000000000..e1c0c8f372 --- /dev/null +++ b/src/Core/AdminConsole/OrganizationFeatures/MemberOrProviderRequirement.cs @@ -0,0 +1,15 @@ +#nullable enable + +using Bit.Core.AdminConsole.OrganizationFeatures.Shared.Authorization; +using Bit.Core.Context; + +namespace Bit.Core.AdminConsole.OrganizationFeatures; + +/// +/// Requires that the user is a member of the organization or a provider for the organization. +/// +public class MemberOrProviderRequirement : IOrganizationRequirement +{ + public async Task AuthorizeAsync(Guid organizationId, CurrentContextOrganization? organizationClaims, ICurrentContext currentContext) + => organizationClaims is not null || await currentContext.ProviderUserForOrgAsync(organizationId); +} diff --git a/src/Core/AdminConsole/OrganizationFeatures/OrganizationMemberRequirement.cs b/src/Core/AdminConsole/OrganizationFeatures/OrganizationMemberRequirement.cs deleted file mode 100644 index 3176ea1deb..0000000000 --- a/src/Core/AdminConsole/OrganizationFeatures/OrganizationMemberRequirement.cs +++ /dev/null @@ -1,12 +0,0 @@ -#nullable enable - -using Bit.Core.AdminConsole.OrganizationFeatures.Shared.Authorization; -using Bit.Core.Context; - -namespace Bit.Core.AdminConsole.OrganizationFeatures; - -public class OrganizationMemberRequirement : IOrganizationRequirement -{ - public Task AuthorizeAsync(Guid organizationId, CurrentContextOrganization? organizationClaims, ICurrentContext currentContext) - => Task.FromResult(organizationClaims is not null); -}