Skip to content

如何正确集成控制台

HaojunRen edited this page May 31, 2024 · 2 revisions

本文档只适用于Discovery 6.20.0及以上版本的集成方式

控制台,通过暴露Http Rest Endpoint的方式,向外提供链路智能编排、无损下线黑名单、网关动态路由、故障转移等操作

集成方式

控制台,默认集成集成Swagger组件(Spring Boot 3.0.0以上版本除外)

框架默认集成的Swagger版本

<swagger.version>1.5.21</swagger.version>
<springfox.swagger.version>2.9.2</springfox.swagger.version>

集成依赖

<dependency>
    <!-- <groupId>org.springframework.cloud</groupId> -->
    <!-- <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId> -->
    <!-- <artifactId>spring-cloud-starter-consul-discovery</artifactId> -->
    <!-- <artifactId>spring-cloud-starter-zookeeper-discovery</artifactId> -->

    <groupId>com.alibaba.cloud</groupId>
    <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>

<dependency>
    <groupId>com.nepxion</groupId>
    <!-- <artifactId>discovery-console-starter-apollo</artifactId> -->
    <artifactId>discovery-console-starter-nacos</artifactId>
    <!-- <artifactId>discovery-console-starter-redis</artifactId> -->
    <!-- <artifactId>discovery-console-starter-zookeeper</artifactId> -->
    <!-- <artifactId>discovery-console-starter-consul</artifactId> -->
    <!-- <artifactId>discovery-console-starter-etcd</artifactId> -->
</dependency>

安全问题

对于内网向外网暴露接口控制不严格的企业,暴露Http Rest Endpoint可能存在一些风险

控制台,提供相关开关关闭对应的Endpoint

# 启动和关闭服务相关操作端点。缺失则默认为true
spring.application.console.service.endpoint.enabled=true
# 启动和关闭配置相关操作端点。缺失则默认为true
spring.application.console.config.endpoint.enabled=true
# 启动和关闭版本相关操作端点。缺失则默认为true
spring.application.console.version.endpoint.enabled=true
# 启动和关闭侦测相关操作端点。缺失则默认为true
spring.application.console.inspector.endpoint.enabled=true
# 启动和关闭网关路由相关操作端点。缺失则默认为true
spring.application.console.route.endpoint.enabled=true
# 启动和关闭策略相关操作端点。缺失则默认为true
spring.application.console.strategy.endpoint.enabled=true
# 启动和关闭Sentinel相关操作端点。缺失则默认为true
spring.application.console.sentinel.endpoint.enabled=true
# 启动和关闭无损下线黑名单相关操作端点。缺失则默认为true
spring.application.console.blacklist.endpoint.enabled=true
# 启动和关闭故障转移相关操作端点。缺失则默认为true
spring.application.console.failover.endpoint.enabled=true
# 启动和关闭认证相关操作端点。缺失则默认为true
spring.application.console.authentication.endpoint.enabled=true
# 启动和关闭策略操作端点的验证SPEL表达式方法。缺失则默认为true
# 该端点方法使用Spring StandardEvaluationContext类,StandardEvaluationContext支持全部的Spel语法且功能齐全,但GitHub Security报告其存在一定的注入风险,推荐使用SimpleEvaluationContext,而SimpleEvaluationContext并不能满足当前框架的需求
# 如果未使用验证SPEL表达式方法,可以通过下面开关关闭在方法在策略端点上的暴露,规避风险
spring.application.console.strategy.endpoint.validate-expression.enabled=true

关闭和重用Swagger

控制台提供关闭Swagger的功能,同时也可以通过自定义重用框架内置的Swagger模块的方式,使用者如果希望扩展,不需要再写Swagger自动装配类

具体用法,请参考




2017-2050 ©Nepxion Studio Apache License

           

Total visits

讲义篇

集成篇

概念篇

实践篇

功能篇

配置篇

扩展篇

测试篇

升级篇

贡献篇

Clone this wiki locally