--author:scott--date:20261013--for:【安全 GHSA-g9pv-58jx-2grf/GHSA-85m5-jf95-q532/GHSA-rhrv-jv29-rmmq】AI语音/视频记录查询与删除接口移除userId入参,强制使用当前登录用户,防止越权读取删除他人记录

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
zhangdaiscott 2026-10-13 05:06:58 -04:00
parent 28d47a0109
commit 7187cf3e8d
2 changed files with 12 additions and 4 deletions

View File

@ -2,7 +2,9 @@ package org.jeecg.modules.airag.video.controller;
import com.alibaba.fastjson2.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.modules.airag.video.service.IVideoGenerationService;
import org.jeecg.modules.airag.video.vo.VideoGenerateVo;
import org.jeecg.modules.airag.video.vo.VideoTaskResultVo;
@ -75,7 +77,8 @@ public class VideoGenerationController {
* 查询当前用户的视频生成记录
*/
@GetMapping("/listByUser")
public Result<List<JSONObject>> getVideoRecords(@RequestParam String userId) {
public Result<List<JSONObject>> getVideoRecords() {
String userId = ((LoginUser) SecurityUtils.getSubject().getPrincipal()).getId();
List<JSONObject> records = videoGenerationService.getVideoRecords(userId);
return Result.OK(records);
}
@ -84,7 +87,8 @@ public class VideoGenerationController {
* 删除视频生成记录
*/
@DeleteMapping("/deleteVideoRecord")
public Result<String> deleteVideoRecord(@RequestParam String userId, @RequestParam String recordId) {
public Result<String> deleteVideoRecord(@RequestParam String recordId) {
String userId = ((LoginUser) SecurityUtils.getSubject().getPrincipal()).getId();
boolean deleted = videoGenerationService.deleteVideoRecord(userId, recordId);
return deleted ? Result.OK("删除成功") : Result.error("记录不存在");
}

View File

@ -1,7 +1,9 @@
package org.jeecg.modules.airag.voice.controller;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.modules.airag.voice.service.IVoiceService;
import org.jeecg.modules.airag.voice.vo.VoiceGenerateVo;
import org.jeecg.modules.airag.voice.vo.VoiceResultVo;
@ -75,7 +77,8 @@ public class VoiceController {
* 查询当前用户的语音生成记录
*/
@GetMapping("/listByUser")
public Result<List<JSONObject>> getVoiceRecords(@RequestParam String userId) {
public Result<List<JSONObject>> getVoiceRecords() {
String userId = ((LoginUser) SecurityUtils.getSubject().getPrincipal()).getId();
List<JSONObject> records = voiceService.getVoiceRecords(userId);
return Result.OK(records);
}
@ -84,7 +87,8 @@ public class VoiceController {
* 删除语音生成记录
*/
@DeleteMapping("/deleteVoiceRecord")
public Result<String> deleteVoiceRecord(@RequestParam String userId, @RequestParam String recordId) {
public Result<String> deleteVoiceRecord(@RequestParam String recordId) {
String userId = ((LoginUser) SecurityUtils.getSubject().getPrincipal()).getId();
boolean deleted = voiceService.deleteVoiceRecord(userId, recordId);
return deleted ? Result.OK("删除成功") : Result.error("记录不存在");
}