I am developing a web service which uses Spring Security toolbox for authorizing the request by the 'Authority'. Naturally, the web service has a configuration class which extends to WebSecurityConfigurerAdapter class and overrides the configure(HttpSecurity http) method.
Within the method I have written the profiles (roles or Authorities) with the follow code:
http
.authorizeRequests()
.antMatchers("/**").hasAnyAuthority("PERFIL")
.anyRequest().authenticated()
.and()
.logout().clearAuthentication(true)
.invalidateHttpSession(true)
.and()
.csrf().disable();
It works very well, however I would want to charge dynamic profiles (roles or Authorities) from a database because I want to change them without changing the web service.
Does someone know how could do it?
Regards.