July 2018
Intermediate to advanced
268 pages
7h 36m
English
To enable method security, first, annotate the Spring Security configurations class with @EnableReactiveMethodSecurity:
@EnableReactiveMethodSecuritypublic class SpringSecurityWebFluxConfig { …}
After that, for any method that you would like to have some security features for, use all of the various security-related annotations discussed in previous chapters:
@GetMapping("/movies")@PreAuthorize("hasRole('ADMIN')")public Flux<Movie> getAllMovies() { return reactiveMovieRepository.findAll();}
In the preceding method, we are directing Spring Security that the method execution for getAllMovies() should be allowed if the user is authenticated and has the ADMIN role granted.
Read now
Unlock full access