其他分享
首页 > 其他分享> > mica-captcha 验证码组件

mica-captcha 验证码组件

作者:互联网

验证码效果


图片

图片

图片





保证了验证码的安全性的同时尽量做到了美观,欢迎试用,更多使用方式可以查看 mica 示例项目。


依赖坐标

Maven

    net.dreamlu
    mica-captcha


Gradle

implementation "net.dreamlu:mica-captcha"


配置项

配置项默认值说明
mica.captcha.cache-namemicaCaptchaCache验证码cache名,默认:micaCaptchaCache
mica.captcha.cookie-namemica-captcha验证码cookie名,默认:mica-captcha
mica.captcha.enabledtrue是否开启验证码,默认:true.

注意:结合 mica-pro 的 mica-cache-redis 组件实现 cache name 使用 # 号自动配置超时时间。

使用

首先需要配置 Spring cache,如 ehcache、redis等,然后给 micaCaptchaCache 配置一个超时时间。

Servlet

  ;

 
 
(  ,   .)

  ( ) {
     .();
}


boolean validated = micaCaptcha.validate(response, userInputCaptcha);


WebFlux

  ;

 
 
(  ,   .)

  ( ) {
     .(.());
}


boolean validated = micaCaptcha.validate(exchange, userInputCaptcha);


生成其他类型验证码



标签:cache,校验,验证码,captcha,micaCaptcha,mica
来源: https://blog.51cto.com/15016434/2646096