mirror of https://github.com/OpenVidu/openvidu.git
openvidu-server: webhook properties
parent
851d07d36e
commit
d72063b97d
|
@ -19,6 +19,6 @@ package io.openvidu.server.cdr;
|
||||||
|
|
||||||
public enum CDREventName {
|
public enum CDREventName {
|
||||||
|
|
||||||
sessionCreated, sessionDestroyed, participantJoined, participantLeft, webrtcConnectionCreated, webrtcConnectionDestroyed, recordingStarted, recordingStopped
|
sessionCreated, sessionDestroyed, participantJoined, participantLeft, webrtcConnectionCreated, webrtcConnectionDestroyed, recordingStarted, recordingStopped, recordingStatusChanged
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,9 +17,18 @@
|
||||||
|
|
||||||
package io.openvidu.server.config;
|
package io.openvidu.server.config;
|
||||||
|
|
||||||
|
import java.net.MalformedURLException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.annotation.PostConstruct;
|
||||||
|
|
||||||
|
import org.apache.http.Header;
|
||||||
|
import org.apache.http.message.BasicHeader;
|
||||||
import org.kurento.jsonrpc.JsonUtils;
|
import org.kurento.jsonrpc.JsonUtils;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.boot.info.BuildProperties;
|
import org.springframework.boot.info.BuildProperties;
|
||||||
|
@ -30,18 +39,19 @@ import com.google.gson.JsonElement;
|
||||||
import com.google.gson.JsonParser;
|
import com.google.gson.JsonParser;
|
||||||
|
|
||||||
import io.openvidu.java.client.OpenViduRole;
|
import io.openvidu.java.client.OpenViduRole;
|
||||||
|
import io.openvidu.server.cdr.CDREventName;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class OpenviduConfig {
|
public class OpenviduConfig {
|
||||||
|
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(OpenviduConfig.class);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
BuildProperties buildProperties;
|
BuildProperties buildProperties;
|
||||||
|
|
||||||
@Value("${kms.uris}")
|
@Value("${kms.uris}")
|
||||||
private String kmsUris;
|
private String kmsUris;
|
||||||
|
|
||||||
private List<String> kmsUrisList;
|
|
||||||
|
|
||||||
@Value("${openvidu.publicurl}")
|
@Value("${openvidu.publicurl}")
|
||||||
private String openviduPublicUrl; // local, docker, [FINAL_URL]
|
private String openviduPublicUrl; // local, docker, [FINAL_URL]
|
||||||
|
|
||||||
|
@ -81,6 +91,18 @@ public class OpenviduConfig {
|
||||||
@Value("${openvidu.recording.composed-url}")
|
@Value("${openvidu.recording.composed-url}")
|
||||||
private String openviduRecordingComposedUrl;
|
private String openviduRecordingComposedUrl;
|
||||||
|
|
||||||
|
@Value("${openvidu.webhook}")
|
||||||
|
private boolean openviduWebhook;
|
||||||
|
|
||||||
|
@Value("${openvidu.webhook.endpoint}")
|
||||||
|
private String openviduWebhookEndpoint;
|
||||||
|
|
||||||
|
@Value("${openvidu.webhook.headers}")
|
||||||
|
private String openviduWebhookHeaders;
|
||||||
|
|
||||||
|
@Value("${openvidu.webhook.events}")
|
||||||
|
private String openviduWebhookEvents;
|
||||||
|
|
||||||
@Value("${openvidu.streams.video.max-recv-bandwidth}")
|
@Value("${openvidu.streams.video.max-recv-bandwidth}")
|
||||||
private int openviduStreamsVideoMaxRecvBandwidth;
|
private int openviduStreamsVideoMaxRecvBandwidth;
|
||||||
|
|
||||||
|
@ -109,18 +131,48 @@ public class OpenviduConfig {
|
||||||
private String springProfile;
|
private String springProfile;
|
||||||
|
|
||||||
private String finalUrl;
|
private String finalUrl;
|
||||||
|
private List<String> kmsUrisList;
|
||||||
|
private List<Header> webhookHeadersList;
|
||||||
|
private List<CDREventName> webhookEventsList;
|
||||||
|
|
||||||
|
@PostConstruct
|
||||||
|
public void init() {
|
||||||
|
try {
|
||||||
|
this.initiateKmsUris();
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("Error in 'kms.uris' system property: " + e.getMessage());
|
||||||
|
log.error("Shutting down OpenVidu Server");
|
||||||
|
System.exit(1);
|
||||||
|
}
|
||||||
|
if (this.isWebhookEnabled()) {
|
||||||
|
log.info("OpenVidu Webhook service enabled");
|
||||||
|
try {
|
||||||
|
new URL(this.openviduWebhookEndpoint);
|
||||||
|
log.info("OpenVidu Webhook endpoint is {}", this.getOpenViduWebhookEndpoint());
|
||||||
|
} catch (MalformedURLException e) {
|
||||||
|
log.error("Error in 'openvidu.webhook.endpoint' system property. Malformed URL: " + e.getMessage());
|
||||||
|
log.error("Shutting down OpenVidu Server");
|
||||||
|
System.exit(1);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
this.initiateOpenViduWebhookHeaders();
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("Error in 'openvidu.webhook.headers' system property: " + e.getMessage());
|
||||||
|
log.error("Shutting down OpenVidu Server");
|
||||||
|
System.exit(1);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
this.initiateOpenViduWebhookEvents();
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("Error in 'openvidu.webhook.events' system property: " + e.getMessage());
|
||||||
|
log.error("Shutting down OpenVidu Server");
|
||||||
|
System.exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public List<String> getKmsUris() {
|
public List<String> getKmsUris() {
|
||||||
if (kmsUrisList == null) {
|
|
||||||
this.kmsUris = this.kmsUris.replaceAll("\\s", "");
|
|
||||||
JsonParser parser = new JsonParser();
|
|
||||||
JsonElement elem = parser.parse(this.kmsUris);
|
|
||||||
JsonArray kmsUris = elem.getAsJsonArray();
|
|
||||||
this.kmsUrisList = JsonUtils.toStringList(kmsUris);
|
|
||||||
return this.kmsUrisList;
|
return this.kmsUrisList;
|
||||||
} else {
|
|
||||||
return this.kmsUrisList;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getOpenViduPublicUrl() {
|
public String getOpenViduPublicUrl() {
|
||||||
|
@ -232,6 +284,22 @@ public class OpenviduConfig {
|
||||||
return this.openviduRecordingComposedUrl;
|
return this.openviduRecordingComposedUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isWebhookEnabled() {
|
||||||
|
return this.openviduWebhook;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOpenViduWebhookEndpoint() {
|
||||||
|
return this.openviduWebhookEndpoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Header> getOpenViduWebhookHeaders() {
|
||||||
|
return this.webhookHeadersList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<CDREventName> getOpenViduWebhookEvents() {
|
||||||
|
return this.webhookEventsList;
|
||||||
|
}
|
||||||
|
|
||||||
public OpenViduRole[] getRolesFromRecordingNotification() {
|
public OpenViduRole[] getRolesFromRecordingNotification() {
|
||||||
OpenViduRole[] roles;
|
OpenViduRole[] roles;
|
||||||
switch (this.openviduRecordingNotification) {
|
switch (this.openviduRecordingNotification) {
|
||||||
|
@ -265,4 +333,56 @@ public class OpenviduConfig {
|
||||||
return this.buildProperties.getVersion();
|
return this.buildProperties.getVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void initiateKmsUris() throws Exception {
|
||||||
|
if (kmsUrisList == null) {
|
||||||
|
this.kmsUris = this.kmsUris.replaceAll("\\s", "");
|
||||||
|
JsonParser parser = new JsonParser();
|
||||||
|
JsonElement elem = parser.parse(this.kmsUris);
|
||||||
|
JsonArray kmsUris = elem.getAsJsonArray();
|
||||||
|
this.kmsUrisList = JsonUtils.toStringList(kmsUris);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initiateOpenViduWebhookHeaders() throws Exception {
|
||||||
|
if (webhookHeadersList == null) {
|
||||||
|
JsonParser parser = new JsonParser();
|
||||||
|
JsonElement elem = parser.parse(this.openviduWebhookHeaders);
|
||||||
|
JsonArray headersJsonArray = elem.getAsJsonArray();
|
||||||
|
this.webhookHeadersList = new ArrayList<>();
|
||||||
|
|
||||||
|
for (JsonElement jsonElement : headersJsonArray) {
|
||||||
|
String headerString = jsonElement.getAsString();
|
||||||
|
String[] headerSplit = headerString.split(": ", 2);
|
||||||
|
if (headerSplit.length != 2) {
|
||||||
|
throw new Exception("HTTP header '" + headerString
|
||||||
|
+ "' syntax is not correct. Must be 'HEADER_NAME: HEADER_VALUE'. For example: 'Authorization: Basic YWxhZGRpbjpvcGVuc2VzYW1l'");
|
||||||
|
}
|
||||||
|
String headerName = headerSplit[0];
|
||||||
|
String headerValue = headerSplit[1];
|
||||||
|
this.webhookHeadersList.add(new BasicHeader(headerName, headerValue));
|
||||||
|
}
|
||||||
|
log.info("OpenVidu Webhook headers: {}", this.getOpenViduWebhookHeaders().toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initiateOpenViduWebhookEvents() throws Exception {
|
||||||
|
if (webhookEventsList == null) {
|
||||||
|
JsonParser parser = new JsonParser();
|
||||||
|
JsonElement elem = parser.parse(this.openviduWebhookEvents);
|
||||||
|
JsonArray eventsJsonArray = elem.getAsJsonArray();
|
||||||
|
this.webhookEventsList = new ArrayList<>();
|
||||||
|
|
||||||
|
for (JsonElement jsonElement : eventsJsonArray) {
|
||||||
|
String eventString = jsonElement.getAsString();
|
||||||
|
try {
|
||||||
|
CDREventName.valueOf(eventString);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
throw new Exception("Event name '" + eventString + "' does not exist");
|
||||||
|
}
|
||||||
|
this.webhookEventsList.add(CDREventName.valueOf(eventString));
|
||||||
|
}
|
||||||
|
log.info("OpenVidu Webhook events: {}", this.getOpenViduWebhookEvents().toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,10 +78,28 @@
|
||||||
"defaultValue": ""
|
"defaultValue": ""
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "coturn.sqlite",
|
"name": "openvidu.webhook",
|
||||||
|
"type": "java.lang.Boolean",
|
||||||
|
"description": "'true' to enable OpenVidu Server Webhook service. 'false' otherwise",
|
||||||
|
"defaultValue": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "openvidu.webhook.endpoint",
|
||||||
"type": "java.lang.String",
|
"type": "java.lang.String",
|
||||||
"description": "Path to COTURN sqlite database to add and remove TURN user credentials",
|
"description": "HTTP endpoint where OpenVidu Server will send Webhook HTTP POST messages",
|
||||||
"defaultValue": "/opt/openvidu/coturn/turndb"
|
"defaultValue": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "openvidu.webhook.headers",
|
||||||
|
"type": "java.lang.String",
|
||||||
|
"description": "List of headers that OpenVidu Server Webhook service will attach to HTTP POST messages",
|
||||||
|
"defaultValue": "[]"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "openvidu.webhook.events",
|
||||||
|
"type": "java.lang.String",
|
||||||
|
"description": "List of events that will be sent by OpenVidu Server Webhook service",
|
||||||
|
"defaultValue": "[\"sessionCreated\",\"sessionDestroyed\",\"participantJoined\",\"participantLeft\",\"webrtcConnectionCreated\",\"webrtcConnectionDestroyed\",\"recordingStatusChanged\"]"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "openvidu.streams.video.max-recv-bandwidth",
|
"name": "openvidu.streams.video.max-recv-bandwidth",
|
||||||
|
@ -131,6 +149,12 @@
|
||||||
"description": "Timeout in seconds when OpenVidu Server is connecting to Redis database to store TURN credentials",
|
"description": "Timeout in seconds when OpenVidu Server is connecting to Redis database to store TURN credentials",
|
||||||
"defaultValue": 30
|
"defaultValue": 30
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "coturn.sqlite",
|
||||||
|
"type": "java.lang.String",
|
||||||
|
"description": "Path to COTURN sqlite database to add and remove TURN user credentials",
|
||||||
|
"defaultValue": "/opt/openvidu/coturn/turndb"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "jsonRpcClientWebSocket.reconnectionDelay",
|
"name": "jsonRpcClientWebSocket.reconnectionDelay",
|
||||||
"type": "java.lang.Integer",
|
"type": "java.lang.Integer",
|
||||||
|
|
|
@ -1,23 +1,29 @@
|
||||||
server.address: 0.0.0.0
|
server.address: 0.0.0.0
|
||||||
server.ssl.enabled: true
|
server.ssl.enabled: true
|
||||||
openvidu.recording.version: 2.9.0
|
|
||||||
logging.level.root: info
|
|
||||||
spring.main.allow-bean-definition-overriding: true
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
server.port: 4443
|
server.port: 4443
|
||||||
server.ssl.key-store: classpath:openvidu-selfsigned.jks
|
server.ssl.key-store: classpath:openvidu-selfsigned.jks
|
||||||
server.ssl.key-store-password: openvidu
|
server.ssl.key-store-password: openvidu
|
||||||
server.ssl.key-store-type: JKS
|
server.ssl.key-store-type: JKS
|
||||||
server.ssl.key-alias: openvidu-selfsigned
|
server.ssl.key-alias: openvidu-selfsigned
|
||||||
|
|
||||||
openvidu.secret: MY_SECRET
|
logging.level.root: info
|
||||||
|
spring.main.allow-bean-definition-overriding: true
|
||||||
|
|
||||||
|
kms.uris: [\"ws://localhost:8888/kurento\"]
|
||||||
|
|
||||||
openvidu.publicurl: local
|
openvidu.publicurl: local
|
||||||
|
openvidu.secret: MY_SECRET
|
||||||
|
|
||||||
openvidu.cdr: false
|
openvidu.cdr: false
|
||||||
openvidu.cdr.path: log
|
openvidu.cdr.path: log
|
||||||
|
|
||||||
|
openvidu.webhook: true
|
||||||
|
openvidu.webhook.endpoint: https://localhost/openvidu-endpoint
|
||||||
|
openvidu.webhook.headers: [\"Authorization:\ Basic\ T1BFTlZJRFVBUFA6TVlfU0VDUkVU\"]
|
||||||
|
openvidu.webhook.events: [\"sessionCreated\",\"sessionDestroyed\",\"recordingStatusChanged\"]
|
||||||
|
|
||||||
openvidu.recording: false
|
openvidu.recording: false
|
||||||
|
openvidu.recording.version: 2.9.0
|
||||||
openvidu.recording.path: /opt/openvidu/recordings
|
openvidu.recording.path: /opt/openvidu/recordings
|
||||||
openvidu.recording.public-access: false
|
openvidu.recording.public-access: false
|
||||||
openvidu.recording.notification: publisher_moderator
|
openvidu.recording.notification: publisher_moderator
|
||||||
|
@ -30,8 +36,6 @@ openvidu.streams.video.min-recv-bandwidth: 300
|
||||||
openvidu.streams.video.max-send-bandwidth: 1000
|
openvidu.streams.video.max-send-bandwidth: 1000
|
||||||
openvidu.streams.video.min-send-bandwidth: 300
|
openvidu.streams.video.min-send-bandwidth: 300
|
||||||
|
|
||||||
kms.uris: [\"ws://localhost:8888/kurento\"]
|
|
||||||
|
|
||||||
coturn.redis.ip: 127.0.0.1
|
coturn.redis.ip: 127.0.0.1
|
||||||
coturn.redis.dbname: 0
|
coturn.redis.dbname: 0
|
||||||
coturn.redis.password: turn
|
coturn.redis.password: turn
|
||||||
|
|
Loading…
Reference in New Issue