'Spring Security "Administrator" Access to all URLs
In Spring Security configuration I have something like following:
http.authorizeRequests()
.mvcMatchers("/admin").hasRole("ADMIN")
.mvcMatchers("/student").hasAnyRole("ADMIN", "STUDENT")
.mvcMatchers("/teacher").hasAnyRole("ADMIN", "TEACHER")
// ....
Is there anyway to avoid repeating the "ADMIN" each time, i.e. giving someone with the ADMIN role automatic access to all URLs?
A bit like:
http.authorizeRequests()
.anyRequest().hasRole("ADMIN")
.or()
.mvcMatchers("/student").hasRole("STUDENT")
.mvcMatchers("/teacher").hasRole("TEACHER")
// ....
But although there is an .and() method, there doesn't seem to be an .or() one.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
