Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
jobmission committed Jul 20, 2024
1 parent a86f854 commit 445e8fd
Show file tree
Hide file tree
Showing 20 changed files with 53 additions and 23 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.3.1</version>
<version>3.3.2</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

Expand All @@ -23,7 +23,7 @@
<java.version>17</java.version>
<org.mapstruct.version>1.5.5.Final</org.mapstruct.version>
<commons-text.version>1.12.0</commons-text.version>
<tianai-captcha.version>1.4.1</tianai-captcha.version>
<tianai-captcha.version>1.5.0</tianai-captcha.version>
</properties>

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
package com.revengemission.sso.oauth2.server.controller;

import cloud.tianai.captcha.application.ImageCaptchaApplication;
import cloud.tianai.captcha.application.vo.CaptchaResponse;
import cloud.tianai.captcha.application.vo.ImageCaptchaVO;
import cloud.tianai.captcha.common.constant.CaptchaTypeConstant;
import cloud.tianai.captcha.common.response.ApiResponse;
import cloud.tianai.captcha.spring.application.ImageCaptchaApplication;
import cloud.tianai.captcha.resource.ResourceStore;
import cloud.tianai.captcha.resource.common.model.dto.Resource;
import cloud.tianai.captcha.spring.plugins.secondary.SecondaryVerificationApplication;
import cloud.tianai.captcha.spring.vo.CaptchaResponse;
import cloud.tianai.captcha.spring.vo.ImageCaptchaVO;
import cloud.tianai.captcha.validator.common.model.dto.ImageCaptchaTrack;
import jakarta.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
Expand All @@ -20,16 +23,20 @@

@RequestMapping(value = "/captcha")
@Controller
public class CaptchaController {
public class CaptchaController implements InitializingBean {

private Logger log = LoggerFactory.getLogger(this.getClass());

@Autowired
private ImageCaptchaApplication imageCaptchaApplication;

@Autowired
private ResourceStore resourceStore;

@RequestMapping("/gen")
@ResponseBody
public CaptchaResponse<ImageCaptchaVO> genCaptcha(HttpServletRequest request, @RequestParam(value = "type", required = false) String type) {
public CaptchaResponse<ImageCaptchaVO> genCaptcha(HttpServletRequest request,
@RequestParam(value = "type", required = false) String type) {
if (StringUtils.isBlank(type)) {
type = CaptchaTypeConstant.SLIDER;
}
Expand Down Expand Up @@ -61,6 +68,22 @@ public ApiResponse<?> checkCaptcha(@RequestBody Data data,
return response;
}

@Override
public void afterPropertiesSet() throws Exception {
// 2. 添加自定义背景图片
resourceStore.addResource(CaptchaTypeConstant.SLIDER, new Resource("classpath", "bgimages/a.jpg", "default"));
resourceStore.addResource(CaptchaTypeConstant.SLIDER, new Resource("classpath", "bgimages/b.jpg", "default"));
resourceStore.addResource(CaptchaTypeConstant.SLIDER, new Resource("classpath", "bgimages/c.jpg", "default"));
resourceStore.addResource(CaptchaTypeConstant.SLIDER, new Resource("classpath", "bgimages/d.jpg", "default"));
resourceStore.addResource(CaptchaTypeConstant.SLIDER, new Resource("classpath", "bgimages/g.jpg", "default"));
resourceStore.addResource(CaptchaTypeConstant.SLIDER, new Resource("classpath", "bgimages/i.jpg", "default"));
resourceStore.addResource(CaptchaTypeConstant.SLIDER, new Resource("classpath", "bgimages/x.jpg", "default"));
resourceStore.addResource(CaptchaTypeConstant.SLIDER, new Resource("classpath", "bgimages/y.jpg", "default"));
resourceStore.addResource(CaptchaTypeConstant.ROTATE, new Resource("classpath", "bgimages/48.jpg", "default"));
resourceStore.addResource(CaptchaTypeConstant.CONCAT, new Resource("classpath", "bgimages/48.jpg", "default"));
resourceStore.addResource(CaptchaTypeConstant.WORD_IMAGE_CLICK, new Resource("classpath", "bgimages/c.jpg", "default"));
}

@lombok.Data
public static class Data {
private String id;
Expand Down
13 changes: 9 additions & 4 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,15 @@ dozer.mapping-files=classpath:dozer/mapper.xml
thirdparty.weixin.mini.appid=
thirdparty.weixin.mini.secret=

captcha.expire.default=10000
captcha.expireWORD_IMAGE_CLICK=60000
captcha.cache.enabled=true
captcha.prefix=captcha
captcha.expire.default=120000
captcha.expire.WORD_IMAGE_CLICK=180000
captcha.init-default-resource=true
captcha.local-cache-enabled=true
captcha.cache.cache-size=20
captcha.local-cache-wait-time=5000
captcha.local-cache-period=120000
captcha.secondary.enabled=false
captcha.init-default-resource=true
captcha.expire=120000
captcha.keyPrefix=captcha:secondary

Binary file added src/main/resources/bgimages/48.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/resources/bgimages/a.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/resources/bgimages/b.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/resources/bgimages/c.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/resources/bgimages/d.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/resources/bgimages/g.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/resources/bgimages/i.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/resources/bgimages/x.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/resources/bgimages/y.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/main/resources/static/assets/tac/js/tac.min.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/main/resources/static/assets/tac/load.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion src/main/resources/static/assets/tianai/tac.min.js

This file was deleted.

8 changes: 4 additions & 4 deletions src/main/resources/templates/signIn.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
href="../static/assets/bootstrap/css/bootstrap.min.css"
th:href="@{/assets/bootstrap/css/bootstrap.min.css}" />
<link rel="stylesheet"
href="../static/assets/tianai/styles/tac.css"
th:href="@{/assets/tianai/styles/tac.css}" />
href="../static/assets/tac/css/tac.css"
th:href="@{/assets/tac/css/tac.css}" />
</head>

<body>
Expand Down Expand Up @@ -56,8 +56,8 @@ <h3 class="text-center">登录</h3>
th:src="@{/assets/bootstrap/js/bootstrap.min.js}"></script>
<script th:src="@{/assets/localforage.min.js}"
src="../static/assets/localforage.min.js"></script>
<script src="../static//assets/tianai/tac.min.js"
th:src="@{/assets/tianai/tac.min.js}"></script>
<script src="../static//assets/tac/js/tac.min.js"
th:src="@{/assets/tac/js/tac.min.js}"></script>
<script th:inline="javascript">
/*<![CDATA[*/
var captchaPassed = false;
Expand Down
9 changes: 5 additions & 4 deletions src/main/resources/templates/signUp.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
<link rel="stylesheet" href="../static/assets/bootstrap/css/bootstrap.min.css"
th:href="@{/assets/bootstrap/css/bootstrap.min.css}"/>
<link rel="stylesheet"
href="../static/assets/tianai/styles/tac.css"
th:href="@{/assets/tianai/styles/tac.css}" />
href="../static/assets/tac/css/tac.css"
th:href="@{/assets/tac/css/tac.css}" />
</head>

<body>
Expand Down Expand Up @@ -57,8 +57,8 @@ <h3 class="text-center">注册</h3>
<script th:src="@{/assets/localforage.min.js}" src="../static/assets/localforage.min.js"></script>
<script th:src="@{/assets/sweetalert2/sweetalert2.all.min.js}"
src="../static/assets/sweetalert2/sweetalert2.all.min.js"></script>
<script src="../static//assets/tianai/tac.min.js"
th:src="@{/assets/tianai/tac.min.js}"></script>
<script src="../static/assets/tac/js/tac.min.js"
th:src="@{/assets/tac/js/tac.min.js}"></script>
<script th:inline="javascript">
/*<![CDATA[*/
var captchaPassed = false;
Expand Down Expand Up @@ -136,6 +136,7 @@ <h3 class="text-center">注册</h3>
icon: 'error',
confirmButtonText: '确定'
})
captchaPassed = false;
} else {
window.location.href = "/";
}
Expand Down

0 comments on commit 445e8fd

Please sign in to comment.