Eureka 服务器使用 Spring Cloud Finchley RC1

Eureka Server using Spring Cloud Finchley RC1

带有 Spring Cloud Finchley.RC1 的 Eureka 正在使用基于表单的身份验证,这导致 eureka 客户端无法使用:

eureka:
  client:
    serviceUrl:
      defaultZone: http://user:password@localhost:8761/eureka

知道如何取回 Spring Cloud Egware.SR3 中使用的原始身份验证机制吗?

这里我创建了一个示例 repo:

https://github.com/altfatterz/eureka

与此问题相同:https://github.com/spring-cloud/spring-cloud-netflix/issues/2754

Ryan Baxter 建议的解决方法是使用

禁用 csrf
http.csrf().disable()

我通过将这个 WebSecurityConfig 包含在 eureka 服务中来让它工作。

@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {

@Override
protected void configure(HttpSecurity http) throws Exception {
    http.csrf().disable()
            .authorizeRequests()
                .anyRequest().authenticated()
            .and()
                .httpBasic();
   }
}