如何在API描述中声明API需要的权限(spring security)
doc.method[@org.springframework.security.access.prepost.PreAuthorize]=groovy:```
def preAuthorize = it.ann("org.springframework.security.access.prepost.PreAuthorize")
if(tool.nullOrBlank(preAuthorize)){
return
}
def role = regex.getGroup1("hasRole\\('(.*?)'\\)",preAuthorize)
return "require role: $role"
```
@RestController
@RequestMapping(value = "mock")
public class MockCtrl {
@GetMapping("/string")
@PreAuthorize("hasRole('admin')")
public String mockString() {
return Result.success("mock string");
}
}