代码拉取完成,页面将自动刷新
未上传到中央库,需手动编译构建打包!!!
mvn clean install
<!-- 验证码 -->
<dependency>
<groupId>cn.com.stary1993.kite.captcha</groupId>
<artifactId>kite-captcha-spring-boot-starter</artifactId>
<version>1.1.0</version>
</dependency>
<!--验证码缓存,可以不需要-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
spring:
application:
name: @project.name@
# redis 验证码缓存
redis:
port: 6379
host: 127.0.0.1
database: 0
# 验证码配置
captcha:
enabled: true
simple:
enabled: true
line-count: 6
behavior:
enabled: true
@CrossOrigin
@RequiredArgsConstructor
@RestController
@RequestMapping("/captcha")
public class CaptchaDemoController {
private final SimpleImageCaptcha simpleImageCaptcha;
private final BehaviorImageCaptcha behaviorImageCaptcha;
@SneakyThrows
@GetMapping("/simple/gen1")
public void genSimpleImageCaptchaStream(HttpServletResponse response, @RequestParam("type") String type, String timestamp) {
simpleImageCaptcha.out(SimpleImageCaptchaType.valueOf(type), timestamp, response.getOutputStream());
}
@PostMapping("/simple/check1")
public Boolean checkSimpleImageCaptchaStream(@RequestParam("type") String type, String timestamp, @RequestParam("code") String code) {
return simpleImageCaptcha.verify(SimpleImageCaptchaType.valueOf(type), timestamp, code);
}
@GetMapping("/simple/gen2")
public CaptchaResponse<SimpleCaptchaVO> genSimpleImageCaptcha(@RequestParam("type") String type, @RequestParam("timestamp") String timestamp) {
return simpleImageCaptcha.generate(SimpleImageCaptchaType.valueOf(type), timestamp);
}
@PostMapping("/simple/check2")
public Boolean checkSimpleImageCaptcha(@RequestParam("id") String id, @RequestParam("type") String type, @RequestParam("timestamp") String timestamp, @RequestParam("code") String code) {
return simpleImageCaptcha.verify(id, SimpleImageCaptchaType.valueOf(type), timestamp, code);
}
@GetMapping("/behavior/gen")
public CaptchaResponse<BehaviorCaptchaVO> genBehaviorImageCaptcha(@RequestParam("type") String type) {
return behaviorImageCaptcha.generate(type);
}
@PostMapping("/behavior/check")
public ApiResponse checkBehaviorImageCaptcha(@RequestParam("id") String id, @RequestBody BehaviorImageCaptchaTrack imageCaptchaTrack) {
return behaviorImageCaptcha.matching(id, imageCaptchaTrack);
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。