<mark>此插件，主要社区贡献人（Thief）</mark>，详情见：[代码仓库](https://gitee.com/dromara/solon-plugins/tree/master/captcha-solon-plugin)。版本已纳入 solon-parent 管理

```xml
<dependency>
    <groupId>org.dromara.solon-plugins</groupId>
    <artifactId>captcha-solon-plugin</artifactId>
</dependency>
```

#### 1、描述

基础扩展插件，基于 AJ-Captcha 适配，提供图形的验证码支持（支持 web, ios, android 等...）。AJ-Captcha 代码仓库：[https://gitee.com/anji-plus/captcha](https://gitee.com/anji-plus/captcha)


#### 2、配置参考

更多内容详见： https://ajcaptcha.beliefteam.cn/captcha-doc/


```yaml
aj.captcha:
  # aes加密坐标开启或者禁用(true|false)
  aes-status: true
  # 缓存local/redis...
  cache-type: local
  history-data-clear-enable: false
  # 滑动干扰项(0/1/2)
  interference-options: 2
  # 滑动验证，底图路径，不配置将使用默认图片
  # 支持全路径
  # 支持项目路径,以classpath:开头,取resource目录下路径,例：classpath:images/jigsaw
  #    jigsaw: classpath:images/jigsaw
  # 支持项目路径,以classpath:开头,取resource目录下路径,例：classpath:images/pic-click
  #    pic-click: classpath:images/pic-click
  # check接口一分钟内请求数限制
  req-check-minute-limit: 60
  # 接口请求次数一分钟限制是否开启 true|false
  req-frequency-limit-enable: true
  # 验证失败5次，get接口锁定
  req-get-lock-limit: 5
  # 验证失败后，锁定时间间隔,s
  req-get-lock-seconds: 360
  # get接口一分钟内请求数限制
  req-get-minute-limit: 30
  # check接口一分钟内请求数限制
  req-verify-minute-limit: 60
  # 校验滑动拼图允许误差偏移量(默认5像素)
  slip-offset: 5
  # 验证码类型default两种都实例化。
  type: default
  # 汉字统一使用Unicode,保证程序通过@value读取到是中文，可通过这个在线转换;yml格式不需要转换
  # https://tool.chinaz.com/tools/unicode.aspx 中文转Unicode
  water-mark: com.cn
```

后端较验示例：

```java
@Controller
public class LoginController {
    @Inject
    private CaptchaService captchaService;

    @Post
    @Mapping("/login")
    public ResponseModel get(CaptchaVO captchaVO) {
        //必传参数：captchaVO.captchaVerification
        ResponseModel response = captchaService.verification(captchaVO);
        if (response.isSuccess() == false) {
            //验证码校验失败，返回信息告诉前端
            //repCode  0000  无异常，代表成功
            //repCode  9999  服务器内部异常
            //repCode  0011  参数不能为空
            //repCode  6110  验证码已失效，请重新获取
            //repCode  6111  验证失败
            //repCode  6112  获取验证码失败,请联系管理员
            //repCode  6113  底图未初始化成功，请检查路径
            //repCode  6201  get接口请求次数超限，请稍后再试!
            //repCode  6206  无效请求，请重新获取验证码
            //repCode  6202  接口验证失败数过多，请稍后再试
            //repCode  6204  check接口请求次数超限，请稍后再试!
        }
        return response;
    }
}
```


#### 具体可参考

* [https://gitee.com/noear/solon-examples/tree/dev/3.Solon-Web/demo3038-auth_captcha](https://gitee.com/noear/solon-examples/tree/dev/3.Solon-Web/demo3038-auth_captcha)