Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
fa4c127
fix(readme):常量引用错误修复
TestsLing Jul 22, 2022
19b6c0e
feat:增加redis存储机制,修复aes解密失败错误
TestsLing Sep 29, 2022
acfe947
docs:修改中文readme
TestsLing Sep 29, 2022
4ed3aab
Merge branch 'anji-plus:dev' into dev
TestsLing Sep 29, 2022
3958194
update view/html/css/verify.css.
ken678 Nov 13, 2022
8d1d95f
原有的redis缓存逻辑存在下述问题:
Tea-white Nov 13, 2024
7fdf504
!65 接口限制锁定问题
coding-now Nov 13, 2024
5a72b2e
文字点选验证码优化:
qiang1023 Dec 19, 2024
e31dd4d
!67 文字点选验证码优化
coding-now Dec 20, 2024
56c52c1
!47 update view/html/css/verify.css.
coding-now Dec 20, 2024
eb333a8
Merge remote-tracking branch 'origin/master' into dev
coding-now Dec 21, 2024
bb33282
接口限流功能失效修复 fix #66
Dec 23, 2024
39b9d73
接口限流功能失效修复
Dec 23, 2024
887fc91
add pr提交规范
Dec 23, 2024
479c68a
springboot2.x版本升级到2.7
Dec 23, 2024
80c3ea0
jdk升级到17后打包测试
Dec 23, 2024
7f4fcea
提供springboot3使用示例
Dec 23, 2024
e6b8090
图片资源 移入images公用
Dec 23, 2024
07c88c7
图片资源 移入images公用
Dec 24, 2024
d96d54c
fix github #188
Dec 24, 2024
e9f2cdd
close github #173 maven坐标规范调整
Dec 24, 2024
263708b
Merge branch 'dev' into dev
raodv Dec 24, 2024
dd97d11
Merge pull request #134 from TestsLing/dev
raodv Dec 24, 2024
9d41952
rm fastjson
Dec 25, 2024
580ea94
Merge remote-tracking branch 'origin/dev' into dev
Dec 25, 2024
14b846a
test local-docker-run
Dec 25, 2024
e39e7d9
response支持国际化init
Dec 26, 2024
73c857a
response支持国际化test
Dec 26, 2024
2bf9fa6
response支持国际化test
Dec 26, 2024
695a3a7
test local docker run with go
Dec 26, 2024
d94aa86
test local-docker-run
Dec 27, 2024
d12f513
test local-docker-run
Dec 27, 2024
85dd52b
test local-docker-run
Dec 27, 2024
b91814e
test local-docker-run
Dec 27, 2024
22e1699
服务端验证接口保留,以支持独立部署的场景
Dec 30, 2024
742c840
update README_CN.md.
Jan 7, 2025
386ccaf
deploy-centra
Jan 23, 2025
8af98dd
init-1.4.0
raodv Feb 24, 2025
8123d22
init-1.4.0
raodv Feb 24, 2025
ca5ecb4
init-1.4.0
raodv Feb 24, 2025
8945089
移植到spring boot 4.0.3
radarfyh Jun 29, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
Contributing
============

Contributions are welcome!

**Please carefully read this page to make the code review process go as smoothly as possible and to maximize the likelihood of your contribution being merged.**

## Bug Reports

For bug reports or requests [submit an issue](https://gitee.com/anji-plus/captcha/issues).

## Pull Requests

The preferred way to contribute is to fork the
[main repository](https://gitee.com/anji-plus/captcha) on Gitee.

1. Fork the [main repository](https://gitee.com/anji-plus/captcha). Click on the 'Fork' button near the top of the page. This creates a copy of the code under your account on the Gitee.

2. Clone this copy to your local disk:

$ git clone git@gitee.com:%YourLogin%/captcha.git
$ cd captcha

3. Create a branch to hold your changes and start making changes.

!!!!Note:: Don't work in the `master` branch!

$ git checkout -b my-feature

4. Work on this copy on your computer using Git to do the version control. When you're done editing, run the following to record your changes in Git:

$ git add modified_files
$ git commit

5. Push your changes to Gitee with:

$ git push -u origin my-feature

6. Finally, go to the web page of your fork of the `captcha` repo and click 'Pull Request' to send your changes for review.

7. If you want to update your pull request, just commit your changes to your branch and push to your fork.

8. ***important***: By submitting a patch, you agree to allow the project owners to license your work under the terms of the [Apache License 2.0](https://github.com/anji-plus/captcha/blob/master/LICENSE).

9. REMEMBER: submitting PR to branch anji-plus:dev instead of anji-plus:master.

### GitHub Pull Requests Docs

If you are not familiar with pull requests, review the [pull request docs](https://help.github.com/articles/using-pull-requests/).


13 changes: 10 additions & 3 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[![EN doc](https://img.shields.io/badge/document-English-blue.svg)](README.md)[![CN doc](https://img.shields.io/badge/文档-中文版-blue.svg)](README_CN.md)

## 简介
    AJ-Captcha行为验证码,包含滑动拼图、文字点选两种方式,UI支持弹出和嵌入两种方式。后端提供Java实现,前端提供了php、angular、html、vue、uni-app、flutter、android、ios等代码示例。
    AJ-Captcha行为验证码,包含滑动拼图、文字点选两种方式,UI支持弹出和嵌入两种方式。后端提供Java、Golang实现,前端提供了php、angular、html、vue、uni-app、flutter、android、ios等代码示例。

# 1 在线体验
**在线体验暂时下线**
Expand Down Expand Up @@ -47,7 +47,9 @@
├─service<br>
│&emsp;├─go &emsp;&emsp; 后端为go项目示例<br>
│&emsp;├─php &emsp;&emsp; 后端为php项目示例<br>
│&emsp;├─springboot &emsp;&emsp; 后端为springboot项目示例<br>
│&emsp;├─go &emsp;&emsp; 后端为go项目示例<br>
│&emsp;├─springboot &emsp;&emsp; 后端为springboot-2.x项目示例<br>
│&emsp;├─springboot3 &emsp;&emsp; 后端为springboot-3.x项目示例<br>
│&emsp;└─springmvc &emsp;&emsp; 后端为springmvc非springboot项目示例<br>
└─view &emsp;&emsp;&emsp;&emsp;&emsp; 多语言客户端示例<br>
&emsp;├─android &emsp;&emsp; 原生android实现示例<br>
Expand Down Expand Up @@ -75,8 +77,13 @@ I Your application is running here: http://localhost:8081
```
&emsp;详细的前后端接入文档,后端示例代码service目录下,前端示例代码view目录下。


# 6 技术支持,如有问题,请提交Issue
提交Issue前请查阅已有Issue.
如有兴趣提交PR,请参考[提交PR规范](./CONTRIBUTING.md),切忌不要直接提交大PR,否则会影响合并流程和审核时效,也不要提交到master分支。

技术交流群:新群可直接进<br>
<img src="https://ajreport.beliefteam.cn/file/download/495faaaa-4277-45e8-979a-ffccb6b1e86f" width = "200" height = auto />

加微信前请备注AJ-Captcha。
<br>微信群地址

Expand Down
40 changes: 19 additions & 21 deletions core/captcha-spring-boot-starter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,29 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.5.RELEASE</version>
<version>4.0.3</version>
</parent>

<groupId>com.anji-plus</groupId>
<artifactId>spring-boot-starter-captcha</artifactId>
<version>1.3.1</version>
<artifactId>captcha-spring-boot-starter</artifactId>
<version>1.4.1</version>

<name>captcha-spring-boot-starter</name>
<description>anji-plus captcha captcha-spring-boot-starter</description>
<url>https://github.com/anji-plus/captcha</url>
<packaging>jar</packaging>

<properties>
<java.version>1.8</java.version>
<spring-boot-version>2.3.5.RELEASE</spring-boot-version>
<java.version>17</java.version>
<spring-boot-version>4.0.3</spring-boot-version>
</properties>

<!-- Add typical dependencies for a web application -->
<dependencies>
<dependency>
<groupId>com.anji-plus</groupId>
<artifactId>captcha</artifactId>
<version>1.3.1</version>
<version>1.4.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
Expand All @@ -40,16 +40,17 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
</dependency>
<!-- @ConfigurationProperties annotation processing (metadata for IDEs) -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>


<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
<version>4.0.0-M2</version>
</dependency>
</dependencies>

<!--中央仓库上传配置开始-->
<licenses>
<!-- Apache许可证 -->
Expand Down Expand Up @@ -83,25 +84,22 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<source>17</source>
<target>17</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.4</version>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
Expand All @@ -114,7 +112,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
<executions>
<execution>
<id>attach-javadocs</id>
Expand All @@ -125,17 +122,18 @@
</executions>
<configuration>
<encoding>UTF-8</encoding>
<additionalparam>-Xdoclint:none</additionalparam>
<source>1.8</source>
<failOnError>false</failOnError>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.5</version>
<version>3.1.0</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>site</phase>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
Expand All @@ -147,11 +145,11 @@
<!-- 【注】snapshotRepository 与 repository 中的 id 一定要与 setting.xml 中 server 的 id 保持一致! -->
<distributionManagement>
<snapshotRepository>
<id>releases</id>
<id>center-releases</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>releases</id>
<id>center-releases</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2</url>
</repository>
</distributionManagement>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.anji.captcha.properties.AjCaptchaProperties;
import com.anji.captcha.service.CaptchaService;
import com.anji.captcha.service.impl.CaptchaServiceFactory;
import com.anji.captcha.util.Base64Utils;
import com.anji.captcha.util.ImageUtils;
import com.anji.captcha.util.StringUtils;
import org.slf4j.Logger;
Expand All @@ -15,7 +16,6 @@
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.core.io.support.ResourcePatternResolver;
import org.springframework.util.Base64Utils;
import org.springframework.util.FileCopyUtils;

import java.util.HashMap;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package com.anji.captcha.config;

import com.anji.captcha.model.common.ResponseModel;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.ApplicationContext;
import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.core.MethodParameter;
import org.springframework.http.MediaType;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.server.ServerHttpRequest;
import org.springframework.http.server.ServerHttpResponse;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice;

import java.util.Objects;

@Aspect
@ControllerAdvice
@Component
@ConditionalOnProperty(value = "aj.captcha.i18n.enabled",matchIfMissing = false)
public class I18nAspect implements ResponseBodyAdvice<Object> {

{
System.out.println("===>I18nAspect init...");
}

@Override
public boolean supports(MethodParameter returnType, Class<? extends HttpMessageConverter<?>> converterType) {
return returnType.getParameterType().isAssignableFrom(ResponseModel.class);
}

@Override
public Object beforeBodyWrite(Object body, MethodParameter returnType, MediaType selectedContentType,
Class<? extends HttpMessageConverter<?>> selectedConverterType,
ServerHttpRequest request, ServerHttpResponse response) {
if (body instanceof ResponseModel) {
ResponseModel res = (ResponseModel) body;
String code = res.getRepCode();
String desc = getMessage(code,res);
res.setRepMsg(desc);
return res;
}
return body;
}

private String getMessage(String code,ResponseModel res){
try {
if(Objects.isNull(messageSource)){
messageSource = applicationContext.getBean(MessageSource.class);
}
return messageSource.getMessage(prefix + code, null, LocaleContextHolder.getLocale());
} catch (Exception e) {
return res.getRepMsg(); // 如果找不到对应的国际化信息,返回默认信息
}
}

@Autowired(required = false)
private MessageSource messageSource;

@Value("${aj.captcha.i18n.prefix:aj.captcha.}")
private String prefix;

@Autowired
private ApplicationContext applicationContext;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
com.anji.captcha.config.AjCaptchaAutoConfiguration
15 changes: 7 additions & 8 deletions core/captcha/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.anji-plus</groupId>
<artifactId>captcha</artifactId>
<version>1.3.1</version>
<version>1.4.0</version>

<name>${project.groupId}:${project.artifactId}</name>
<description>anji-plus captcha.jar</description>
Expand Down Expand Up @@ -63,7 +63,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
Expand All @@ -81,7 +80,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
Expand All @@ -94,7 +92,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
<version>3.11.2</version>
<executions>
<execution>
<id>attach-javadocs</id>
Expand All @@ -105,7 +103,8 @@
</executions>
<configuration>
<encoding>UTF-8</encoding>
<additionalparam>-Xdoclint:none</additionalparam>
<source>1.8</source>
<failOnError>false</failOnError>
</configuration>
</plugin>
<plugin>
Expand All @@ -115,7 +114,7 @@
<executions>
<execution>
<id>sign-artifacts</id>
<phase>site</phase>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
Expand All @@ -127,11 +126,11 @@
<!-- 【注】snapshotRepository 与 repository 中的 id 一定要与 setting.xml 中 server 的 id 保持一致! -->
<distributionManagement>
<snapshotRepository>
<id>releases</id>
<id>center-releases</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>releases</id>
<id>center-releases</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2</url>
</repository>
</distributionManagement>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,17 @@ public interface CaptchaCacheService {
String type();

/***
*
* key 存在,返回存在的值+val,key不存在 返回val
* @param key
* @param val
* @return
*/
default Long increment(String key, long val){
return 0L;
return val;
};

void setExpire(String key, long l);
default void setExpire(String key, long l){

};

}
Loading