I am using Spring Boot, Spring Security and jdk 1.8. When I am trying to open any secured Thymleaf page in iframe on Chrome, then it is redirecting me to login page every time. It is working fine on Firefox and IE.
And when I try to open the same URL without iframe, it is working fine. Below are my Spring Security conf file code. One more thing: both domains are different.
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.headers()
.frameOptions().disable()
.and()
.csrf().disable()/*disbaling csrf here*/
.authorizeRequests()
.antMatchers("/","/login","/css/**", "/js/**", "/fonts/**","/img/**").permitAll()/*do not use spring security on this path*/
.and()
.formLogin()
.successHandler(successHandler) /*after success login on web we are handling the success event*/
.permitAll()
.and()
.logout().logoutRequestMatcher(new AntPathRequestMatcher("/logout")).logoutSuccessUrl("/login/?logout") /*defining logout and login url here*/
.permitAll()
/*
* This is for authentication failure handling
* */
http.exceptionHandling().authenticationEntryPoint(authenticationEntryPoint)
/*Token based authentication we are handling here*/
http.addFilterBefore(new StatelessAuthenticationFilter(tokenAuthenticationService), BasicAuthenticationFilter.class);
http.addFilterAfter(new SameSiteFilter(), BasicAuthenticationFilter.class)
}
How can I fix it?