Skip to content

[Bug][Eureka] Eureka username/password configuration not taking effect #5319

@kinghao007

Description

@kinghao007

Search before asking

  • I searched the issues and found no similar issues.

Linkis Component

linkis-mg-eureka

What happened

English:

The username and password configured in the Eureka configuration file do not take effect, causing Eureka service to fail to start properly or authentication to fail.

Problem Description:
Users configured Eureka security authentication information in application-eureka.yml or related configuration files:

eureka:
  server:
    username: admin
    password: linkis123

However, the configured username and password do not take effect. After the service starts, Eureka can still be accessed without authentication, or other services fail to authenticate when connecting to Eureka.


中文:

在Eureka配置文件中配置了账号密码,但是配置不生效,导致Eureka服务无法正常启动或认证失败。

问题描述:
用户在 application-eureka.yml 或相关配置文件中配置了Eureka的安全认证信息:

eureka:
  server:
    username: admin
    password: linkis123

但是配置的账号密码没有生效,服务启动后仍然可以无认证访问Eureka,或者其他服务连接Eureka时认证失败。

What you expected to happen

English:

The configured Eureka username and password should take effect:

  1. Eureka Server should require authentication after startup
  2. Other Linkis services should be able to successfully register with Eureka using the configured credentials
  3. Eureka Dashboard should require login to access

中文:

配置的Eureka账号密码应该生效:

  1. Eureka Server启动后需要认证才能访问
  2. 其他Linkis服务能够使用配置的账号密码成功注册到Eureka
  3. Eureka Dashboard需要登录才能访问

How to reproduce

English:

  1. Configure username and password in application-eureka.yml
  2. Start linkis-mg-eureka service
  3. Try to access Eureka Dashboard (http://ip:20303/)
  4. Observe whether authentication is required, or whether other services can register normally

中文:

  1. application-eureka.yml 中配置账号密码
  2. 启动 linkis-mg-eureka 服务
  3. 尝试访问 Eureka Dashboard (http://ip:20303/)
  4. 观察是否需要认证,或者其他服务是否能正常注册

Anything else

English:

Root Cause:
Eureka's security authentication requires Spring Security related dependencies to take effect. Configuration parameters alone are not sufficient.

Solution:

  1. Add Spring Security dependency to linkis-mg-eureka's pom.xml:
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-security</artifactId>
</dependency>
  1. Add Security configuration class to enable basic authentication
  2. Ensure other services' Eureka client configurations include authentication information

Technical Points:

  • Spring Security basic authentication configuration
  • Eureka Client authentication configuration
  • Configuration encryption storage (optional)

References:


中文:

根本原因:
Eureka的安全认证需要引入Spring Security相关依赖才能生效,仅配置参数是不够的。

解决方案:

  1. linkis-mg-eurekapom.xml 中添加 Spring Security 依赖:
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-security</artifactId>
</dependency>
  1. 添加 Security 配置类,启用基本认证
  2. 确保其他服务的Eureka客户端配置包含认证信息

相关技术要点:

  • Spring Security 基本认证配置
  • Eureka Client 认证配置
  • 配置加密存储(可选)

参考文档:

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

Linkis Version

1.8.0

Java Version

OpenJDK 1.8.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions