Code Monkey home page Code Monkey logo

spring-boot-starter-kaptcha's Introduction

spring-boot-starter-kaptcha : google-kaptcha验证码自动加载组件

freemark maven

它有什么作用

  • spring-boot-starter配置加载 组件通过spring-boot-starter方式加载

  • 支持集群/分布式 验证码生成后,存于缓存,组件中的缓存部分由agile-cache缓存提供,当集群/分布式环境中,可将缓存配置为redis缓存,以此实现 无状态化服务

  • 开放所有自定义配置 开放了可以开放的所有配置项

  • 自定义验证码访问地址 可以定义验证码访问地址

  • 自动过期 验证码可以配置过期时间


快速入门

开始你的第一个项目是非常容易的。

步骤 1: 下载包

您可以从[最新稳定版本]下载包(https://github.com/mydeathtrial/spring-boot-starter-kaptcha/releases). 该包已上传至maven**仓库,可在pom中直接声明引用

以版本spring-boot-starter-kaptcha-2.1.0.M5.jar为例。

步骤 2: 添加maven依赖

<!--声明**仓库-->
<repositories>
    <repository>
        <id>cent</id>
        <url>https://repo1.maven.org/maven2/</url>
    </repository>
</repositories>
        <!--声明依赖-->
<dependency>
<groupId>cloud.agileframework</groupId>
<artifactId>spring-boot-starter-kaptcha</artifactId>
<version>2.1.0.M5</version>
</dependency>

步骤 3: 开箱即用

//验证码组件开关
agile.kaptcha.enable=true
//验证码失效时间
agile.kaptcha.live-time=30s
//前后端传输验证码相关令牌参数
agile.kaptcha.token-header=V-CODE
//验证码访问地址
agile.kaptcha.url=/code
//google kaptcha 验证码原生配置,可按需自行扩展
agile.kaptcha.properties.kaptcha.background.clear.from=45,45,45
agile.kaptcha.properties.kaptcha.background.clear.to=45,45,45
agile.kaptcha.properties.kaptcha.noise.color=white
agile.kaptcha.properties.kaptcha.border=yes
agile.kaptcha.properties.kaptcha.border.color=white
agile.kaptcha.properties.kaptcha.textproducer.font.color=white
agile.kaptcha.properties.kaptcha.textproducer.font.size=40
agile.kaptcha.properties.kaptcha.image.width=125
agile.kaptcha.properties.kaptcha.image.height=45
agile.kaptcha.properties.kaptcha.textproducer.char.length=4
agile.kaptcha.properties.kaptcha.textproducer.font.names="微软雅黑"
agile.kaptcha.properties.kaptcha.obscurificator.impl=com.google.code.kaptcha.impl.ShadowGimpy
自定义验证码内容
//自定义验证码内容
agile.kaptcha.text='我爱你**'
//指定验证码内容生成器
agile.kaptcha.properties.kaptcha.textproducer.impl=cloud.agileframework.kaptcha.kaptcha.AgileTextProducer

步骤 4: 直接访问

以上面的配置为例,访问地址为http://localhost:8080/code,访问后会在客户端会接收到验证码图片数据

步骤 5: 后端获取当前请求的合法验证码

//同步访问中,将请求HttpServletRequest当作参数,组件会在请求中获取验证码令牌`agile.kaptcha.token-header`
//通过获取到的令牌,在缓存中提取已生成的合法验证码
KaptchaContextHolder.code(HttpServletRequest request)

spring-boot-starter-kaptcha's People

Contributors

mydeathtrial avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.