diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java index 637f5efc..3a94f796 100644 --- a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java +++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java @@ -191,13 +191,13 @@ public class ZLMHttpHookListener { if (userSetting.getPushAuthority()) { // 推流鉴权 if (param.getParams() == null) { - logger.info("推流鉴权失败: 缺少不要参数:sign=md5(user表的pushKey)"); + logger.info("推流鉴权失败: 缺少必要参数:sign=md5(user表的pushKey)"); return new HookResultForOnPublish(401, "Unauthorized"); } Map paramMap = urlParamToMap(param.getParams()); String sign = paramMap.get("sign"); if (sign == null) { - logger.info("推流鉴权失败: 缺少不要参数:sign=md5(user表的pushKey)"); + logger.info("推流鉴权失败: 缺少必要参数:sign=md5(user表的pushKey)"); return new HookResultForOnPublish(401, "Unauthorized"); } // 推流自定义播放鉴权码 diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/UserServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/UserServiceImpl.java index aeba9edc..efbb24dc 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/UserServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/UserServiceImpl.java @@ -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 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 diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/StreamPushMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/StreamPushMapper.java index 45ed4f80..4efc058d 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/StreamPushMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/StreamPushMapper.java @@ -13,9 +13,9 @@ import java.util.List; public interface StreamPushMapper { @Insert("INSERT INTO wvp_stream_push (app, stream, total_reader_count, origin_type, origin_type_str, " + - "push_time, alive_second, media_server_id, server_id, update_time, create_time, push_ing, self) VALUES" + + "push_time, alive_second, media_server_id, update_time, create_time, push_ing, self) VALUES" + "(#{app}, #{stream}, #{totalReaderCount}, #{originType}, #{originTypeStr}, " + - "#{pushTime}, #{aliveSecond}, #{mediaServerId} , #{serverId} , #{updateTime} , #{createTime}, " + + "#{pushTime}, #{aliveSecond}, #{mediaServerId} , #{updateTime} , #{createTime}, " + "#{pushIng}, #{self} )") int add(StreamPushItem streamPushItem); diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/UserMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/UserMapper.java index 89b9d861..67cdccde 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/UserMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/UserMapper.java @@ -50,11 +50,11 @@ public interface UserMapper { @ResultMap(value="roleMap") List selectAll(); - @Select("select * from (select user.*, concat(concat(#{call_id}, '_'), push_key) as str1 from wvp_user) as u where md5(u.str1) = #{sign}") - List checkPushAuthorityByCallIdAndSign(String callId, String sign); - - @Select("select * from wvp_user where md5(push_key) = #{sign}") - List checkPushAuthorityByCallId(String sign); +// @Select("select * from (select user.*, concat(concat(#{call_id}, '_'), push_key) as str1 from wvp_user) as u where md5(u.str1) = #{sign}") +// List checkPushAuthorityByCallIdAndSign(String callId, String sign); +// +// @Select("select * from wvp_user where md5(push_key) = #{sign}") +// List checkPushAuthorityByCallId(String sign); @Select("select u.id, u.username,u.push_key,u.role_id, r.id as role_id, r.name as role_name, r.authority as role_authority , r.create_time as role_create_time , r.update_time as role_update_time from wvp_user u join wvp_user_role r on u.role_id=r.id") @ResultMap(value="roleMap")