美文网首页SpringCloud
Eureka 2.0 以及账号密码配置

Eureka 2.0 以及账号密码配置

作者: 黄靠谱 | 来源:发表于2019-07-02 14:40 被阅读4次

参考

自己的一个demo源码
https://github.com/huangzhenshi/eureka2.x_auth_demo

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/

2.X CSRF保护默认是开启的,可以禁用掉即可
https://blog.csdn.net/u010889990/article/details/80431487
通过配置server端的代码

@EnableWebSecurity
public  class WebSecurityConfig extends WebSecurityConfigurerAdapter {
    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http.csrf().disable();
    }
}

相关文章

网友评论

    本文标题:Eureka 2.0 以及账号密码配置

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