posted 2 years ago
I'm trying to implement Role hierarchy and then use it in method security.
For the simplicity its just two roles here: ADMIN and GOAL. ADMIN includes GOAL.
I created RoleHierarchy Bean in a separate Configuration file, because some people here stated that Spring Security filters need to be configured quite early.
I'm getting following errors:
When I'm accessing the controller I'm getting a NullPointer error (which stated below)
Another controllers which stated in antMatchers stops working too with the same error.
Questions:
1.Where is the error?
2.Do I need to declare my custom hierarchy in GlobalMethodSecurityConfiguration or WebSecurityConfigurerAdapter or both?
Source code:
RoleHierarchy Bean
GlobalMethodSecurityConfiguration
WebSecurityConfigurerAdapter
Controller
Tried to also use @PreAuthorize("hasRole('ROLE_GOAL')" or @PreAuthorize("hasRole('GOAL')".
Error when accesssing the controller: