# fir-cloud
**Repository Path**: sevenfir/fir-cloud
## Basic Information
- **Project Name**: fir-cloud
- **Description**: 基于Spring Cloud Alibaba 2021.0.5.0,Spring Boot 2.6.13实现的前后端分布式安全网关,可实现令牌校验,整体加密,防重放,完整性,xss,ip白名单等安全校验。
- **Primary Language**: Java
- **License**: MIT
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 4
- **Forks**: 2
- **Created**: 2024-05-08
- **Last Updated**: 2025-09-27
## Categories & Tags
**Categories**: Uncategorized
**Tags**: SpringCloud, SpringBoot, Security, Java
## README
Fir Cloud v1.0.0
基于Spring Cloud Alibaba微服务网关框架
## 简述
本项目配合前端项目**fir_security_vue2**可以运行。
## 🧭 功能说明
| 功能 | 实现 |
| :---------------------: | :--: |
| 令牌校验 | ✔ |
| 请求整体解密 | ✔ |
| 响应整体加密 | ✔ |
| 防重放校验 | ✔ |
| 完整性校验 | ✔ |
| xss校验 | ✔ |
| ip地址白名单 | ✔ |
| 接口地址白名单 | ✔ |
| Nacos配置、服务注册中心 | ✔ |
| Redis | ✔ |
| 访问日志记录器 | ✔ |
| 盐 | ✔ |
| AES对称加密 | ✔ |
| RSA非对称加密 | ✔ |
## 框架
| 框架 | 说明 | 版本 | 相关文档 |
| ------------------------------------------------------------ | -------------------------------- | -------------- | ------------------------------------------------------------ |
| [Spring Cloud Alibaba](https://github.com/alibaba/spring-cloud-alibaba) | 阿里分布式应用服务一站式解决方案 | 2021.0.5.0 | [文档](https://github.com/alibaba/spring-cloud-alibaba/blob/2023.x/README-zh.md) |
| [Spring Boot](https://spring.io/projects/spring-boot) | 应用开发框架 | 2.6.13 | [文档](https://github.com/YunaiV/SpringBoot-Labs) |
| [Spring Cloud Gateway](https://github.com/spring-cloud/spring-cloud-gateway) | Spring生态系统之上的API网关 | 2021.0.5.0 | [文档](https://springdoc.cn/spring-cloud-gateway/) |
| [nacos](https://github.com/alibaba/nacos) | 配置管理和服务管理 | 2021.0.5.0 | [文档](https://nacos.io/zh-cn/docs/quick-start-spring.html) |
| [loadbalancer](https://spring.io/guides/gs/spring-cloud-loadbalancer) | 负载均衡器 | 2021.0.5.0 | [文档](https://springdoc.cn/spring-cloud-load-balancer/) |
| [netflix-hystrix](https://github.com/Netflix/Hystrix) | 熔断器 | 2.2.10.RELEASE | [文档](https://github.com/Netflix/Hystrix/wiki/How-it-Works) |
| [feign](https://github.com/OpenFeign/feign) | 负载均衡和服务发现等功能 | 2021.0.5.0 | [文档](https://springdoc.cn/spring-cloud-openfeign/) |
| [Redis](https://redis.io/) | key-value 数据库 | 5.0 | [文档](https://www.redis.net.cn/tutorial/3501.html) |
| [hutool-all](https://github.com/dromara/hutool) | 功能丰富且易用的Java工具库 | 5.8.20 | [文档](https://doc.hutool.cn/pages/index/) |
| [jsoup](https://jsoup.org/) | Java 的HTML解析器 | 1.14.1 | [文档](https://jsoup.org/apidocs/) |
| [commons-lang3](https://github.com/apache/commons-lang) | 类型转换工具库 | 3.12.0 | [文档](https://commons.apache.org/proper/commons-lang/apidocs/) |
| [fastjson](https://github.com/alibaba/fastjson) | JSON 工具库 | 1.2.83 | [文档](https://github.com/alibaba/fastjson/wiki/Quick-Start-CN) |
## 版本选择
选择目前最新的Spring Boot 2.6.13作为基础。
| Spring Cloud Alibaba Version | Spring Cloud Version | Spring Boot Version |
| ---------------------------- | --------------------- | ------------------- |
| 2021.0.5.0 | Spring Cloud 2021.0.5 | 2.6.13 |
根据Spring Cloud的版本选择适合的中间件。
| Spring Cloud Alibaba Version | Sentinel Version | Nacos Version | RocketMQ Version | Dubbo Version | Seata Version |
| ---------------------------- | ---------------- | ------------- | ---------------- | ------------- | ------------- |
| 2021.0.5.0 | 1.8.6 | 2.2.0 | 4.9.4 | ~ | 1.6.1 |
## 执行流程

### 前端处理流程
**请求数据(请求拦截器)**
前端业务-->请求白名单-->添加请求头数据(token,sessionId)-->添加防重放信息-->添加完整性校验信息-->数据整体对称加密-->数据非对称加密-->http-->Gateway网关
**响应数据(响应拦截器)**
Gateway网关-->http-->前端-->401判断-->请求白名单-->非对称解密-->对称解密-->json转化处理-->前端业务
### 后端处理流程
**请求数据处理(请求拦截器)**
前端-->Gateway网关-->访问来源记录-->令牌token校验拦截器-->整体解密拦截器-->防重放拦截器-->完整性检验拦截器-->XSS拦截器-->负载均衡-->微服务。
**响应数据处理(响应拦截器)**
微服务-->整体加密拦截器-->http-->前端。