您好,欢迎来到花图问答。
搜索
您的当前位置:首页Eureka 2.0 以及账号密码配置

Eureka 2.0 以及账号密码配置

来源:花图问答

参考

eureka整合账号密码的功能

  1. 添加配置 而且defaultZone的配置不同
server.port=8761
spring.profiles.active=master
spring.application.name=spring-cloud-eureka
eureka.client.register-with-eureka=false
eureka.client.fetch-registry=false

security.basic.enabled=true
security.user.name=yinjihuan
security.user.password=123456
eureka.client.serviceUrl.defaultZone=http://yinjihuan:123456@localhost:8761/eureka/
  1. 添加jar包依赖
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
    </dependency>

2.x 版本权限配置

  1. application配置不同,需要添加前缀spring
  2. eureka的server端需要关闭CSRD保护

2.0 版配置 server端

spring.security.basic.enabled=true
spring.security.user.name=huangzs
spring.security.user.password=123456

eureka.client.serviceUrl.defaultZone=http://huangzs:123456@localhost:8762/eureka/
@EnableWebSecurity
public  class WebSecurityConfig extends WebSecurityConfigurerAdapter {
    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http.csrf().disable();
    }
}

Copyright © 2019- huatuowenda.com 版权所有 湘ICP备2023022495号-1

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务