This commit is contained in:
2020-06-07 18:13:56 +00:00
parent 58a3ac71f5
commit 6f8eb9ba6b
11 changed files with 67 additions and 20 deletions

View File

@@ -61,7 +61,7 @@ namespace AyaNova.Api.Controllers
{
if (serverState.IsClosed)
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
if (!Authorized.HasAnyRole(HttpContext.Items, AuthorizationRoles.OpsAdminFull))
if (!Authorized.HasModifyRole(HttpContext.Items, AyaType.Backup))//technically maybe this could be wider open, but for now keeping as locked down
return StatusCode(403, new ApiNotAuthorizedResponse());
var JobName = $"Backup (on demand)";
OpsJob j = new OpsJob();
@@ -87,7 +87,7 @@ namespace AyaNova.Api.Controllers
//Need size and more info
if (serverState.IsClosed)
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
if (!Authorized.HasAnyRole(HttpContext.Items, AuthorizationRoles.OpsAdminFull | AuthorizationRoles.OpsAdminLimited))
if (!Authorized.HasReadFullRole(HttpContext.Items, AyaType.Backup))
return StatusCode(403, new ApiNotAuthorizedResponse());
return Ok(ApiOkResponse.Response(FileUtil.BackupStatusReport()));
}
@@ -122,7 +122,7 @@ namespace AyaNova.Api.Controllers
return StatusCode(401, new ApiErrorResponse(ApiErrorCode.AUTHENTICATION_FAILED));
}
if (!Authorized.HasAnyRole(DownloadUser.Roles, AuthorizationRoles.OpsAdminFull))
if (!Authorized.HasModifyRole(HttpContext.Items, AyaType.Backup))//not technically modify but treating as such as a backup is very sensitive data
{
await Task.Delay(nFailedAuthDelay);//DOS protection
return StatusCode(403, new ApiNotAuthorizedResponse());