当前位置: 首页> 房产> 建筑 > 视频号推广入口_免费自助建站源码_成都网络营销公司哪家好_上海seo推广公司

视频号推广入口_免费自助建站源码_成都网络营销公司哪家好_上海seo推广公司

时间:2025/7/10 13:28:17来源:https://blog.csdn.net/r65115257/article/details/145023124 浏览次数:0次
视频号推广入口_免费自助建站源码_成都网络营销公司哪家好_上海seo推广公司

要确保访问Eureka Server时要求输入账户和密码,需要确保以下几点:

  1. 确保 eurekaSecurityEnabled 配置为 true:这个配置项控制是否启用Eureka的安全认证。如果它被设置为 false,即使配置了用户名和密码,也不会启用安全认证。

  2. 确保 username 和 password 配置正确:你需要确保在配置文件中正确设置了 apollo.eureka.server.security.username 和 apollo.eureka.server.security.password

  3. 优化 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

修改的作用

  1. 根路径 (/) 需要认证

    • 当用户访问根路径(例如 http://localhost:8080/)时,会要求输入用户名和密码。

    • 满足合规要求,用户访问Eureka Dashboard时进行身份验证。

  2. Eureka相关路径需要认证

    • /eureka/apps/**/eureka/instances/** 和 /eureka/peerreplication/** 这些路径仍然需要认证。

  3. 其他路径允许匿名访问/** 表示所有其他路径允许匿名访问。如果希望所有路径都需要认证,可以将 /** 改为 .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页面,这在安全合规上通过不了

关键字:视频号推广入口_免费自助建站源码_成都网络营销公司哪家好_上海seo推广公司

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: