AbpAuthorizeAttribute.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. using System;
  2. using Abp.Application.Services;
  3. namespace Abp.Authorization
  4. {
  5. /// <summary>
  6. /// This attribute is used on a method of an Application Service (A class that implements <see cref="IApplicationService"/>)
  7. /// to make that method usable only by authorized users.
  8. /// </summary>
  9. [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true)]
  10. public class AbpAuthorizeAttribute : Attribute, IAbpAuthorizeAttribute
  11. {
  12. /// <summary>
  13. /// A list of permissions to authorize.
  14. /// </summary>
  15. public string[] Permissions { get; }
  16. /// <summary>
  17. /// If this property is set to true, all of the <see cref="Permissions"/> must be granted.
  18. /// If it's false, at least one of the <see cref="Permissions"/> must be granted.
  19. /// Default: false.
  20. /// </summary>
  21. public bool RequireAllPermissions { get; set; }
  22. /// <summary>
  23. /// Creates a new instance of <see cref="AbpAuthorizeAttribute"/> class.
  24. /// </summary>
  25. /// <param name="permissions">A list of permissions to authorize</param>
  26. public AbpAuthorizeAttribute(params string[] permissions)
  27. {
  28. Permissions = permissions;
  29. }
  30. }
  31. }