mirror of
http://git.pig4cloud.com/pig/pigx.git
synced 2026-11-09 04:49:02 +08:00
🔒 Fixing security issues. 微信模块权限完善,SQL 维护、token 过期提示优化
This commit is contained in:
1 parent
d1b2fc2e2b
commit
de263a7630
9 files changed
+28
-10
No files matched your search
+2
-2
@@ -680,8 +680,8 @@ CREATE TABLE `sys_tenant` (
|
|||||||
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '租户id',
|
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '租户id',
|
||||||
`name` varchar(255) DEFAULT NULL,
|
`name` varchar(255) DEFAULT NULL,
|
||||||
`code` varchar(64) DEFAULT NULL,
|
`code` varchar(64) DEFAULT NULL,
|
||||||
`start_time` timestamp NULL DEFAULT NULL COMMENT '开始时间',
|
`start_time` datetime DEFAULT NULL COMMENT '开始时间',
|
||||||
`end_time` timestamp NULL DEFAULT NULL COMMENT '结束时间',
|
`end_time` datetime DEFAULT NULL COMMENT '结束时间',
|
||||||
`status` char(1) DEFAULT '0',
|
`status` char(1) DEFAULT '0',
|
||||||
`del_flag` char(1) DEFAULT '0',
|
`del_flag` char(1) DEFAULT '0',
|
||||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建',
|
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建',
|
||||||
|
|||||||
+3
-1
@@ -26,6 +26,7 @@ import lombok.SneakyThrows;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.security.authentication.CredentialsExpiredException;
|
import org.springframework.security.authentication.CredentialsExpiredException;
|
||||||
|
import org.springframework.security.authentication.InsufficientAuthenticationException;
|
||||||
import org.springframework.security.core.AuthenticationException;
|
import org.springframework.security.core.AuthenticationException;
|
||||||
import org.springframework.security.core.SpringSecurityMessageSource;
|
import org.springframework.security.core.SpringSecurityMessageSource;
|
||||||
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
||||||
@@ -59,7 +60,8 @@ public class ResourceAuthExceptionEntryPoint implements AuthenticationEntryPoint
|
|||||||
result.setData(authException.getMessage());
|
result.setData(authException.getMessage());
|
||||||
result.setCode(CommonConstants.FAIL);
|
result.setCode(CommonConstants.FAIL);
|
||||||
|
|
||||||
if (authException instanceof CredentialsExpiredException) {
|
if (authException instanceof CredentialsExpiredException
|
||||||
|
|| authException instanceof InsufficientAuthenticationException) {
|
||||||
String msg = SpringSecurityMessageSource.getAccessor().getMessage(
|
String msg = SpringSecurityMessageSource.getAccessor().getMessage(
|
||||||
"AbstractUserDetailsAuthenticationProvider.credentialsExpired", authException.getMessage());
|
"AbstractUserDetailsAuthenticationProvider.credentialsExpired", authException.getMessage());
|
||||||
result.setMsg(msg);
|
result.setMsg(msg);
|
||||||
|
|||||||
+6
-6
@@ -15,12 +15,12 @@ import java.util.Locale;
|
|||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* JacksonConfig
|
* JacksonConfig 扩展增加 spring boot 默认配置
|
||||||
|
* <p>
|
||||||
|
* 自身序列化机制 {@link de.codecentric.boot.admin.server.utils.jackson.AdminServerModule}
|
||||||
*
|
*
|
||||||
* @author L.cm
|
* @author lengleng
|
||||||
* @author: lengleng
|
* @date 2020-06-07
|
||||||
* @author: lishangbu
|
|
||||||
* @date: 2018/10/22
|
|
||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
@ConditionalOnClass(ObjectMapper.class)
|
@ConditionalOnClass(ObjectMapper.class)
|
||||||
@@ -31,7 +31,7 @@ public class JacksonConfig {
|
|||||||
* 覆盖core 模块提供的序列方式,增加springboot admin 序列化
|
* 覆盖core 模块提供的序列方式,增加springboot admin 序列化
|
||||||
*
|
*
|
||||||
* @param adminJacksonModule spring boot admin 提供的序列化
|
* @param adminJacksonModule spring boot admin 提供的序列化
|
||||||
* @return
|
* @return Jackson customizer
|
||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
public Jackson2ObjectMapperBuilderCustomizer customizer(SimpleModule adminJacksonModule) {
|
public Jackson2ObjectMapperBuilderCustomizer customizer(SimpleModule adminJacksonModule) {
|
||||||
|
|||||||
+1
@@ -110,6 +110,7 @@ public class WxAccountFansController {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@PostMapping("/sync/{appId}")
|
@PostMapping("/sync/{appId}")
|
||||||
|
@PreAuthorize("@pms.hasPermission('mp_wxaccountfans_sync')")
|
||||||
public R sync(@PathVariable String appId) {
|
public R sync(@PathVariable String appId) {
|
||||||
return R.ok(wxAccountFansService.syncAccountFans(appId));
|
return R.ok(wxAccountFansService.syncAccountFans(appId));
|
||||||
}
|
}
|
||||||
|
|||||||
+4
@@ -8,6 +8,7 @@ import com.pig4cloud.pigx.mp.constant.ReplyTypeEnum;
|
|||||||
import com.pig4cloud.pigx.mp.entity.WxAutoReply;
|
import com.pig4cloud.pigx.mp.entity.WxAutoReply;
|
||||||
import com.pig4cloud.pigx.mp.service.WxAutoReplyService;
|
import com.pig4cloud.pigx.mp.service.WxAutoReplyService;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -56,6 +57,7 @@ public class WxAutoReplyController {
|
|||||||
* @return R
|
* @return R
|
||||||
*/
|
*/
|
||||||
@PostMapping
|
@PostMapping
|
||||||
|
@PreAuthorize("@pms.hasPermission('mp_wxautoreply_add')")
|
||||||
public R save(@RequestBody WxAutoReply wxAutoReply) {
|
public R save(@RequestBody WxAutoReply wxAutoReply) {
|
||||||
this.jude(wxAutoReply);
|
this.jude(wxAutoReply);
|
||||||
return R.ok(wxAutoReplyService.save(wxAutoReply));
|
return R.ok(wxAutoReplyService.save(wxAutoReply));
|
||||||
@@ -68,6 +70,7 @@ public class WxAutoReplyController {
|
|||||||
* @return R
|
* @return R
|
||||||
*/
|
*/
|
||||||
@PutMapping
|
@PutMapping
|
||||||
|
@PreAuthorize("@pms.hasPermission('mp_wxautoreply_edit')")
|
||||||
public R updateById(@RequestBody WxAutoReply wxAutoReply) {
|
public R updateById(@RequestBody WxAutoReply wxAutoReply) {
|
||||||
this.jude(wxAutoReply);
|
this.jude(wxAutoReply);
|
||||||
return R.ok(wxAutoReplyService.updateById(wxAutoReply));
|
return R.ok(wxAutoReplyService.updateById(wxAutoReply));
|
||||||
@@ -80,6 +83,7 @@ public class WxAutoReplyController {
|
|||||||
* @return R
|
* @return R
|
||||||
*/
|
*/
|
||||||
@DeleteMapping("/{id}")
|
@DeleteMapping("/{id}")
|
||||||
|
@PreAuthorize("@pms.hasPermission('mp_wxautoreply_del')")
|
||||||
public R removeById(@PathVariable String id) {
|
public R removeById(@PathVariable String id) {
|
||||||
return R.ok(wxAutoReplyService.removeById(id));
|
return R.ok(wxAutoReplyService.removeById(id));
|
||||||
}
|
}
|
||||||
|
|||||||
+4
@@ -23,6 +23,7 @@ import com.pig4cloud.pigx.mp.entity.WxMsg;
|
|||||||
import com.pig4cloud.pigx.mp.service.WxMsgService;
|
import com.pig4cloud.pigx.mp.service.WxMsgService;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
|
||||||
@@ -69,6 +70,7 @@ public class WxFansMsgController {
|
|||||||
* @return R
|
* @return R
|
||||||
*/
|
*/
|
||||||
@PostMapping
|
@PostMapping
|
||||||
|
@PreAuthorize("@pms.hasPermission('mp_wxmsg_add')")
|
||||||
public R save(@RequestBody WxMsg wxMsg) {
|
public R save(@RequestBody WxMsg wxMsg) {
|
||||||
return wxMsgService.saveAndPushMsg(wxMsg);
|
return wxMsgService.saveAndPushMsg(wxMsg);
|
||||||
}
|
}
|
||||||
@@ -80,6 +82,7 @@ public class WxFansMsgController {
|
|||||||
* @return R
|
* @return R
|
||||||
*/
|
*/
|
||||||
@PutMapping
|
@PutMapping
|
||||||
|
@PreAuthorize("@pms.hasPermission('mp_wxmsg_edit')")
|
||||||
public R updateById(@RequestBody WxMsg wxMsg) {
|
public R updateById(@RequestBody WxMsg wxMsg) {
|
||||||
return R.ok(wxMsgService.updateById(wxMsg));
|
return R.ok(wxMsgService.updateById(wxMsg));
|
||||||
}
|
}
|
||||||
@@ -91,6 +94,7 @@ public class WxFansMsgController {
|
|||||||
* @return R
|
* @return R
|
||||||
*/
|
*/
|
||||||
@DeleteMapping("/{id}")
|
@DeleteMapping("/{id}")
|
||||||
|
@PreAuthorize("@pms.hasPermission('mp_wxmsg_del')")
|
||||||
public R removeById(@PathVariable String id) {
|
public R removeById(@PathVariable String id) {
|
||||||
return R.ok(wxMsgService.removeById(id));
|
return R.ok(wxMsgService.removeById(id));
|
||||||
}
|
}
|
||||||
|
|||||||
+6
@@ -17,6 +17,7 @@ import me.chanjar.weixin.mp.bean.material.*;
|
|||||||
import org.springframework.http.HttpHeaders;
|
import org.springframework.http.HttpHeaders;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
@@ -48,6 +49,7 @@ public class WxMaterialController {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@PostMapping("/materialFileUpload")
|
@PostMapping("/materialFileUpload")
|
||||||
|
@PreAuthorize("@pms.hasPermission('mp_wxmaterial_add')")
|
||||||
public R materialFileUpload(@RequestParam("file") MultipartFile mulFile,
|
public R materialFileUpload(@RequestParam("file") MultipartFile mulFile,
|
||||||
@RequestParam String appId,
|
@RequestParam String appId,
|
||||||
@RequestParam("title") String title,
|
@RequestParam("title") String title,
|
||||||
@@ -90,6 +92,7 @@ public class WxMaterialController {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@PostMapping("/materialNews")
|
@PostMapping("/materialNews")
|
||||||
|
@PreAuthorize("@pms.hasPermission('mp_wxmaterial_add')")
|
||||||
public R materialNewsUpload(@RequestBody JSONObject data) {
|
public R materialNewsUpload(@RequestBody JSONObject data) {
|
||||||
try {
|
try {
|
||||||
JSONArray jSONArray = data.getJSONArray("articles");
|
JSONArray jSONArray = data.getJSONArray("articles");
|
||||||
@@ -118,6 +121,7 @@ public class WxMaterialController {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@PutMapping("/materialNews")
|
@PutMapping("/materialNews")
|
||||||
|
@PreAuthorize("@pms.hasPermission('mp_wxmaterial_add')")
|
||||||
public R materialNewsUpdate(@RequestBody JSONObject data) {
|
public R materialNewsUpdate(@RequestBody JSONObject data) {
|
||||||
try {
|
try {
|
||||||
String mediaId = data.getStr("mediaId");
|
String mediaId = data.getStr("mediaId");
|
||||||
@@ -152,6 +156,7 @@ public class WxMaterialController {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@PostMapping("/newsImgUpload")
|
@PostMapping("/newsImgUpload")
|
||||||
|
@PreAuthorize("@pms.hasPermission('mp_wxmaterial_add')")
|
||||||
public String newsImgUpload(@RequestParam("file") MultipartFile mulFile, @RequestParam String appId) throws Exception {
|
public String newsImgUpload(@RequestParam("file") MultipartFile mulFile, @RequestParam String appId) throws Exception {
|
||||||
File file = FileUtil.createTempFile(FileUtil.getTmpDir());
|
File file = FileUtil.createTempFile(FileUtil.getTmpDir());
|
||||||
mulFile.transferTo(file);
|
mulFile.transferTo(file);
|
||||||
@@ -171,6 +176,7 @@ public class WxMaterialController {
|
|||||||
* @return R
|
* @return R
|
||||||
*/
|
*/
|
||||||
@DeleteMapping
|
@DeleteMapping
|
||||||
|
@PreAuthorize("@pms.hasPermission('mp_wxmaterial_del')")
|
||||||
public R materialDel(String appId, String id) {
|
public R materialDel(String appId, String id) {
|
||||||
WxMpService wxMpService = WxMpInitConfigRunner.getMpServices().get(appId);
|
WxMpService wxMpService = WxMpInitConfigRunner.getMpServices().get(appId);
|
||||||
WxMpMaterialService wxMpMaterialService = wxMpService.getMaterialService();
|
WxMpMaterialService wxMpMaterialService = wxMpService.getMaterialService();
|
||||||
|
|||||||
+1
@@ -77,6 +77,7 @@ public class WxMenuController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/{appId}")
|
@DeleteMapping("/{appId}")
|
||||||
|
@PreAuthorize("@pms.hasPermission('mp_wxmenu_del')")
|
||||||
public R delete(@PathVariable("appId") String appId) {
|
public R delete(@PathVariable("appId") String appId) {
|
||||||
return wxMenuService.delete(appId);
|
return wxMenuService.delete(appId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,7 +42,7 @@
|
|||||||
<maven.compiler.version>3.8.1</maven.compiler.version>
|
<maven.compiler.version>3.8.1</maven.compiler.version>
|
||||||
<git.commit.version>2.2.5</git.commit.version>
|
<git.commit.version>2.2.5</git.commit.version>
|
||||||
<spring-boot-admin.version>2.2.3</spring-boot-admin.version>
|
<spring-boot-admin.version>2.2.3</spring-boot-admin.version>
|
||||||
<hutool.version>5.3.6</hutool.version>
|
<hutool.version>5.3.7</hutool.version>
|
||||||
<kaptcha.version>1.2.0</kaptcha.version>
|
<kaptcha.version>1.2.0</kaptcha.version>
|
||||||
<swagger.fox.version>2.9.2</swagger.fox.version>
|
<swagger.fox.version>2.9.2</swagger.fox.version>
|
||||||
<knife4j.version>2.0.3</knife4j.version>
|
<knife4j.version>2.0.3</knife4j.version>
|
||||||
|
|||||||
Reference in new issue
Block a user