mirror of https://github.com/OpenVidu/openvidu.git
openvidu-server support 'local', 'ngtok' and custom URL mode
parent
c5bb9e9002
commit
83edc43299
|
@ -12,8 +12,7 @@ public class InfoSocketConfig implements WebSocketConfigurer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
|
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
|
||||||
registry.addHandler(infoHandler(), "/info");
|
registry.addHandler(infoHandler(), "/info").setAllowedOrigins("*");
|
||||||
//.setAllowedOrigins("*");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
|
|
@ -46,6 +46,7 @@ import io.openvidu.server.kms.FixedOneKmsManager;
|
||||||
import io.openvidu.server.rest.NgrokController;
|
import io.openvidu.server.rest.NgrokController;
|
||||||
import io.openvidu.server.rpc.JsonRpcNotificationService;
|
import io.openvidu.server.rpc.JsonRpcNotificationService;
|
||||||
import io.openvidu.server.rpc.JsonRpcUserControl;
|
import io.openvidu.server.rpc.JsonRpcUserControl;
|
||||||
|
import io.openvidu.server.security.OpenviduConfiguration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Room server application.
|
* Room server application.
|
||||||
|
@ -55,113 +56,126 @@ import io.openvidu.server.rpc.JsonRpcUserControl;
|
||||||
* @author Radu Tom Vlad (rvlad@naevatec.com)
|
* @author Radu Tom Vlad (rvlad@naevatec.com)
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
@Import({JsonRpcConfiguration.class, InfoSocketConfig.class})
|
@Import({ JsonRpcConfiguration.class, InfoSocketConfig.class })
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
public class OpenViduServer implements JsonRpcConfigurer {
|
public class OpenViduServer implements JsonRpcConfigurer {
|
||||||
|
|
||||||
public static final String KMSS_URIS_PROPERTY = "kms.uris";
|
public static final String KMSS_URIS_PROPERTY = "kms.uris";
|
||||||
public static final String KMSS_URIS_DEFAULT = "[ \"ws://localhost:8888/kurento\" ]";
|
public static final String KMSS_URIS_DEFAULT = "[ \"ws://localhost:8888/kurento\" ]";
|
||||||
|
|
||||||
@Value("${kms.uris}")
|
@Value("${kms.uris}")
|
||||||
private String KMSS_CUSTOM_URIS;
|
private String KMSS_CUSTOM_URIS;
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(OpenViduServer.class);
|
public static String publicUrl;
|
||||||
|
|
||||||
@Bean
|
private static final Logger log = LoggerFactory.getLogger(OpenViduServer.class);
|
||||||
@ConditionalOnMissingBean
|
|
||||||
public KurentoClientProvider kmsManager() {
|
|
||||||
|
|
||||||
JsonArray kmsUris = getPropertyJson(KMSS_URIS_PROPERTY, KMSS_URIS_DEFAULT, JsonArray.class);
|
@Bean
|
||||||
List<String> kmsWsUris = JsonUtils.toStringList(kmsUris);
|
@ConditionalOnMissingBean
|
||||||
|
public KurentoClientProvider kmsManager() {
|
||||||
|
|
||||||
if ((KMSS_CUSTOM_URIS != null) && (!KMSS_CUSTOM_URIS.isEmpty())) {
|
JsonArray kmsUris = getPropertyJson(KMSS_URIS_PROPERTY, KMSS_URIS_DEFAULT, JsonArray.class);
|
||||||
List<String> uris = new Gson().fromJson( KMSS_CUSTOM_URIS, List.class );
|
List<String> kmsWsUris = JsonUtils.toStringList(kmsUris);
|
||||||
kmsWsUris.addAll(0, uris);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (kmsWsUris.isEmpty()) {
|
if ((KMSS_CUSTOM_URIS != null) && (!KMSS_CUSTOM_URIS.isEmpty())) {
|
||||||
throw new IllegalArgumentException(KMSS_URIS_PROPERTY
|
List<String> uris = new Gson().fromJson(KMSS_CUSTOM_URIS, List.class);
|
||||||
+ " should contain at least one kms url");
|
kmsWsUris.addAll(0, uris);
|
||||||
}
|
}
|
||||||
|
|
||||||
String firstKmsWsUri = kmsWsUris.get(0);
|
if (kmsWsUris.isEmpty()) {
|
||||||
|
throw new IllegalArgumentException(KMSS_URIS_PROPERTY + " should contain at least one kms url");
|
||||||
|
}
|
||||||
|
|
||||||
if (firstKmsWsUri.equals("autodiscovery")) {
|
String firstKmsWsUri = kmsWsUris.get(0);
|
||||||
log.info("Using autodiscovery rules to locate KMS on every pipeline");
|
|
||||||
return new AutodiscoveryKurentoClientProvider();
|
|
||||||
} else {
|
|
||||||
log.info("Configuring Kurento Room Server to use first of the following kmss: " + kmsWsUris);
|
|
||||||
return new FixedOneKmsManager(firstKmsWsUri);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
if (firstKmsWsUri.equals("autodiscovery")) {
|
||||||
@ConditionalOnMissingBean
|
log.info("Using autodiscovery rules to locate KMS on every pipeline");
|
||||||
public JsonRpcNotificationService notificationService() {
|
return new AutodiscoveryKurentoClientProvider();
|
||||||
return new JsonRpcNotificationService();
|
} else {
|
||||||
}
|
log.info("Configuring Kurento Room Server to use first of the following kmss: " + kmsWsUris);
|
||||||
|
return new FixedOneKmsManager(firstKmsWsUri);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnMissingBean
|
@ConditionalOnMissingBean
|
||||||
public NotificationRoomHandler defaultNotificationRoomHandler() {
|
public JsonRpcNotificationService notificationService() {
|
||||||
return new DefaultNotificationRoomHandler(notificationService());
|
return new JsonRpcNotificationService();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnMissingBean
|
@ConditionalOnMissingBean
|
||||||
public RoomManager roomManager() {
|
public NotificationRoomHandler defaultNotificationRoomHandler() {
|
||||||
return new RoomManager();
|
return new DefaultNotificationRoomHandler(notificationService());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnMissingBean
|
@ConditionalOnMissingBean
|
||||||
public NotificationRoomManager notificationRoomManager() {
|
public RoomManager roomManager() {
|
||||||
return new NotificationRoomManager();
|
return new RoomManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnMissingBean
|
@ConditionalOnMissingBean
|
||||||
public JsonRpcUserControl userControl() {
|
public NotificationRoomManager notificationRoomManager() {
|
||||||
return new JsonRpcUserControl();
|
return new NotificationRoomManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnMissingBean
|
@ConditionalOnMissingBean
|
||||||
public RoomJsonRpcHandler roomHandler() {
|
public JsonRpcUserControl userControl() {
|
||||||
return new RoomJsonRpcHandler();
|
return new JsonRpcUserControl();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Bean
|
||||||
public void registerJsonRpcHandlers(JsonRpcHandlerRegistry registry) {
|
@ConditionalOnMissingBean
|
||||||
registry.addHandler(roomHandler().withPingWatchdog(true), "/room");
|
public RoomJsonRpcHandler roomHandler() {
|
||||||
}
|
return new RoomJsonRpcHandler();
|
||||||
|
}
|
||||||
|
|
||||||
@Bean
|
@Override
|
||||||
public ServletServerContainerFactoryBean createWebSocketContainer() {
|
public void registerJsonRpcHandlers(JsonRpcHandlerRegistry registry) {
|
||||||
ServletServerContainerFactoryBean container = new ServletServerContainerFactoryBean();
|
registry.addHandler(roomHandler().withPingWatchdog(true), "/room");
|
||||||
container.setMaxTextMessageBufferSize(1000000); // chars
|
}
|
||||||
container.setMaxBinaryMessageBufferSize(1000000); // bytes
|
|
||||||
return container;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
@Bean
|
||||||
start(args);
|
public ServletServerContainerFactoryBean createWebSocketContainer() {
|
||||||
try {
|
ServletServerContainerFactoryBean container = new ServletServerContainerFactoryBean();
|
||||||
NgrokController ngrok = new NgrokController();
|
container.setMaxTextMessageBufferSize(1000000); // chars
|
||||||
System.out.println();
|
container.setMaxBinaryMessageBufferSize(1000000); // bytes
|
||||||
System.out.println(" PUBLIC IP ");
|
return container;
|
||||||
System.out.println("-------------------------");
|
}
|
||||||
System.out.println(ngrok.getNgrokPublicUrl());
|
|
||||||
System.out.println("-------------------------");
|
|
||||||
System.out.println();
|
|
||||||
} catch(Exception e) {
|
|
||||||
System.out.println(" No ngrok connection ");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ConfigurableApplicationContext start(String[] args) {
|
public static void main(String[] args) throws Exception {
|
||||||
log.info("Using /dev/urandom for secure random generation");
|
ConfigurableApplicationContext context = start(args);
|
||||||
System.setProperty("java.security.egd", "file:/dev/./urandom");
|
OpenviduConfiguration openviduConf = context.getBean(OpenviduConfiguration.class);
|
||||||
return SpringApplication.run(OpenViduServer.class, args);
|
OpenViduServer.publicUrl = "wss://localhost:" + openviduConf.getServerPort();
|
||||||
}
|
|
||||||
|
if (openviduConf.getOpenViduPublicUrl().equals("ngrok")) {
|
||||||
|
try {
|
||||||
|
NgrokController ngrok = new NgrokController();
|
||||||
|
System.out.println();
|
||||||
|
System.out.println(" PUBLIC IP ");
|
||||||
|
System.out.println("-------------------------");
|
||||||
|
System.out.println(ngrok.getNgrokAppUrl());
|
||||||
|
System.out.println("-------------------------");
|
||||||
|
System.out.println();
|
||||||
|
OpenViduServer.publicUrl = ngrok.getNgrokServerUrl().replaceFirst("https://", "wss://");
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.out.println(" No ngrok connection ");
|
||||||
|
}
|
||||||
|
} else if (!openviduConf.getOpenViduPublicUrl().equals("local")) {
|
||||||
|
System.out.println("CUSTOM URL");
|
||||||
|
OpenViduServer.publicUrl = openviduConf.getOpenViduPublicUrl().replaceFirst("https://", "wss://");
|
||||||
|
if (!OpenViduServer.publicUrl.startsWith("wss://")) {
|
||||||
|
OpenViduServer.publicUrl = "wss://" + OpenViduServer.publicUrl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ConfigurableApplicationContext start(String[] args) {
|
||||||
|
log.info("Using /dev/urandom for secure random generation");
|
||||||
|
System.setProperty("java.security.egd", "file:/dev/./urandom");
|
||||||
|
return SpringApplication.run(OpenViduServer.class, args);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,11 +37,10 @@ import org.kurento.client.WebRtcEndpoint;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
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 io.openvidu.client.OpenViduException;
|
import io.openvidu.client.OpenViduException;
|
||||||
import io.openvidu.client.OpenViduException.Code;
|
import io.openvidu.client.OpenViduException.Code;
|
||||||
import io.openvidu.server.InfoHandler;
|
import io.openvidu.server.OpenViduServer;
|
||||||
import io.openvidu.server.core.api.KurentoClientProvider;
|
import io.openvidu.server.core.api.KurentoClientProvider;
|
||||||
import io.openvidu.server.core.api.KurentoClientSessionInfo;
|
import io.openvidu.server.core.api.KurentoClientSessionInfo;
|
||||||
import io.openvidu.server.core.api.MutedMediaType;
|
import io.openvidu.server.core.api.MutedMediaType;
|
||||||
|
@ -50,6 +49,7 @@ import io.openvidu.server.core.api.pojo.UserParticipant;
|
||||||
import io.openvidu.server.core.endpoint.SdpType;
|
import io.openvidu.server.core.endpoint.SdpType;
|
||||||
import io.openvidu.server.core.internal.Participant;
|
import io.openvidu.server.core.internal.Participant;
|
||||||
import io.openvidu.server.core.internal.Room;
|
import io.openvidu.server.core.internal.Room;
|
||||||
|
import io.openvidu.server.security.OpenviduConfiguration;
|
||||||
import io.openvidu.server.security.ParticipantRole;
|
import io.openvidu.server.security.ParticipantRole;
|
||||||
import io.openvidu.server.security.Token;
|
import io.openvidu.server.security.Token;
|
||||||
|
|
||||||
|
@ -83,13 +83,13 @@ public class RoomManager {
|
||||||
@Autowired
|
@Autowired
|
||||||
private KurentoClientProvider kcProvider;
|
private KurentoClientProvider kcProvider;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private OpenviduConfiguration openviduConf;
|
||||||
|
|
||||||
private final ConcurrentMap<String, Room> rooms = new ConcurrentHashMap<String, Room>();
|
private final ConcurrentMap<String, Room> rooms = new ConcurrentHashMap<String, Room>();
|
||||||
private final ConcurrentMap<String, ConcurrentHashMap<String, Token>> sessionidTokenTokenobj = new ConcurrentHashMap<>();
|
private final ConcurrentMap<String, ConcurrentHashMap<String, Token>> sessionidTokenTokenobj = new ConcurrentHashMap<>();
|
||||||
private final ConcurrentMap<String, ConcurrentHashMap<String, String>> sessionidUsernameToken = new ConcurrentHashMap<>();
|
private final ConcurrentMap<String, ConcurrentHashMap<String, String>> sessionidUsernameToken = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
@Value("${openvidu.security}")
|
|
||||||
private boolean SECURITY_ENABLED;
|
|
||||||
|
|
||||||
private volatile boolean closed = false;
|
private volatile boolean closed = false;
|
||||||
|
|
||||||
public RoomManager() {
|
public RoomManager() {
|
||||||
|
@ -963,7 +963,7 @@ public class RoomManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isParticipantInRoom(String token, String roomId) throws OpenViduException {
|
public boolean isParticipantInRoom(String token, String roomId) throws OpenViduException {
|
||||||
if (SECURITY_ENABLED) {
|
if (openviduConf.getOpenViduSecurity()) {
|
||||||
if (this.sessionidTokenTokenobj.get(roomId) != null) {
|
if (this.sessionidTokenTokenobj.get(roomId) != null) {
|
||||||
return this.sessionidTokenTokenobj.get(roomId).containsKey(token);
|
return this.sessionidTokenTokenobj.get(roomId).containsKey(token);
|
||||||
} else{
|
} else{
|
||||||
|
@ -979,7 +979,7 @@ public class RoomManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPublisherInRoom(String userName, String roomId) {
|
public boolean isPublisherInRoom(String userName, String roomId) {
|
||||||
if (SECURITY_ENABLED) {
|
if (openviduConf.getOpenViduSecurity()) {
|
||||||
if (this.sessionidUsernameToken.get(roomId) != null){
|
if (this.sessionidUsernameToken.get(roomId) != null){
|
||||||
String token = this.sessionidUsernameToken.get(roomId).get(userName);
|
String token = this.sessionidUsernameToken.get(roomId).get(userName);
|
||||||
if (token != null){
|
if (token != null){
|
||||||
|
@ -1035,7 +1035,8 @@ public class RoomManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String newSessionId(){
|
public String newSessionId(){
|
||||||
String sessionId = new BigInteger(130, new SecureRandom()).toString(32);
|
String sessionId = OpenViduServer.publicUrl;
|
||||||
|
sessionId += "/" + new BigInteger(130, new SecureRandom()).toString(32);
|
||||||
|
|
||||||
this.sessionidTokenTokenobj.put(sessionId, new ConcurrentHashMap<>());
|
this.sessionidTokenTokenobj.put(sessionId, new ConcurrentHashMap<>());
|
||||||
this.sessionidUsernameToken.put(sessionId, new ConcurrentHashMap<>());
|
this.sessionidUsernameToken.put(sessionId, new ConcurrentHashMap<>());
|
||||||
|
@ -1048,7 +1049,7 @@ public class RoomManager {
|
||||||
if (this.sessionidUsernameToken.get(roomId) != null && this.sessionidTokenTokenobj.get(roomId) != null) {
|
if (this.sessionidUsernameToken.get(roomId) != null && this.sessionidTokenTokenobj.get(roomId) != null) {
|
||||||
if(metadataFormatCorrect(metadata)){
|
if(metadataFormatCorrect(metadata)){
|
||||||
String token = new BigInteger(130, new SecureRandom()).toString(32);
|
String token = new BigInteger(130, new SecureRandom()).toString(32);
|
||||||
if (SECURITY_ENABLED) { // Store the token only if security is enabled
|
if (openviduConf.getOpenViduSecurity()) { // Store the token only if security is enabled
|
||||||
this.sessionidTokenTokenobj.get(roomId).put(token, new Token(token, role, metadata));
|
this.sessionidTokenTokenobj.get(roomId).put(token, new Token(token, role, metadata));
|
||||||
}
|
}
|
||||||
showMap();
|
showMap();
|
||||||
|
@ -1065,7 +1066,7 @@ public class RoomManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String newRandomUserName(String token, String roomId) {
|
public String newRandomUserName(String token, String roomId) {
|
||||||
if (SECURITY_ENABLED) {
|
if (openviduConf.getOpenViduSecurity()) {
|
||||||
if (this.sessionidUsernameToken.get(roomId) != null && this.sessionidTokenTokenobj.get(roomId) != null) {
|
if (this.sessionidUsernameToken.get(roomId) != null && this.sessionidTokenTokenobj.get(roomId) != null) {
|
||||||
if (this.sessionidTokenTokenobj.get(roomId).get(token) != null) {
|
if (this.sessionidTokenTokenobj.get(roomId).get(token) != null) {
|
||||||
return this.generateAndStoreUserName(token, roomId);
|
return this.generateAndStoreUserName(token, roomId);
|
||||||
|
|
|
@ -10,16 +10,81 @@ import org.apache.http.client.HttpClient;
|
||||||
import org.apache.http.client.methods.HttpGet;
|
import org.apache.http.client.methods.HttpGet;
|
||||||
import org.apache.http.impl.client.HttpClientBuilder;
|
import org.apache.http.impl.client.HttpClientBuilder;
|
||||||
|
|
||||||
|
import com.google.gson.JsonArray;
|
||||||
|
import com.google.gson.JsonElement;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import com.google.gson.JsonParser;
|
import com.google.gson.JsonParser;
|
||||||
|
|
||||||
public class NgrokController {
|
public class NgrokController {
|
||||||
|
|
||||||
private final String NGROK_URL = "http://localhost:4040/api/tunnels";
|
private final String NGROK_URL = "http://localhost:4040/api/tunnels";
|
||||||
|
private final String NGROK_APP_NAME = "app";
|
||||||
|
private final String NGROK_SERVER_NAME = "server";
|
||||||
|
|
||||||
|
private String appUrl = "";
|
||||||
|
private String serverUrl = "";
|
||||||
|
private JsonObject json;
|
||||||
|
|
||||||
HttpClient client = HttpClientBuilder.create().build();
|
HttpClient client = HttpClientBuilder.create().build();
|
||||||
|
|
||||||
public String getNgrokPublicUrl() throws ClientProtocolException, IOException {
|
public String getNgrokAppUrl() throws ClientProtocolException, IOException {
|
||||||
|
|
||||||
|
if (this.appUrl != null && !this.appUrl.isEmpty()) {
|
||||||
|
return this.appUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.json == null) {
|
||||||
|
this.json = this.httpRequest();
|
||||||
|
}
|
||||||
|
|
||||||
|
String appPublicUrl = "";
|
||||||
|
|
||||||
|
JsonArray array = this.json.getAsJsonArray("tunnels");
|
||||||
|
for (JsonElement el : array) {
|
||||||
|
JsonObject elObj = el.getAsJsonObject();
|
||||||
|
String name = elObj.get("name").getAsString();
|
||||||
|
if (name.equals(NGROK_APP_NAME)) {
|
||||||
|
appPublicUrl = elObj.get("public_url").getAsString();
|
||||||
|
appPublicUrl = appPublicUrl.replaceFirst("http://", "https://");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.appUrl = appPublicUrl;
|
||||||
|
|
||||||
|
return appPublicUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNgrokServerUrl() throws ClientProtocolException, IOException {
|
||||||
|
|
||||||
|
if (this.serverUrl != null && !this.serverUrl.isEmpty()) {
|
||||||
|
return this.serverUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.json == null) {
|
||||||
|
this.json = this.httpRequest();
|
||||||
|
}
|
||||||
|
|
||||||
|
String serverPublicUrl = "";
|
||||||
|
|
||||||
|
JsonArray array = this.json.getAsJsonArray("tunnels");
|
||||||
|
for (JsonElement el : array) {
|
||||||
|
JsonObject elObj = el.getAsJsonObject();
|
||||||
|
String name = elObj.get("name").getAsString();
|
||||||
|
if (name.equals(NGROK_SERVER_NAME)) {
|
||||||
|
serverPublicUrl = elObj.get("public_url").getAsString();
|
||||||
|
serverPublicUrl = serverPublicUrl.replaceFirst("http://", "https://");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.serverUrl = serverPublicUrl;
|
||||||
|
|
||||||
|
return serverPublicUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
private JsonObject httpRequest() throws ClientProtocolException, IOException {
|
||||||
|
|
||||||
HttpClient client = HttpClientBuilder.create().build();
|
HttpClient client = HttpClientBuilder.create().build();
|
||||||
|
|
||||||
HttpGet request = new HttpGet(NGROK_URL);
|
HttpGet request = new HttpGet(NGROK_URL);
|
||||||
|
@ -31,11 +96,10 @@ public class NgrokController {
|
||||||
while ((line = rd.readLine()) != null) {
|
while ((line = rd.readLine()) != null) {
|
||||||
result.append(line);
|
result.append(line);
|
||||||
}
|
}
|
||||||
JsonObject json = (JsonObject) new JsonParser().parse(result.toString());
|
|
||||||
String publicUrl = json.getAsJsonArray("tunnels").get(0).getAsJsonObject().get("public_url").getAsString();
|
|
||||||
publicUrl = publicUrl.replaceFirst("http://", "https://");
|
|
||||||
|
|
||||||
return publicUrl;
|
JsonObject responseJson = (JsonObject) new JsonParser().parse(result.toString());
|
||||||
|
|
||||||
|
return responseJson;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
package io.openvidu.server.security;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class OpenviduConfiguration {
|
||||||
|
|
||||||
|
@Value("${openvidu.publicurl}")
|
||||||
|
private String openviduPublicUrl; //local, ngrok, FINAL_URL
|
||||||
|
|
||||||
|
@Value("${server.port}")
|
||||||
|
private String serverPort;
|
||||||
|
|
||||||
|
@Value("${openvidu.secret}")
|
||||||
|
private String openviduSecret;
|
||||||
|
|
||||||
|
@Value("${openvidu.security}")
|
||||||
|
private boolean openviduSecurity; // true, false
|
||||||
|
|
||||||
|
public String getOpenViduPublicUrl() {
|
||||||
|
return this.openviduPublicUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getServerPort() {
|
||||||
|
return this.serverPort;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOpenViduSecret() {
|
||||||
|
return this.openviduSecret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getOpenViduSecurity() {
|
||||||
|
return this.openviduSecurity;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,7 +1,6 @@
|
||||||
package io.openvidu.server.security;
|
package io.openvidu.server.security;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.http.HttpMethod;
|
import org.springframework.http.HttpMethod;
|
||||||
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
|
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
|
||||||
|
@ -14,13 +13,13 @@ import org.springframework.security.config.http.SessionCreationPolicy;
|
||||||
@EnableGlobalAuthentication
|
@EnableGlobalAuthentication
|
||||||
public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
||||||
|
|
||||||
@Value("${openvidu.secret}")
|
@Autowired
|
||||||
private String SECRET;
|
OpenviduConfiguration openviduConf;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
|
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
|
||||||
auth.inMemoryAuthentication()
|
auth.inMemoryAuthentication()
|
||||||
.withUser("OPENVIDUAPP").password(SECRET).roles("ADMIN");
|
.withUser("OPENVIDUAPP").password(openviduConf.getOpenViduSecret()).roles("ADMIN");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -8,3 +8,4 @@ kms.uris=[\"ws://localhost:8888/kurento\"]
|
||||||
|
|
||||||
openvidu.secret: MY_SECRET
|
openvidu.secret: MY_SECRET
|
||||||
openvidu.security: false
|
openvidu.security: false
|
||||||
|
openvidu.publicurl: ngrok
|
|
@ -10,3 +10,4 @@ kms.uris=[\"ws://localhost:8888/kurento\"]
|
||||||
|
|
||||||
openvidu.secret: MY_SECRET
|
openvidu.secret: MY_SECRET
|
||||||
openvidu.security: true
|
openvidu.security: true
|
||||||
|
openvidu.publicurl: local
|
File diff suppressed because one or more lines are too long
|
@ -59,7 +59,9 @@ var AppComponent = (function () {
|
||||||
}
|
}
|
||||||
AppComponent.prototype.ngOnInit = function () {
|
AppComponent.prototype.ngOnInit = function () {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
this.websocket = new WebSocket('wss://' + location.hostname + ':8443/info');
|
var protocol = location.protocol.includes('https') ? 'wss://' : 'ws://';
|
||||||
|
var port = (location.port) ? (':' + location.port) : '';
|
||||||
|
this.websocket = new WebSocket(protocol + location.hostname + port + '/info');
|
||||||
this.websocket.onopen = function (event) {
|
this.websocket.onopen = function (event) {
|
||||||
console.log('Info websocket connected');
|
console.log('Info websocket connected');
|
||||||
};
|
};
|
||||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue