From b6caecf1406236b9db67541f624ff29344dd3ddf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=BE=E6=96=87=E8=B1=AA?= <980287353@qq.com> Date: Tue, 11 Jun 2024 16:11:14 +0800 Subject: [PATCH] publish 1.1.3 --- pom.xml | 20 ++++----- springboot-ademo/pom.xml | 4 +- .../demo/config/JWTAuthenticationFilter.java | 43 +++++++++++++++++++ .../demo/config/TieshengSecurityAdapter.java | 29 +++++++++++++ .../src/main/resources/application-test.yml | 2 + .../src/main/resources/application.yml | 2 + springboot-annotation/pom.xml | 2 +- springboot-database/pom.xml | 2 +- springboot-encrypt/pom.xml | 2 +- springboot-login/pom.xml | 2 +- springboot-message/pom.xml | 2 +- .../config/aliyun/AliyunSmsSender.java | 14 ++++-- springboot-platform/pom.xml | 2 +- springboot-poi/pom.xml | 2 +- springboot-util/pom.xml | 2 +- springboot-web/pom.xml | 2 +- 16 files changed, 107 insertions(+), 25 deletions(-) create mode 100644 springboot-ademo/src/main/java/com/tiesheng/demo/config/JWTAuthenticationFilter.java create mode 100644 springboot-ademo/src/main/java/com/tiesheng/demo/config/TieshengSecurityAdapter.java diff --git a/pom.xml b/pom.xml index 52637f0..7ba87c2 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.tiesheng.springboot-parent springboot-parent - 1.1.2 + 1.1.3 pom springboot-parent 杭州铁晟科技有限公司基础依赖 @@ -57,55 +57,55 @@ com.tiesheng.springboot-parent springboot-database - 1.1.2 + 1.1.3 com.tiesheng.springboot-parent springboot-login - 1.1.2 + 1.1.3 com.tiesheng.springboot-parent springboot-web - 1.1.2 + 1.1.3 com.tiesheng.springboot-parent springboot-util - 1.1.2 + 1.1.3 com.tiesheng.springboot-parent springboot-platform - 1.1.2 + 1.1.3 com.tiesheng.springboot-parent springboot-message - 1.1.2 + 1.1.3 com.tiesheng.springboot-parent springboot-encrypt - 1.1.2 + 1.1.3 com.tiesheng.springboot-parent springboot-annotation - 1.1.2 + 1.1.3 com.tiesheng.springboot-parent springboot-poi - 1.1.2 + 1.1.3 diff --git a/springboot-ademo/pom.xml b/springboot-ademo/pom.xml index 0a3183d..65f444f 100644 --- a/springboot-ademo/pom.xml +++ b/springboot-ademo/pom.xml @@ -6,11 +6,11 @@ com.tiesheng.springboot-parent springboot-parent - 1.1.2 + 1.1.3 springboot-ademo - 1.1.2 + 1.1.3 8 diff --git a/springboot-ademo/src/main/java/com/tiesheng/demo/config/JWTAuthenticationFilter.java b/springboot-ademo/src/main/java/com/tiesheng/demo/config/JWTAuthenticationFilter.java new file mode 100644 index 0000000..ce4bc5f --- /dev/null +++ b/springboot-ademo/src/main/java/com/tiesheng/demo/config/JWTAuthenticationFilter.java @@ -0,0 +1,43 @@ +//package com.tiesheng.demo.config; +// +//import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; +//import org.springframework.security.core.GrantedAuthority; +//import org.springframework.security.core.authority.SimpleGrantedAuthority; +//import org.springframework.security.core.context.SecurityContextHolder; +//import org.springframework.security.web.authentication.WebAuthenticationDetailsSource; +//import org.springframework.web.filter.OncePerRequestFilter; +// +//import javax.servlet.FilterChain; +//import javax.servlet.ServletException; +//import javax.servlet.http.HttpServletRequest; +//import javax.servlet.http.HttpServletResponse; +//import java.io.IOException; +//import java.util.ArrayList; +//import java.util.List; +// +//public class JWTAuthenticationFilter extends OncePerRequestFilter { +// +// public JWTAuthenticationFilter(JwtTokenProvider tokenProvider) { +// this.tokenProvider = tokenProvider; +// } +// +// @Override +// protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { +// String authHeader = request.getHeader("Authorization"); +// if (authHeader != null && authHeader.startsWith("Bearer ")) { +// String token = authHeader.substring(7); +// String username = tokenProvider.getUsername(token); +// if (username != null && SecurityContextHolder.getContext().getAuthentication() == null) { +// if (tokenProvider.validateToken(token)) { +// List authorities = new ArrayList<>(); +// // 根据你的应用程序需求设置权限 +// authorities.add(new SimpleGrantedAuthority("ROLE_USER")); +// UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(username, null, authorities); +// authenticationToken.setDetails(new WebAuthenticationDetailsSource().buildDetails(request)); +// SecurityContextHolder.getContext().setAuthentication(authenticationToken); +// } +// } +// } +// filterChain.doFilter(request, response); +// } +//} diff --git a/springboot-ademo/src/main/java/com/tiesheng/demo/config/TieshengSecurityAdapter.java b/springboot-ademo/src/main/java/com/tiesheng/demo/config/TieshengSecurityAdapter.java new file mode 100644 index 0000000..971183d --- /dev/null +++ b/springboot-ademo/src/main/java/com/tiesheng/demo/config/TieshengSecurityAdapter.java @@ -0,0 +1,29 @@ +//package com.tiesheng.demo.config; +// +//import cn.hutool.extra.spring.SpringUtil; +//import org.springframework.context.annotation.Configuration; +//import org.springframework.security.config.annotation.web.builders.HttpSecurity; +//import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +//import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; +//import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; +// +//import javax.servlet.http.HttpServletResponse; +// +//@Configuration +//@EnableWebSecurity +//public class TieshengSecurityAdapter extends WebSecurityConfigurerAdapter { +// +// @Override +// protected void configure(HttpSecurity http) throws Exception { +// SpringUtil.getBeanFactory().getA +// http.csrf().disable() // JWT 通常与状态无关,因此 CSRF 保护不适用 +// .authorizeRequests() +// .antMatchers("/login").permitAll() // 登录接口允许所有人访问 +// .anyRequest().authenticated() // 其他所有请求需要认证 +// .and() +// .exceptionHandling() +// .authenticationEntryPoint((request, response, authException) -> response.sendError(HttpServletResponse.SC_UNAUTHORIZED)) +// .and() +// .addFilterBefore(new JWTAuthenticationFilter(tokenProvider), UsernamePasswordAuthenticationFilter.class); +// } +//} diff --git a/springboot-ademo/src/main/resources/application-test.yml b/springboot-ademo/src/main/resources/application-test.yml index 0b0b38c..e997b01 100644 --- a/springboot-ademo/src/main/resources/application-test.yml +++ b/springboot-ademo/src/main/resources/application-test.yml @@ -25,3 +25,5 @@ tiesheng: aliyun: access-key-id: LTAI5tJtbgBCnTY5eS4SmrTf access-key-secret: JIHqpRUFffCHhXaJEVvWN31WcexWqG + encrypt: + body: true diff --git a/springboot-ademo/src/main/resources/application.yml b/springboot-ademo/src/main/resources/application.yml index 6585c49..ac6bcf9 100644 --- a/springboot-ademo/src/main/resources/application.yml +++ b/springboot-ademo/src/main/resources/application.yml @@ -9,6 +9,7 @@ spring: servlet: multipart: max-file-size: 20MB + max-request-size: 20MB web: resources: static-locations: classpath:/static/,file:static/ @@ -24,3 +25,4 @@ tiesheng: token: ignore-paths: - /test/index + diff --git a/springboot-annotation/pom.xml b/springboot-annotation/pom.xml index 1002276..9e47c8c 100644 --- a/springboot-annotation/pom.xml +++ b/springboot-annotation/pom.xml @@ -6,7 +6,7 @@ com.tiesheng.springboot-parent springboot-parent - 1.1.2 + 1.1.3 springboot-annotation diff --git a/springboot-database/pom.xml b/springboot-database/pom.xml index ec8ccb3..a0a63ea 100644 --- a/springboot-database/pom.xml +++ b/springboot-database/pom.xml @@ -6,7 +6,7 @@ com.tiesheng.springboot-parent springboot-parent - 1.1.2 + 1.1.3 springboot-database diff --git a/springboot-encrypt/pom.xml b/springboot-encrypt/pom.xml index afcbbd2..37d5c33 100644 --- a/springboot-encrypt/pom.xml +++ b/springboot-encrypt/pom.xml @@ -6,7 +6,7 @@ com.tiesheng.springboot-parent springboot-parent - 1.1.2 + 1.1.3 springboot-encrypt diff --git a/springboot-login/pom.xml b/springboot-login/pom.xml index 9dff645..5b98cd1 100644 --- a/springboot-login/pom.xml +++ b/springboot-login/pom.xml @@ -6,7 +6,7 @@ com.tiesheng.springboot-parent springboot-parent - 1.1.2 + 1.1.3 springboot-login diff --git a/springboot-message/pom.xml b/springboot-message/pom.xml index 1195c45..bcef596 100644 --- a/springboot-message/pom.xml +++ b/springboot-message/pom.xml @@ -6,7 +6,7 @@ com.tiesheng.springboot-parent springboot-parent - 1.1.2 + 1.1.3 springboot-message diff --git a/springboot-message/src/main/java/com/tiesheng/message/config/aliyun/AliyunSmsSender.java b/springboot-message/src/main/java/com/tiesheng/message/config/aliyun/AliyunSmsSender.java index b53e6b2..9e8a8c6 100644 --- a/springboot-message/src/main/java/com/tiesheng/message/config/aliyun/AliyunSmsSender.java +++ b/springboot-message/src/main/java/com/tiesheng/message/config/aliyun/AliyunSmsSender.java @@ -3,10 +3,8 @@ package com.tiesheng.message.config.aliyun; import cn.hutool.core.date.DateUtil; import cn.hutool.core.lang.Validator; import cn.hutool.core.util.IdUtil; -import cn.hutool.core.util.ReUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.crypto.SecureUtil; -import cn.hutool.extra.validation.ValidationUtil; import cn.hutool.http.HttpUtil; import cn.hutool.json.JSONObject; import cn.hutool.json.JSONUtil; @@ -18,7 +16,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.Configuration; -import javax.annotation.Resource; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; import java.text.SimpleDateFormat; @@ -103,7 +100,16 @@ public class AliyunSmsSender implements TieshengMessageSender { String signature = specialUrlEncode(digest); queryMap.put("Signature", signature); - return HttpUtil.get(ENDPOINT + "?Signature=" + signature + sortQueryStringTmp, 10 * 1000); + String respBody = ""; + try { + respBody = HttpUtil.get(ENDPOINT + "?Signature=" + signature + sortQueryStringTmp, 10 * 1000); + } catch (Exception e) { + respBody = JSONUtil.createObj() + .putOpt("Code", "Error") + .putOpt("Message", "消息通道异常") + .toString(); + } + return respBody; } diff --git a/springboot-platform/pom.xml b/springboot-platform/pom.xml index 44c17f2..ed1ab96 100644 --- a/springboot-platform/pom.xml +++ b/springboot-platform/pom.xml @@ -6,7 +6,7 @@ com.tiesheng.springboot-parent springboot-parent - 1.1.2 + 1.1.3 springboot-platform diff --git a/springboot-poi/pom.xml b/springboot-poi/pom.xml index 9a360fd..3bda4a4 100644 --- a/springboot-poi/pom.xml +++ b/springboot-poi/pom.xml @@ -6,7 +6,7 @@ com.tiesheng.springboot-parent springboot-parent - 1.1.2 + 1.1.3 springboot-poi diff --git a/springboot-util/pom.xml b/springboot-util/pom.xml index 159eb95..bf68a6c 100644 --- a/springboot-util/pom.xml +++ b/springboot-util/pom.xml @@ -6,7 +6,7 @@ com.tiesheng.springboot-parent springboot-parent - 1.1.2 + 1.1.3 springboot-util diff --git a/springboot-web/pom.xml b/springboot-web/pom.xml index 8e0675e..435a42b 100644 --- a/springboot-web/pom.xml +++ b/springboot-web/pom.xml @@ -6,7 +6,7 @@ com.tiesheng.springboot-parent springboot-parent - 1.1.2 + 1.1.3 springboot-web