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>
22 lines
674 B
C#
22 lines
674 B
C#
#nullable enable
|
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
namespace Bit.Api.AdminConsole.Authorization;
|
|
|
|
/// <summary>
|
|
/// An attribute which requires authorization using the specified requirement.
|
|
/// This uses the standard ASP.NET authorization middleware.
|
|
/// </summary>
|
|
/// <typeparam name="T">The IAuthorizationRequirement that will be used to authorize the user.</typeparam>
|
|
public class AuthorizeAttribute<T>
|
|
: AuthorizeAttribute, IAuthorizationRequirementData
|
|
where T : IAuthorizationRequirement, new()
|
|
{
|
|
public IEnumerable<IAuthorizationRequirement> GetRequirements()
|
|
{
|
|
var requirement = new T();
|
|
return [requirement];
|
|
}
|
|
}
|