美文网首页工作生活
springboot2.0 + security eureka客

springboot2.0 + security eureka客

作者: mml_慢慢来 | 来源:发表于2019-07-02 16:24 被阅读0次
security:
    user:
      name: xxx
      password: xxx

配置了默认用户名和密码

然后eureka客户端注册地址也加上了

eureka:
  client:
    service-url:
      defaultZone: http://xxx:xxx@localhost:8761/eureka/

结果启动注册的时候注册不了,说是403错误.

然后看了下boot的文档,在security处找到了一个说是csrf会导致403,我想可能服务注册的403就是这个原因造成的.

之后又在github上的springCloud的issue上看到有人提了这个问题,一看的确是这个原因

处理方式就是禁用security的csrf咯,虽然这样不太安全,不过我这个是提供rest接口,也用不上这个

@EnableWebSecurity
    static class WebSecurityConfig extends WebSecurityConfigurerAdapter {
        @Override
        protected void configure(HttpSecurity http) throws Exception {
            super.configure(http);//加这句是为了访问eureka控制台和/actuator时能做安全控制
            http.csrf().disable();
        }
    }

相关文章

网友评论

    本文标题:springboot2.0 + security eureka客

    本文链接:https://www.haomeiwen.com/subject/rshthctx.html