Spring Security 변경
This commit is contained in:
@@ -8,6 +8,7 @@ import com.eactive.testmaster.server.service.ServerMgmtService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.security.access.annotation.Secured;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.validation.BindingResult;
|
||||
@@ -40,6 +41,7 @@ public class ServerMgmtController {
|
||||
public static final String SERVER_LIST_VIEW = "redirect:/mgmt/servers/list_view.do";
|
||||
|
||||
@GetMapping("/list_view.do")
|
||||
@Secured("ROLE_MANAGE_SERVER")
|
||||
public String listView(@ModelAttribute("serverSearch") ServerSearch serverSearch,
|
||||
ModelMap model,
|
||||
Pageable pageable) {
|
||||
@@ -53,6 +55,7 @@ public class ServerMgmtController {
|
||||
}
|
||||
|
||||
@GetMapping("/create_view.do")
|
||||
@Secured("ROLE_MANAGE_SERVER")
|
||||
public String createView(ModelMap model) {
|
||||
ServerDTO defaultServer = new ServerDTO();
|
||||
model.addAttribute(SERVER, defaultServer);
|
||||
@@ -60,6 +63,7 @@ public class ServerMgmtController {
|
||||
}
|
||||
|
||||
@GetMapping("/update_view.do")
|
||||
@Secured("ROLE_MANAGE_SERVER")
|
||||
public String updateView(ModelMap model, @RequestParam("id") Long id) {
|
||||
Server found = serverMgmtService.findById(id);
|
||||
ServerDTO server = serverMapper.map(found);
|
||||
@@ -68,6 +72,7 @@ public class ServerMgmtController {
|
||||
}
|
||||
|
||||
@PostMapping("/register.do")
|
||||
@Secured("ROLE_MANAGE_SERVER")
|
||||
public String register(@ModelAttribute(SERVER) ServerDTO dto,
|
||||
BindingResult bindingResult,
|
||||
ModelMap model) {
|
||||
@@ -89,6 +94,7 @@ public class ServerMgmtController {
|
||||
}
|
||||
|
||||
@PostMapping("/update.do")
|
||||
@Secured("ROLE_MANAGE_SERVER")
|
||||
public String update(@ModelAttribute(SERVER) ServerDTO dto,
|
||||
BindingResult bindingResult,
|
||||
ModelMap model) {
|
||||
@@ -110,6 +116,7 @@ public class ServerMgmtController {
|
||||
}
|
||||
|
||||
@PostMapping("/delete.do")
|
||||
@Secured("ROLE_MANAGE_SERVER")
|
||||
public String delete(@RequestParam("checkedIdForDel") List<String> checkedIdForDel) {
|
||||
for (String id : checkedIdForDel) {
|
||||
serverMgmtService.delete(Long.parseLong(id));
|
||||
|
||||
@@ -11,6 +11,7 @@ import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.annotation.Secured;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
@@ -18,7 +19,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/mgmt/servers")
|
||||
@RequestMapping("/servers")
|
||||
public class ServerRestController {
|
||||
|
||||
private final ServerMgmtService serverMgmtService;
|
||||
@@ -31,6 +32,7 @@ public class ServerRestController {
|
||||
}
|
||||
|
||||
@GetMapping("/list.do")
|
||||
@Secured("ROLE_API_TESTER")
|
||||
public ResponseEntity<List<ServerDTO>> listView(@ModelAttribute("serverSearch") ServerSearch serverSearch, ModelMap model, Pageable pageable) {
|
||||
Page<Server> page = serverMgmtService.findAll(serverSearch.buildSpecification(), pageable);
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
|
||||
Reference in New Issue
Block a user