Skip to content

Provide guidance on using X-Frame-Options with SockJS iframe transports [SPR-11496] #16121

@spring-projects-issues

Description

@spring-projects-issues

Rossen Stoyanchev opened SPR-11496 and commented

SockJS has a couple of iframe-based transports. Those transports fail when using the Spring Security Java config, which automatically adds the X-Frame-Options: DENY response header (see documentation). Adding the following for example seems to work:

@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {

  @Override
  protected void configure(HttpSecurity http) throws Exception {
    http
      .headers().addHeaderWriter(
        new XFrameOptionsHeaderWriter(
            XFrameOptionsHeaderWriter.XFrameOptionsMode.SAMEORIGIN))
        .and()

    ...

  }
}

Affects: 4.0.2

Issue Links:

Referenced from: commits 15188a8

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: documentationA documentation task

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions