mirror of https://github.com/OpenVidu/openvidu.git
openvidu-server: same public ID in Token and Connection for insecure participants
parent
ed82ab1241
commit
fe749d40c0
|
@ -227,11 +227,14 @@ public class SessionEventsHandler {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (participant.isRecorderOrSttParticipant()) {
|
// Return if recorder participant
|
||||||
|
if (participant.isRecorderParticipant()) {
|
||||||
this.rpcNotificationService.immediatelyCloseRpcSession(participant.getParticipantPrivateId());
|
this.rpcNotificationService.immediatelyCloseRpcSession(participant.getParticipantPrivateId());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!participant.isSttParticipant()) {
|
||||||
|
|
||||||
JsonObject params = new JsonObject();
|
JsonObject params = new JsonObject();
|
||||||
params.addProperty(ProtocolElements.PARTICIPANTLEFT_NAME_PARAM, participant.getParticipantPublicId());
|
params.addProperty(ProtocolElements.PARTICIPANTLEFT_NAME_PARAM, participant.getParticipantPublicId());
|
||||||
params.addProperty(ProtocolElements.PARTICIPANTLEFT_REASON_PARAM, reason != null ? reason.name() : "");
|
params.addProperty(ProtocolElements.PARTICIPANTLEFT_REASON_PARAM, reason != null ? reason.name() : "");
|
||||||
|
@ -241,6 +244,10 @@ public class SessionEventsHandler {
|
||||||
ProtocolElements.PARTICIPANTLEFT_METHOD, params);
|
ProtocolElements.PARTICIPANTLEFT_METHOD, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CDR.recordParticipantLeft(participant, sessionId, reason);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
if (transactionId != null) {
|
if (transactionId != null) {
|
||||||
// No response when the participant is forcibly evicted instead of voluntarily
|
// No response when the participant is forcibly evicted instead of voluntarily
|
||||||
// leaving the session
|
// leaving the session
|
||||||
|
@ -254,7 +261,6 @@ public class SessionEventsHandler {
|
||||||
this.rpcNotificationService.scheduleCloseRpcSession(participant.getParticipantPrivateId(), 10000);
|
this.rpcNotificationService.scheduleCloseRpcSession(participant.getParticipantPrivateId(), 10000);
|
||||||
}
|
}
|
||||||
|
|
||||||
CDR.recordParticipantLeft(participant, sessionId, reason);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onPublishMedia(Participant participant, String streamId, Long createdAt, String sessionId,
|
public void onPublishMedia(Participant participant, String streamId, Long createdAt, String sessionId,
|
||||||
|
|
|
@ -364,10 +364,13 @@ public abstract class SessionManager {
|
||||||
return tokenObj;
|
return tokenObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Token newTokenForInsecureUser(Session session, String token, ConnectionProperties connectionProperties)
|
public Token newTokenForInsecureUser(Session session, String token, ConnectionProperties connectionProperties,
|
||||||
throws Exception {
|
String connectionId) throws Exception {
|
||||||
Token tokenObj = new Token(token, session.getSessionId(), connectionProperties,
|
Token tokenObj = new Token(token, session.getSessionId(), connectionProperties,
|
||||||
this.coturnCredentialsService.createUser());
|
this.coturnCredentialsService.createUser());
|
||||||
|
if (connectionId != null) {
|
||||||
|
tokenObj.setConnectionId(connectionId);
|
||||||
|
}
|
||||||
session.storeToken(tokenObj);
|
session.storeToken(tokenObj);
|
||||||
return tokenObj;
|
return tokenObj;
|
||||||
}
|
}
|
||||||
|
@ -444,7 +447,8 @@ public abstract class SessionManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Participant newSttParticipant(Session session, String participantPrivateId, Token token, String clientMetadata) {
|
public Participant newSttParticipant(Session session, String participantPrivateId, Token token,
|
||||||
|
String clientMetadata) {
|
||||||
String sessionId = session.getSessionId();
|
String sessionId = session.getSessionId();
|
||||||
if (this.sessionidParticipantpublicidParticipant.get(sessionId) != null) {
|
if (this.sessionidParticipantpublicidParticipant.get(sessionId) != null) {
|
||||||
return newParticipantAux(sessionId, session.getUniqueSessionId(), null, participantPrivateId,
|
return newParticipantAux(sessionId, session.getUniqueSessionId(), null, participantPrivateId,
|
||||||
|
|
|
@ -1161,7 +1161,7 @@ public class KurentoSessionManager extends SessionManager {
|
||||||
String token = IdentifierPrefixes.TOKEN_ID + RandomStringUtils.randomAlphabetic(1).toUpperCase()
|
String token = IdentifierPrefixes.TOKEN_ID + RandomStringUtils.randomAlphabetic(1).toUpperCase()
|
||||||
+ RandomStringUtils.randomAlphanumeric(15);
|
+ RandomStringUtils.randomAlphanumeric(15);
|
||||||
|
|
||||||
this.newTokenForInsecureUser(session, token, connectionProperties);
|
this.newTokenForInsecureUser(session, token, connectionProperties, null);
|
||||||
final Token tokenObj = session.consumeToken(token);
|
final Token tokenObj = session.consumeToken(token);
|
||||||
|
|
||||||
Participant ipcamParticipant = this.newIpcamParticipant(session, rtspConnectionId, tokenObj, location,
|
Participant ipcamParticipant = this.newIpcamParticipant(session, rtspConnectionId, tokenObj, location,
|
||||||
|
|
|
@ -277,12 +277,6 @@ public class RpcHandler extends DefaultJsonRpcHandler<JsonObject> {
|
||||||
|
|
||||||
if (openviduConfig.isOpenViduSecret(secret)) {
|
if (openviduConfig.isOpenViduSecret(secret)) {
|
||||||
|
|
||||||
if (recorder) {
|
|
||||||
generateRecorderParticipant = true;
|
|
||||||
} else if (stt) {
|
|
||||||
generateSttParticipant = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
sessionManager.newInsecureParticipant(participantPrivateId);
|
sessionManager.newInsecureParticipant(participantPrivateId);
|
||||||
|
|
||||||
token = IdentifierPrefixes.TOKEN_ID + RandomStringUtils.randomAlphabetic(1).toUpperCase()
|
token = IdentifierPrefixes.TOKEN_ID + RandomStringUtils.randomAlphabetic(1).toUpperCase()
|
||||||
|
@ -290,8 +284,17 @@ public class RpcHandler extends DefaultJsonRpcHandler<JsonObject> {
|
||||||
ConnectionProperties connectionProperties = new ConnectionProperties.Builder().type(ConnectionType.WEBRTC)
|
ConnectionProperties connectionProperties = new ConnectionProperties.Builder().type(ConnectionType.WEBRTC)
|
||||||
.role(OpenViduRole.SUBSCRIBER).build();
|
.role(OpenViduRole.SUBSCRIBER).build();
|
||||||
|
|
||||||
|
String connectionId = null;
|
||||||
|
if (recorder) {
|
||||||
|
generateRecorderParticipant = true;
|
||||||
|
connectionId = ProtocolElements.RECORDER_PARTICIPANT_PUBLICID;
|
||||||
|
} else if (stt) {
|
||||||
|
generateSttParticipant = true;
|
||||||
|
connectionId = ProtocolElements.STT_PARTICIPANT_PUBLICID;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
sessionManager.newTokenForInsecureUser(session, token, connectionProperties);
|
sessionManager.newTokenForInsecureUser(session, token, connectionProperties, connectionId);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new OpenViduException(Code.TOKEN_CANNOT_BE_CREATED_ERROR_CODE,
|
throw new OpenViduException(Code.TOKEN_CANNOT_BE_CREATED_ERROR_CODE,
|
||||||
"Unable to create token for session " + sessionId + ": " + e.getMessage());
|
"Unable to create token for session " + sessionId + ": " + e.getMessage());
|
||||||
|
@ -890,9 +893,10 @@ public class RpcHandler extends DefaultJsonRpcHandler<JsonObject> {
|
||||||
// Sanity check: don't call RPC method unless the id checks out
|
// Sanity check: don't call RPC method unless the id checks out
|
||||||
Participant participant = sessionManager.getParticipant(sessionId, participantPrivateId);
|
Participant participant = sessionManager.getParticipant(sessionId, participantPrivateId);
|
||||||
if (participant != null) {
|
if (participant != null) {
|
||||||
errorMsg = "Participant " + participant.getParticipantPublicId() + " is calling method '" + methodName
|
if (methodName != "videoData") {
|
||||||
+ "' in session " + sessionId;
|
log.info("Participant {} is calling method '{}' in session {}",
|
||||||
log.info(errorMsg);
|
participant.getParticipantPublicId(), methodName, sessionId);
|
||||||
|
}
|
||||||
return participant;
|
return participant;
|
||||||
} else {
|
} else {
|
||||||
errorMsg = "Participant with private id " + participantPrivateId + " not found in session " + sessionId
|
errorMsg = "Participant with private id " + participantPrivateId + " not found in session " + sessionId
|
||||||
|
|
Loading…
Reference in New Issue