江苏省建设厅八大员考试报名网站,知名跟单网站做信号提供方,有接口怎么做网站,设计杂志官网要确保访问Eureka Server时要求输入账户和密码#xff0c;需要确保以下几点#xff1a; 确保 eurekaSecurityEnabled 配置为 true#xff1a;这个配置项控制是否启用Eureka的安全认证。如果它被设置为 false#xff0c;即使配置了用户名和密码#xff0c;也不会启用安全认… 要确保访问Eureka Server时要求输入账户和密码需要确保以下几点 确保 eurekaSecurityEnabled 配置为 true这个配置项控制是否启用Eureka的安全认证。如果它被设置为 false即使配置了用户名和密码也不会启用安全认证。 确保 username 和 password 配置正确你需要确保在配置文件中正确设置了 apollo.eureka.server.security.username 和 apollo.eureka.server.security.password。 优化 configure(HttpSecurity http) 方法当前的配置允许所有请求通过 permitAll()即使启用了安全认证某些路径仍然可以匿名访问。你需要调整这些路径的权限。
优化前的代码此代码为apollo-configserver的2.x.x以上代码 Overrideprotected void configure(HttpSecurity http) throws Exception {http.csrf().disable();http.httpBasic();if (eurekaSecurityEnabled) {http.authorizeRequests().antMatchers(/eureka/apps/**, /eureka/instances/**, /eureka/peerreplication/**).hasRole(EUREKA_ROLE).antMatchers(/**).permitAll();}}
如果不修改访问eureka dashboard时直接进入到dashboard界面安全合规审核不过要求增加账户审核。
优化后的代码 Overrideprotected void configure(HttpSecurity http) throws Exception {http.csrf().disable();http.httpBasic();if (eurekaSecurityEnabled) {http.authorizeRequests().antMatchers(/,/eureka/apps/**,/eureka/instances/**,/eureka/peerreplication/**).hasRole(EUREKA_ROLE).antMatchers(/**).permitAll();}} 在 application.yml添加如下内容
apollo:eureka:server:security:username: demo1password: demo1enabled: true
修改的作用 根路径 (/) 需要认证 当用户访问根路径例如 http://localhost:8080/时会要求输入用户名和密码。 满足合规要求用户访问Eureka Dashboard时进行身份验证。 Eureka相关路径需要认证 /eureka/apps/**、/eureka/instances/** 和 /eureka/peerreplication/** 这些路径仍然需要认证。 其他路径允许匿名访问/** 表示所有其他路径允许匿名访问。如果希望所有路径都需要认证可以将 /** 改为 .anyRequest().authenticated()。代码如下修改 protected void configure(HttpSecurity http) throws Exception {http.csrf().disable();http.httpBasic();if (eurekaSecurityEnabled) {http.authorizeRequests().antMatchers(/, /eureka/apps/**,/eureka/instances/**,/eureka/peerreplication/**).hasRole(EUREKA_ROLE) .anyRequest().authenticated(); } else {http.authorizeRequests().anyRequest().permitAll(); }
} 增加项动启执行后如下不然就直接进入到dashboard页面这在安全合规上通过不了