支持配置是否开去推流鉴权
parent
73c7dab47f
commit
cc4c4ac144
|
@ -35,6 +35,8 @@ public class UserSetting {
|
||||||
|
|
||||||
private Boolean streamOnDemand = Boolean.TRUE;
|
private Boolean streamOnDemand = Boolean.TRUE;
|
||||||
|
|
||||||
|
private Boolean pushAuthority = Boolean.TRUE;
|
||||||
|
|
||||||
private String serverId = "000000";
|
private String serverId = "000000";
|
||||||
|
|
||||||
private String thirdPartyGBIdReg = "[\\s\\S]*";
|
private String thirdPartyGBIdReg = "[\\s\\S]*";
|
||||||
|
@ -156,4 +158,12 @@ public class UserSetting {
|
||||||
public void setStreamOnDemand(Boolean streamOnDemand) {
|
public void setStreamOnDemand(Boolean streamOnDemand) {
|
||||||
this.streamOnDemand = streamOnDemand;
|
this.streamOnDemand = streamOnDemand;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Boolean getPushAuthority() {
|
||||||
|
return pushAuthority;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPushAuthority(Boolean pushAuthority) {
|
||||||
|
this.pushAuthority = pushAuthority;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -183,42 +183,45 @@ public class ZLMHttpHookListener {
|
||||||
JSONObject ret = new JSONObject();
|
JSONObject ret = new JSONObject();
|
||||||
String mediaServerId = json.getString("mediaServerId");
|
String mediaServerId = json.getString("mediaServerId");
|
||||||
MediaServerItem mediaInfo = mediaServerService.getOne(mediaServerId);
|
MediaServerItem mediaInfo = mediaServerService.getOne(mediaServerId);
|
||||||
|
|
||||||
if (!"rtp".equals(param.getApp())) {
|
if (!"rtp".equals(param.getApp())) {
|
||||||
// 推流鉴权
|
if (userSetting.getPushAuthority()) {
|
||||||
if (param.getParams() == null) {
|
// 推流鉴权
|
||||||
logger.info("推流鉴权失败: 缺少不要参数:sign=md5(user表的pushKey)");
|
if (param.getParams() == null) {
|
||||||
ret.put("code", 401);
|
logger.info("推流鉴权失败: 缺少不要参数:sign=md5(user表的pushKey)");
|
||||||
ret.put("msg", "Unauthorized");
|
ret.put("code", 401);
|
||||||
return ret;
|
ret.put("msg", "Unauthorized");
|
||||||
}
|
return ret;
|
||||||
Map<String, String> paramMap = urlParamToMap(param.getParams());
|
}
|
||||||
String sign = paramMap.get("sign");
|
Map<String, String> paramMap = urlParamToMap(param.getParams());
|
||||||
if (sign == null) {
|
String sign = paramMap.get("sign");
|
||||||
logger.info("推流鉴权失败: 缺少不要参数:sign=md5(user表的pushKey)");
|
if (sign == null) {
|
||||||
ret.put("code", 401);
|
logger.info("推流鉴权失败: 缺少不要参数:sign=md5(user表的pushKey)");
|
||||||
ret.put("msg", "Unauthorized");
|
ret.put("code", 401);
|
||||||
return ret;
|
ret.put("msg", "Unauthorized");
|
||||||
}
|
return ret;
|
||||||
// 推流自定义播放鉴权码
|
}
|
||||||
String callId = paramMap.get("callId");
|
// 推流自定义播放鉴权码
|
||||||
// 鉴权配置
|
String callId = paramMap.get("callId");
|
||||||
boolean hasAuthority = userService.checkPushAuthority(callId, sign);
|
// 鉴权配置
|
||||||
if (!hasAuthority) {
|
boolean hasAuthority = userService.checkPushAuthority(callId, sign);
|
||||||
logger.info("推流鉴权失败: sign 无权限: callId={}. sign={}", callId, sign);
|
if (!hasAuthority) {
|
||||||
ret.put("code", 401);
|
logger.info("推流鉴权失败: sign 无权限: callId={}. sign={}", callId, sign);
|
||||||
ret.put("msg", "Unauthorized");
|
ret.put("code", 401);
|
||||||
return ret;
|
ret.put("msg", "Unauthorized");
|
||||||
}
|
return ret;
|
||||||
StreamAuthorityInfo streamAuthorityInfo = StreamAuthorityInfo.getInstanceByHook(param);
|
}
|
||||||
streamAuthorityInfo.setCallId(callId);
|
StreamAuthorityInfo streamAuthorityInfo = StreamAuthorityInfo.getInstanceByHook(param);
|
||||||
streamAuthorityInfo.setSign(sign);
|
streamAuthorityInfo.setCallId(callId);
|
||||||
// 鉴权通过
|
streamAuthorityInfo.setSign(sign);
|
||||||
redisCatchStorage.updateStreamAuthorityInfo(param.getApp(), param.getStream(), streamAuthorityInfo);
|
// 鉴权通过
|
||||||
// 通知assist新的callId
|
redisCatchStorage.updateStreamAuthorityInfo(param.getApp(), param.getStream(), streamAuthorityInfo);
|
||||||
if (mediaInfo != null && mediaInfo.getRecordAssistPort() > 0) {
|
// 通知assist新的callId
|
||||||
taskExecutor.execute(()->{
|
if (mediaInfo != null && mediaInfo.getRecordAssistPort() > 0) {
|
||||||
assistRESTfulUtils.addStreamCallInfo(mediaInfo, param.getApp(), param.getStream(), callId, null);
|
taskExecutor.execute(()->{
|
||||||
});
|
assistRESTfulUtils.addStreamCallInfo(mediaInfo, param.getApp(), param.getStream(), callId, null);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
zlmMediaListManager.sendStreamEvent(param.getApp(),param.getStream(), param.getMediaServerId());
|
zlmMediaListManager.sendStreamEvent(param.getApp(),param.getStream(), param.getMediaServerId());
|
||||||
|
@ -226,7 +229,6 @@ public class ZLMHttpHookListener {
|
||||||
|
|
||||||
ret.put("code", 0);
|
ret.put("code", 0);
|
||||||
ret.put("msg", "success");
|
ret.put("msg", "success");
|
||||||
ret.put("enable_hls", false);
|
|
||||||
|
|
||||||
if (!"rtp".equals(param.getApp())) {
|
if (!"rtp".equals(param.getApp())) {
|
||||||
ret.put("enable_audio", true);
|
ret.put("enable_audio", true);
|
||||||
|
|
|
@ -190,6 +190,8 @@ user-settings:
|
||||||
use-pushing-as-status: true
|
use-pushing-as-status: true
|
||||||
# 按需拉流, true:有人观看拉流,无人观看释放, false:拉起后不自动释放
|
# 按需拉流, true:有人观看拉流,无人观看释放, false:拉起后不自动释放
|
||||||
stream-on-demand: true
|
stream-on-demand: true
|
||||||
|
# 推流鉴权, 默认开启
|
||||||
|
push-authority: true
|
||||||
|
|
||||||
# 关闭在线文档(生产环境建议关闭)
|
# 关闭在线文档(生产环境建议关闭)
|
||||||
springdoc:
|
springdoc:
|
||||||
|
|
Loading…
Reference in New Issue