# rrPinChe **Repository Path**: noworld_group/rrPinChe ## Basic Information - **Project Name**: rrPinChe - **Description**: 一个专注于为广大开车和有意拼车回家/外出的朋友们提供一站式解决方案的网站。 - **Primary Language**: Java - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2020-04-25 - **Last Updated**: 2022-06-25 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Spring boot+Security+Redis+MySql实现权限登录和反爬虫脚手架 ## 介绍 一个基于Spring boot 2.4.2、JDK 1.8、Security、防恶意请求技术实现的前后端分离的脚手架,可以为开发人员省去前期框架调研和搭建的成本。 ## 软件架构 1. Spring boot 2.4.2 2. JDK 1.8 3. Security 4. kk-anti-reptile(反爬虫接口防刷组件) 5. Redis 6. MySQL 7. MyBatis ## 安装教程 1. 克隆 [本代码到本地](https://gitee.com/noworld_group/springBootDemo/tree/master/springbootSecurity/shunfengche) 2. 修改application.yml配置,包含Mysql数据库信息、Redis连接信息、kk-anti-reptile配置信息(不修改也可以,默认,详细参数见:[kk-anti-reptile](https://gitee.com/kekingcn/kk-anti-reptile)) 3. 将项目other/SQL/中的脚本放到mysql中执行,初始化表结构 4. 启动项目 5. 使用测试工具或者前端连接请求 ## 使用说明 本示例在`TestWebSecurity`类中配置了Security前端登录接口和退出登录接口,如想自定义接口,请修改如下图圈中的配置 ![](http://noworld_group.gitee.io/statichtml/fengLong/site/images/20210122120254.png) `application.yml` 配置文件中`kk-anti-reptile` 部分配置如下: ```yml # 恶意请求 anti: reptile: manager: # 激活恶意请求/反爬虫配置 enabled: true # 需要拦截的请求,多个以“,”分隔,或者直接在controller方法上添加@AntiReptile # include-urls: ^/admin/.*$ ua-rule: #允许linux系统访问 allowed-linux: true # 全局拦截,默认为false,为false时,需要配置上面的include-urls global-filter-mode: true ``` 详细参数请参见[kk-anti-reptile](https://gitee.com/kekingcn/kk-anti-reptile) ## 请求示例 ### 登录接口 #### 请求链接 http://localhost:8099/auth/login #### 请求参数 username:admin password:1234 注意,此处需要使用表单提交,postman中如下: ![](http://noworld_group.gitee.io/statichtml/fengLong/site/images/20210122120255.png) #### 响应参数 登录成功返回参数如下: ```json { "code": "00000", "msg": "操作成功!", "data": { "token": "3aa72e4a-74b5-4542-9e56-e7f31ec5ce09", "permissions": [], "loginTime": 1611284216123 } } ``` 其中,token的值就是前端需要在每次请求中在请求头部传递到后端的参数 ### 退出登录接口 #### 请求链接 http://localhost:8099/auth/logout #### 请求参数 请求头部需要放置如下参数: X-token:token的值 Postman中如下: ![](http://noworld_group.gitee.io/statichtml/fengLong/site/images/20210122120256.png) #### 响应参数 ```json { "code": "00000", "msg": "您已经退出登录!" } ``` ### 正常接口 正常业务逻辑中调用的接口传参 #### 请求链接 http://localhost:8099/test/listOrientations #### 请求参数 header中必须带有X-token参数,其他业务参数请写在请求体中 Postman中如下: ![](http://noworld_group.gitee.io/statichtml/fengLong/site/images/20210122120257.png) #### 正常响应参数(没有超过反爬虫预警) ```json { "code": "00000", "msg": "ddd" } ``` #### 被拦截的响应参数 当使用postman多次请求,请求超过阈值,将会返回验证码页面(如果前端JQ请求,请参照[kk-anti-reptile](https://gitee.com/kekingcn/kk-anti-reptile)处理方式正常显示验证码) ```html kk-anti-reptile验证 普通验证码
操作频繁,请输入验证码
     刷新

``` ## 赞赏我 1. 如果您觉得这个不错,可以打赏下作者,您的赞同是作者不懈努力的源泉 ![](https://www.blog-china.cn/css/img/zhifubao.png) ![](https://www.blog-china.cn/css/img/wechatMa.png)