Merge branch 'master' of github.com:OpenVidu/openvidu

pull/437/head
OscarSotoSanchez 2020-04-16 16:28:03 +02:00
commit 267b5037e4
9 changed files with 30 additions and 35 deletions

View File

@ -176,6 +176,8 @@ public class OpenviduConfig {
public static String finalUrl;
private boolean isTurnadminAvailable = false;
// Plain config properties getters
public String getServerPort() {
@ -308,6 +310,14 @@ public class OpenviduConfig {
finalUrl = finalUrlParam.endsWith("/") ? (finalUrlParam) : (finalUrlParam + "/");
}
public boolean isTurnadminAvailable() {
return this.isTurnadminAvailable;
}
public void setTurnadminAvailable(boolean available) {
this.isTurnadminAvailable = available;
}
public OpenViduRole[] getRolesFromRecordingNotification() {
OpenViduRole[] roles;
switch (this.openviduRecordingNotification) {

View File

@ -37,31 +37,22 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
// Security for API REST
ExpressionUrlAuthorizationConfigurer<HttpSecurity>.ExpressionInterceptUrlRegistry conf = http.cors().and()
.csrf().disable().authorizeRequests()
// /api/sessions
.antMatchers(HttpMethod.GET, "/api/sessions").authenticated()
.antMatchers(HttpMethod.GET, "/api/sessions/**").authenticated()
.antMatchers(HttpMethod.POST, "/api/sessions").authenticated()
.antMatchers(HttpMethod.POST, "/api/sessions/**").authenticated()
// /api/tokens
.antMatchers(HttpMethod.POST, "/api/tokens").authenticated()
// /api/recordings
.antMatchers(HttpMethod.GET, "/api/recordings").authenticated()
.antMatchers(HttpMethod.GET, "/api/recordings/**").authenticated()
.antMatchers(HttpMethod.POST, "/api/recordings/start").authenticated()
.antMatchers(HttpMethod.POST, "/api/recordings/stop").authenticated()
.antMatchers(HttpMethod.DELETE, "/api/recordings/**").authenticated()
// /api
.antMatchers("/api/**").authenticated()
// /config
.antMatchers(HttpMethod.GET, "/config/openvidu-publicurl").permitAll()
.antMatchers(HttpMethod.GET, "/config/**").authenticated()
// /cdr
.antMatchers(HttpMethod.GET, "/cdr/**").authenticated()
// /accept-certificate
.antMatchers(HttpMethod.GET, "/accept-certificate").permitAll()
// Dashboard
.antMatchers("/").authenticated();
.antMatchers("/dashboard").authenticated();
// Security for layouts
// Security for recording layouts
conf.antMatchers("/layouts/**").authenticated();
// Security for recorded videos
// Security for recorded video files
if (openviduConf.getOpenViduRecordingPublicAccess()) {
conf = conf.antMatchers("/recordings/**").permitAll();
} else {

View File

@ -310,8 +310,7 @@ public abstract class SessionManager {
public Token newTokenForInsecureUser(Session session, String token, String serverMetadata) {
Token tokenObj = new Token(token, OpenViduRole.PUBLISHER, serverMetadata != null ? serverMetadata : "",
this.coturnCredentialsService.isCoturnAvailable() ? this.coturnCredentialsService.createUser() : null,
null);
this.openviduConfig.isTurnadminAvailable() ? this.coturnCredentialsService.createUser() : null, null);
session.storeToken(tokenObj);
session.showTokens("Token created for insecure user");
return tokenObj;

View File

@ -49,7 +49,7 @@ public class TokenGeneratorDefault implements TokenGenerator {
token += "&role=" + role.name();
token += "&version=" + openviduBuildConfig.getOpenViduServerVersion();
TurnCredentials turnCredentials = null;
if (this.coturnCredentialsService.isCoturnAvailable()) {
if (this.openviduConfig.isTurnadminAvailable()) {
turnCredentials = coturnCredentialsService.createUser();
if (turnCredentials != null) {
token += "&coturnIp=" + openviduConfig.getCoturnIp();

View File

@ -63,7 +63,7 @@ public class BashCoturnCredentialsService extends CoturnCredentialsService {
} else {
log.error("COTURN DB is not empty");
}
this.coturnAvailable.compareAndSet(false, true);
this.openviduConfig.setTurnadminAvailable(true);
log.info("Using COTURN credentials service for BASH environment");
}
} catch (IOException | InterruptedException e) {

View File

@ -17,8 +17,6 @@
package io.openvidu.server.coturn;
import java.util.concurrent.atomic.AtomicBoolean;
import javax.annotation.PostConstruct;
import org.slf4j.Logger;
@ -37,16 +35,10 @@ public abstract class CoturnCredentialsService {
protected String coturnDatabaseString;
protected String trimmedCoturnDatabaseString;
protected AtomicBoolean coturnAvailable = new AtomicBoolean(false);
public abstract TurnCredentials createUser();
public abstract boolean deleteUser(String user);
public boolean isCoturnAvailable() {
return this.coturnAvailable.get();
}
@PostConstruct
protected void initDatabse() {
this.coturnDatabaseString = this.openviduConfig.getCoturnDatabaseString();

View File

@ -215,7 +215,7 @@ public class KurentoSessionManager extends SessionManager {
Participant p = sessionidParticipantpublicidParticipant.get(sessionId)
.remove(participant.getParticipantPublicId());
if (this.coturnCredentialsService.isCoturnAvailable()) {
if (this.openviduConfig.isTurnadminAvailable()) {
this.coturnCredentialsService.deleteUser(p.getToken().getTurnCredentials().getUsername());
}

View File

@ -285,7 +285,7 @@ public abstract class MediaEndpoint {
webEndpoint = result;
if (openviduConfig.getCoturnIp() != null && !openviduConfig.getCoturnIp().isEmpty()
&& !openviduConfig.getCoturnIp().equals("localhost")) {
&& openviduConfig.isTurnadminAvailable()) {
webEndpoint.setStunServerAddress(openviduConfig.getCoturnIp());
webEndpoint.setStunServerPort(3478);
}

View File

@ -17,17 +17,20 @@
package io.openvidu.server.rest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
@Controller
@RestController
@CrossOrigin
@RequestMapping("/accept-certificate")
public class CertificateRestController {
@RequestMapping(value = "/accept-certificate", method = RequestMethod.GET)
@RequestMapping(method = RequestMethod.GET)
public String acceptCert() throws Exception {
System.out.println("Navigating to accept certificate");
return "accept-cert";
}
}