How to allow anonymous users to access a certain function only using spring security
How to allow anonymous users to access a certain function only using spring security I'm using spring security in my project. I have a condition where the anonymous users should be able to read from database whereas only authorized users to add/update/delete. How can we mention such situation in the security-config? .antMatchers("/user/**").permitAll() permit all requires to be authenticated but I want even none authenticated users to access via the GET method. @RequestMapping("/user") @PreAuthorize("hasAuthority('USER')") public List<UserAll> getAll() { return userService.getAll(); } And here how do I mention that this function should be accessed by anonymous users too? you can change to hasAnyRole('USER', 'ANONYMOUS') – fg78nc Jul 2 at 4:18 hasAnyR...