Skip to content

Commit

Permalink
fix(plugins): Authorize destructive plugin mgmt endpoints (#808)
Browse files Browse the repository at this point in the history
  • Loading branch information
robzienert committed May 7, 2020
1 parent 46c03e0 commit 6a3ac2f
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.util.Collection;
import java.util.Optional;
import org.springframework.http.HttpStatus;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
Expand All @@ -28,7 +29,6 @@
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;

/** TODO(rz): What's the permissions model for something like plugin info? */
@RestController
@RequestMapping("/pluginInfo")
public class PluginInfoController {
Expand Down Expand Up @@ -56,6 +56,7 @@ PluginInfo upsert(@RequestBody PluginInfo pluginInfo) {
return pluginInfoService.upsert(pluginInfo);
}

@PreAuthorize("@fiatPermissionEvaluator.isAdmin()")
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
@ResponseStatus(HttpStatus.NO_CONTENT)
void delete(@PathVariable String id) {
Expand All @@ -67,6 +68,7 @@ PluginInfo createRelease(@PathVariable String id, @RequestBody PluginInfo.Releas
return pluginInfoService.createRelease(id, release);
}

@PreAuthorize("@fiatPermissionEvaluator.isAdmin()")
@RequestMapping(value = "/{id}/releases/{releaseVersion}", method = RequestMethod.PUT)
PluginInfo.Release preferReleaseVersion(
@PathVariable String id,
Expand All @@ -75,6 +77,7 @@ PluginInfo.Release preferReleaseVersion(
return pluginInfoService.preferReleaseVersion(id, releaseVersion, preferred);
}

@PreAuthorize("@fiatPermissionEvaluator.isAdmin()")
@RequestMapping(value = "/{id}/releases/{releaseVersion}", method = RequestMethod.DELETE)
@ResponseStatus(HttpStatus.NO_CONTENT)
PluginInfo deleteRelease(@PathVariable String id, @PathVariable String releaseVersion) {
Expand Down

0 comments on commit 6a3ac2f

Please sign in to comment.