• spring secrity添加和去掉x-frame-options deny安全头


    pom.xml里添加依赖

          <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-web</artifactId>
            <version>5.2.1.RELEASE</version>
          </dependency>
          <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-config</artifactId>
            <version>5.2.1.RELEASE</version>
          </dependency>

    添加或去掉x-frame-options deny安全头

    package com.chinasofti.cloudeasy.config;
    
    import org.springframework.security.config.annotation.web.builders.HttpSecurity;
    import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
    import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
    
    @EnableWebSecurity
    public class WebSecurityConfiguration extends WebSecurityConfigurerAdapter {
        // @Override
        // protected void configure(AuthenticationManagerBuilder auth) throws Exception {
        // auth.inMemoryAuthentication().withUser("a").password("a").roles("USER");
        // }
    
        @Override
        protected void configure(HttpSecurity http) throws Exception {
            http.headers().frameOptions().sameOrigin(); // 同源跨域
            http.headers().frameOptions().deny();
            http.headers().frameOptions().disable();
        }
    }
  • 相关阅读:
    《大道至简》之五
    String类总结
    《大道至简》之沟通
    程序设计及总结
    《大道至简》之团队
    动手动脑课堂作业7---------
    动手动脑课堂作业7
    动手动脑
    大道至简—现实中的软件工程—思考还是思想
    动手动脑
  • 原文地址:https://www.cnblogs.com/yaoyu1983/p/13187298.html
Copyright © 2020-2023  润新知