| | | 1 | | using ArturRios.Output; |
| | | 2 | | using ArturRios.Util.Http; |
| | | 3 | | using Microsoft.AspNetCore.Mvc; |
| | | 4 | | |
| | | 5 | | namespace ArturRios.Util.WebApi.Security.Filters; |
| | | 6 | | |
| | | 7 | | /// <summary>The failed-envelope results the authorization filters short-circuit with, so a 401 or 403 from a filter |
| | | 8 | | /// has the same shape as the one <see cref="Middleware.AuthenticationMiddleware"/> writes.</summary> |
| | | 9 | | internal static class AuthorizationResults |
| | | 10 | | { |
| | | 11 | | public const string UnauthorizedMessage = "Unauthorized"; |
| | | 12 | | |
| | | 13 | | public const string ForbiddenMessage = "You do not have permission to access this resource"; |
| | | 14 | | |
| | | 15 | | public static ObjectResult Unauthorized() => |
| | 3 | 16 | | new(ProcessOutput.New.WithError(UnauthorizedMessage)) { StatusCode = HttpStatusCodes.Unauthorized }; |
| | | 17 | | |
| | | 18 | | public static ObjectResult Forbidden() => |
| | 2 | 19 | | new(ProcessOutput.New.WithError(ForbiddenMessage)) { StatusCode = HttpStatusCodes.Forbidden }; |
| | | 20 | | } |