Moved share permission parsing to jsonb implementation of ef core. Improved auth handling for shares
This commit is contained in:
@@ -164,8 +164,13 @@ public class FilesController : Controller
|
||||
if (server == null)
|
||||
throw new HttpApiException("No server with this id found", 404);
|
||||
|
||||
if (!await AuthorizeService.Authorize(User, server, permission => permission.Name == "files" && permission.Type >= type))
|
||||
throw new HttpApiException("No server with this id found", 404);
|
||||
var authorizeResult = await AuthorizeService.Authorize(
|
||||
User, server,
|
||||
permission => permission.Name == "files" && permission.Type >= type
|
||||
);
|
||||
|
||||
if (!authorizeResult.Succeeded)
|
||||
throw new HttpApiException("No permission for the requested resource", 403);
|
||||
|
||||
return server;
|
||||
}
|
||||
|
||||
@@ -68,9 +68,14 @@ public class PowerController : Controller
|
||||
if (server == null)
|
||||
throw new HttpApiException("No server with this id found", 404);
|
||||
|
||||
if (!await AuthorizeService.Authorize(User, server, permission => permission is { Name: "power", Type: ServerPermissionType.ReadWrite }))
|
||||
throw new HttpApiException("No server with this id found", 404);
|
||||
var authorizeResult = await AuthorizeService.Authorize(
|
||||
User, server,
|
||||
permission => permission.Name == "power" && permission.Type >= ServerPermissionType.ReadWrite
|
||||
);
|
||||
|
||||
if (!authorizeResult.Succeeded)
|
||||
throw new HttpApiException("No permission for the requested resource", 403);
|
||||
|
||||
return server;
|
||||
}
|
||||
}
|
||||
@@ -148,7 +148,9 @@ public class ServersController : Controller
|
||||
if (server == null)
|
||||
throw new HttpApiException("No server with this id found", 404);
|
||||
|
||||
if (!await AuthorizeService.Authorize(User, server))
|
||||
var authorizationResult = await AuthorizeService.Authorize(User, server);
|
||||
|
||||
if (!authorizationResult.Succeeded)
|
||||
throw new HttpApiException("No server with this id found", 404);
|
||||
|
||||
return new ServerDetailResponse()
|
||||
@@ -256,8 +258,10 @@ public class ServersController : Controller
|
||||
if (server == null)
|
||||
throw new HttpApiException("No server with this id found", 404);
|
||||
|
||||
if (!await AuthorizeService.Authorize(User, server, filter))
|
||||
throw new HttpApiException("No server with this id found", 404);
|
||||
var authorizeResult = await AuthorizeService.Authorize(User, server, filter);
|
||||
|
||||
if (!authorizeResult.Succeeded)
|
||||
throw new HttpApiException("No permission for the requested resource", 403);
|
||||
|
||||
return server;
|
||||
}
|
||||
|
||||
@@ -47,9 +47,14 @@ public class SettingsController : Controller
|
||||
if (server == null)
|
||||
throw new HttpApiException("No server with this id found", 404);
|
||||
|
||||
if (!await AuthorizeService.Authorize(User, server, permission => permission is { Name: "settings", Type: ServerPermissionType.ReadWrite }))
|
||||
throw new HttpApiException("No server with this id found", 404);
|
||||
var authorizeResult = await AuthorizeService.Authorize(
|
||||
User, server,
|
||||
permission => permission is { Name: "settings", Type: >= ServerPermissionType.ReadWrite }
|
||||
);
|
||||
|
||||
if (!authorizeResult.Succeeded)
|
||||
throw new HttpApiException("No permission for the requested resource", 403);
|
||||
|
||||
return server;
|
||||
}
|
||||
}
|
||||
@@ -132,9 +132,13 @@ public class VariablesController : Controller
|
||||
if (server == null)
|
||||
throw new HttpApiException("No server with this id found", 404);
|
||||
|
||||
if (!await AuthorizeService.Authorize(User, server,
|
||||
permission => permission.Name == "variables" && permission.Type >= type))
|
||||
throw new HttpApiException("No server with this id found", 404);
|
||||
var authorizeResult = await AuthorizeService.Authorize(
|
||||
User, server,
|
||||
permission => permission.Name == "variables" && permission.Type >= type
|
||||
);
|
||||
|
||||
if (!authorizeResult.Succeeded)
|
||||
throw new HttpApiException("No permission for the requested resource", 403);
|
||||
|
||||
return server;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user