Применяя следующую конфигурацию, я все еще получаю исключение от сервера
{"timestamp": "2019-10-13T17: 13: 41.168 + 0000", "status": 401, "error": "Unauthorized", "message": "Unauthorized", "path": "/ guest / alternate"}
Router
@GetMapping("/guests/alternate")
public String showAny() {
return "alternate";
}
Config
// For pre-auth
@EnableGlobalMethodSecurity(prePostEnabled = true)
@EnableWebSecurity
@EnableJpaRepositories(basePackageClasses = UsersRepository.class)
@Configuration
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
@Autowired
private CustomUserDetailsService userDetailsService;
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.userDetailsService(userDetailsService)
.passwordEncoder(getPasswordEncoder());
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http.csrf().disable();
http.authorizeRequests()
.antMatchers("/guests**").permitAll()
.antMatchers("**/secured/**").authenticated()
.anyRequest().permitAll()
.and()
.formLogin().permitAll();
}