修复推流鉴权

This commit is contained in:
648540858
2023-05-23 10:34:00 +08:00
parent 061749548c
commit 807d0524a6
4 changed files with 26 additions and 15 deletions

View File

@@ -7,8 +7,7 @@ import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import org.springframework.util.DigestUtils;
import java.util.List;
@@ -61,11 +60,23 @@ public class UserServiceImpl implements IUserService {
@Override
public boolean checkPushAuthority(String callId, String sign) {
if (ObjectUtils.isEmpty(callId)) {
return userMapper.checkPushAuthorityByCallId(sign).size() > 0;
}else {
return userMapper.checkPushAuthorityByCallIdAndSign(callId, sign).size() > 0;
List<User> users = userMapper.getUsers();
if (users.size() == 0) {
return false;
}
for (User user : users) {
if (user.getPushKey() == null) {
continue;
}
String checkStr = callId == null? user.getPushKey():(callId + "_" + user.getPushKey()) ;
System.out.println(checkStr);
String checkSign = DigestUtils.md5DigestAsHex(checkStr.getBytes());
if (checkSign.equals(sign)) {
return true;
}
}
return false;
}
@Override