mirror of
https://github.com/bitwarden/server.git
synced 2025-04-25 23:02:17 -05:00

- Add Authorize<T> attribute - Add IOrganizationRequirement and example implementation - Add OrganizationRequirementHandler - Add extension methods (replacing ICurrentContext) - Move custom permissions claim definitions --- Co-authored-by: Justin Baur <19896123+justindbaur@users.noreply.github.com> Co-authored-by: ✨ Audrey ✨ <ajensen@bitwarden.com>
17 lines
524 B
C#
17 lines
524 B
C#
#nullable enable
|
|
|
|
using Bit.Core.Context;
|
|
|
|
namespace Bit.Api.AdminConsole.Authorization.Requirements;
|
|
|
|
/// <summary>
|
|
/// Requires that the user is a member of the organization or a provider for the organization.
|
|
/// </summary>
|
|
public class MemberOrProviderRequirement : IOrganizationRequirement
|
|
{
|
|
public async Task<bool> AuthorizeAsync(
|
|
CurrentContextOrganization? organizationClaims,
|
|
Func<Task<bool>> isProviderUserForOrg)
|
|
=> organizationClaims is not null || await isProviderUserForOrg();
|
|
}
|