zoukankan      html  css  js  c++  java
  • 关于开启Eureka安全Security认证后,客户端死活注册不上的问题

    <div class="show-content-free">
            <p>遇到一个问题“开启Eureka服务端的安全认证后,客户端死活注册不到Eureka上”,已经尝试了以下办法,完全搞不定。。。</p><p>客户端出错的版本:</p><p>spring-boot:2.0.3.RELEASE</p><p>spring-cloud:Finchley.RELEASE</p><p>查看客户端报的错误:</p><p>cannot regist on known server</p><p>retrying on another server if available&nbsp; 401错误</p><p>spring:</p><p>&nbsp; profiles: peer1</p><p>&nbsp; security:</p><p>&nbsp; &nbsp; user:</p><p>&nbsp; &nbsp; &nbsp; name: test</p><p>&nbsp; &nbsp; &nbsp; password: 123456&nbsp; &nbsp; &nbsp; roles: USER</p><p>1.查询资料,发现,高版本不再在Eureka服务端使用在配置文件(yml文件)中配置basic认证,如下边这样:</p><p>spring:</p><p>&nbsp; profiles: peer1</p><p>&nbsp; security:</p><p>&nbsp; &nbsp; user:</p><p>&nbsp; &nbsp; &nbsp; name: test</p><p>&nbsp; &nbsp; &nbsp; password: 123456&nbsp; &nbsp; &nbsp; roles: USER</p><p>而是集成WebSecurityConfigurerAdapter类,然后重写configure方法来实现badic认证,这步做了,客户端还是注册不了。</p><p>2.又发现,说Eureka服务端需要关闭自我注册,也就是在yml文件中设置registerWithEureka:false,并且fetchRegistry:false。尝试了,发现还是不行。</p><p>3.又看到说Eureka高版本默认开启了csrf保护,需要关闭这个才行,尝试关闭:</p><p>http.csrf().disable();还是不行,看到另外一种写法:</p><p>http.csrf().ignoringAntMatchers("/eureka/**");也还是不行。</p><p>4.最后又边查资料,边观察,发现自己的客户端yml写的不对,eureka节点写在了spring节点下,这是不对的,应该把eureka节点写在直接靠边的位置,这样做就正常注册了。(之前就知道yml对格式要求很严谨,今天这坑踩的可是长记性了。)</p>
          </div>
              原文地址:https://blog.csdn.net/weixin_34037977/article/details/90915691                        </div>
  • 相关阅读:
    django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.
    Error fetching command 'collectstatic': You're using the staticfiles app without having set the STATIC_ROOT setting to a filesystem path. Command 'collectstatic' skipped
    windows 虚拟环境下 安装 mysql 引擎一系列错误处理
    项目概念流程
    pip 使用
    HTTPserver v3.0 版本项目
    GitHub 使用
    git 操作命令详解
    git 忽略部分文件类型的同步
    Python 正则处理_re模块
  • 原文地址:https://www.cnblogs.com/jpfss/p/11310810.html
Copyright © 2011-2022 走看看