I have a controller that has many actions, but one of the actions I want to let anyone in (the "show" action).
Unfortunately, Spring Security throws this exception:Code:@RequestMapping("/show/{pressReleaseId}") @PreAuthorize("permitAll") public ModelAndView show(@PathVariable long pressReleaseId) { ModelAndView modelAndView = new ModelAndView(view("show")); modelAndView.addObject("pressRelease", sysAdminService.findPressRelease(pressReleaseId)); return modelAndView; }
How can I get Spring Security to NOT throw this exception? I just want to let anyone in - non-authenticated users and authenticated users - Everyone.Code:org.springframework.security.authentication.AuthenticationCredentialsNotFoundException: An Authentication object was not found in the SecurityContext at org.springframework.security.access.intercept.AbstractSecurityInterceptor.credentialsNotFound(AbstractSecurityInterceptor.java:321) at org.springframework.security.access.intercept.AbstractSecurityInterceptor.beforeInvocation(AbstractSecurityInterceptor.java:195) at org.springframework.security.access.intercept.aopalliance.MethodSecurityInterceptor.invoke(MethodSecurityInterceptor.java:64)
My only solution is to put this method into another controller altogether with no @PreAuthorize at all... which will work, but that's stupid. I want to keep all my press release actions in the same controller.
Thanks for the help!


Reply With Quote
