1 Star 6 Fork 0

贾同学 / kite-captcha-spring-boot-starter

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

kite-captcha-spring-boot-starter

使用说明

添加依赖

:exclamation: 未上传到中央库,需手动编译构建打包!!!

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);
    }

}

前后端分离 demo

MIT License Copyright (c) 2022 贾同学 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

普通图形验证码[普通,GIF,中文,简单算数],行为验证码 [滑块验证码、点选验证码、行为验证码、旋转验证码, 滑动验证码] 展开 收起
Java 等 2 种语言
MIT
取消

发行版 (1)

全部

贡献者

全部

近期动态

加载更多
不能加载更多了
Java
1
https://gitee.com/stary1993/kite-captcha-spring-boot-starter.git
git@gitee.com:stary1993/kite-captcha-spring-boot-starter.git
stary1993
kite-captcha-spring-boot-starter
kite-captcha-spring-boot-starter
v1.1.0

搜索帮助

53164aa7 5694891 3bd8fe86 5694891