-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
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: linkis123However, 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:
- Eureka Server should require authentication after startup
- Other Linkis services should be able to successfully register with Eureka using the configured credentials
- Eureka Dashboard should require login to access
中文:
配置的Eureka账号密码应该生效:
- Eureka Server启动后需要认证才能访问
- 其他Linkis服务能够使用配置的账号密码成功注册到Eureka
- Eureka Dashboard需要登录才能访问
How to reproduce
English:
- Configure username and password in
application-eureka.yml - Start linkis-mg-eureka service
- Try to access Eureka Dashboard (http://ip:20303/)
- Observe whether authentication is required, or whether other services can register normally
中文:
- 在
application-eureka.yml中配置账号密码 - 启动 linkis-mg-eureka 服务
- 尝试访问 Eureka Dashboard (http://ip:20303/)
- 观察是否需要认证,或者其他服务是否能正常注册
Anything else
English:
Root Cause:
Eureka's security authentication requires Spring Security related dependencies to take effect. Configuration parameters alone are not sufficient.
Solution:
- Add Spring Security dependency to
linkis-mg-eureka'spom.xml:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>- Add Security configuration class to enable basic authentication
- 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:
- Spring Cloud Eureka Security: https://cloud.spring.io/spring-cloud-netflix/reference/html/#spring-cloud-eureka-server
中文:
根本原因:
Eureka的安全认证需要引入Spring Security相关依赖才能生效,仅配置参数是不够的。
解决方案:
- 在
linkis-mg-eureka的pom.xml中添加 Spring Security 依赖:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>- 添加 Security 配置类,启用基本认证
- 确保其他服务的Eureka客户端配置包含认证信息
相关技术要点:
- Spring Security 基本认证配置
- Eureka Client 认证配置
- 配置加密存储(可选)
参考文档:
- Spring Cloud Eureka Security: https://cloud.spring.io/spring-cloud-netflix/reference/html/#spring-cloud-eureka-server
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