检查内部方法@preauthorize 已经为 spring 控制器方法传递了哪个角色
check inside method which role @preauthorize has passed for spring controller method
我正在使用@preauthorize 来实现方法级别的安全性。对于我的method1,两个角色中的一个只能满足。但是在那个方法中,我需要知道这次它满足了哪个角色,并基于此我需要为功能需求设置后续旅程。我的问题如下 -
@PreAuthorize("hasAnyRole('Role_1') or hasAnyRole('Role_2')")
@RequestMapping(value = URL_MAPPING, method = {RequestMethod.GET, RequestMethod.POST })
public ModelAndView methodName(HttpSession session,
ModelAndView modelAndView) {
//here i need to know which role it has passed to execute the method.
if (role1 executed) {
sessionInformation.updateJourneyInfo(updateforrole1);
}else{
sessionInformation.updateJourneyInfo(updateforrole2);
}
谁能帮忙提前解决这个问题issue.Thanks。
将 HttpServletRequest
请求添加到方法的参数列表中,然后使用
request.isInRole("ROLE_Role_1")
我正在使用@preauthorize 来实现方法级别的安全性。对于我的method1,两个角色中的一个只能满足。但是在那个方法中,我需要知道这次它满足了哪个角色,并基于此我需要为功能需求设置后续旅程。我的问题如下 -
@PreAuthorize("hasAnyRole('Role_1') or hasAnyRole('Role_2')")
@RequestMapping(value = URL_MAPPING, method = {RequestMethod.GET, RequestMethod.POST })
public ModelAndView methodName(HttpSession session,
ModelAndView modelAndView) {
//here i need to know which role it has passed to execute the method.
if (role1 executed) {
sessionInformation.updateJourneyInfo(updateforrole1);
}else{
sessionInformation.updateJourneyInfo(updateforrole2);
}
谁能帮忙提前解决这个问题issue.Thanks。
将 HttpServletRequest
请求添加到方法的参数列表中,然后使用
request.isInRole("ROLE_Role_1")