Я начал с Grails 3 и работаю с системой безопасности Spring Boot Starter. Вот мой конфиг безопасности.
@Configuration
@EnableWebSecurity
@EnableWebMvcSecurity
@EnableGlobalMethodSecurity(jsr250Enabled = true)
class CustomSecurityConfig extends WebSecurityConfigurerAdapter{
CustomUserDetailsService userDetailsService
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth)
throws Exception {
auth.userDetailsService(userDetailsService).passwordEncoder(passwordEncoder())
}
@Bean
CustomAuthenticationProvider authenticationProvider() {
CustomAuthenticationProvider provider = new CustomAuthenticationProvider();
return provider;
}
@Override
public void configure(WebSecurity web) throws Exception {
// This is here to ensure that the static content (JavaScript, CSS, etc)
// is accessible from the login page without authentication
web.ignoring().antMatchers("/assets/**");
web.ignoring().antMatchers("/views/**");
}
@Override
protected void configure(HttpSecurity http) throws Exception {
println "configuring security"
http.httpBasic().disable()
http.authorizeRequests().expressionHandler()
http.formLogin().loginPage("/login").permitAll().and().logout().logoutRequestMatcher(new AntPathRequestMatcher("/logout"))
.logoutSuccessUrl("/").deleteCookies("JSESSIONID")
.invalidateHttpSession(true);
http.authorizeRequests().antMatchers("/").permitAll();
http.csrf().disable();
}
@Bean
public BCryptPasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}
}
Ребята, вы видите ошибки? С этой конфигурацией всякий раз, когда я открываю свой корневой URL-адрес, который должен перенаправлять на страницу входа, продолжает запрашивать аутентификацию всплывающего окна! Любые идеи, как это можно исправить? Ваше здоровье!