| | | 1 | | using Microsoft.AspNetCore.Authorization; |
| | | 2 | | using System; |
| | | 3 | | using System.Collections.Generic; |
| | | 4 | | using System.Linq; |
| | | 5 | | using System.Threading.Tasks; |
| | | 6 | | |
| | | 7 | | namespace SVETA.Api.Helpers.Authorize |
| | | 8 | | { |
| | | 9 | | public class MethodAuthorizeAttribute: AuthorizeAttribute |
| | | 10 | | { |
| | | 11 | | const string POLICY_PREFIX = "Method"; |
| | 0 | 12 | | public MethodAuthorizeAttribute(string method) => MethodName = method; |
| | | 13 | | |
| | | 14 | | public string MethodName |
| | | 15 | | { |
| | | 16 | | get |
| | 0 | 17 | | { |
| | 0 | 18 | | if (Policy.Substring(POLICY_PREFIX.Length).Length > 0) |
| | 0 | 19 | | { |
| | 0 | 20 | | return Policy.Substring(POLICY_PREFIX.Length); |
| | | 21 | | } |
| | 0 | 22 | | return default(string); |
| | 0 | 23 | | } |
| | | 24 | | set |
| | 0 | 25 | | { |
| | 0 | 26 | | Policy = $"{POLICY_PREFIX}{value}"; |
| | 0 | 27 | | } |
| | | 28 | | } |
| | | 29 | | } |
| | | 30 | | } |