From a640d3da07b957f0e58869b40ee0d84e499b88d7 Mon Sep 17 00:00:00 2001 From: pabloFuente Date: Sat, 20 May 2017 21:07:42 +0200 Subject: [PATCH] Trying an advanced secure app demo is a piece of cake now --- README.md | 22 ++++++++++++++++++- .../session_manager/SessionController.java | 6 ++--- .../application-container.properties | 15 +++++++++++++ .../src/main/resources/application.properties | 1 + 4 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 openvidu-sample-app/src/main/resources/application-container.properties diff --git a/README.md b/README.md index 9484bc67..26977022 100644 --- a/README.md +++ b/README.md @@ -220,6 +220,26 @@ String token = session.generateToken(); > Communication between _Your Back_ and _openvidu-server_ modules is outlined in the diagram, but it does not correspond to the real methods. Remember you can handle this from your backend by consuming the [REST API](#rest-api) or by using _openvidu-backend-client_ package. + +## A sample advanced app +Wanna try a real sample application that makes use of everything we have talked about? Take a look at this app. It wraps a backend built with Spring and a MySQL database: + + - Please be sure that you have docker-compose (`sudo apt-get install docker-compose`) + - Download the `docker-compose.yml` file and run it: + + ``` + wget -O docker-compose.yml https://raw.githubusercontent.com/OpenVidu/openvidu-docker/master/openvidu-sample-app/docker-compose.yml + docker-compose up + ``` + - Wait until you see an output like `Started App in 13.986 seconds (JVM running for 15.501)` + + - Go to [`https://localhost:8443`](https://localhost:8443) and accept the self-signed certificate. Then you can access the app through [`http://localhost:5000`](http://localhost:5000). Here you have a couple registered users (use a standard window and an incognito window to test both of them at the same time): + + | user | password | + | -------------------------- | ----------- | + | teacher@gmail.com | pass | + | student1@gmail.com | pass | + ---------- @@ -408,7 +428,7 @@ Here you have a step by step guide to deploy a production version of OpenVidu in 7. Init openvidu-server Docker container (securization enabled) - ```bash + ``` sudo docker run -d -p 8443:8443 -e openvidu.security=true -e openvidu.secret=YOUR_SECRET -e kms.uris=[\"ws://YOUR_MACHINE'S_INTERNAL_IP:8888/kurento\"] openvidu/openvidu-server ``` diff --git a/openvidu-sample-app/src/main/java/openvidu/openvidu_sample_app/session_manager/SessionController.java b/openvidu-sample-app/src/main/java/openvidu/openvidu_sample_app/session_manager/SessionController.java index 71c630ea..f8e4ecee 100644 --- a/openvidu-sample-app/src/main/java/openvidu/openvidu_sample_app/session_manager/SessionController.java +++ b/openvidu-sample-app/src/main/java/openvidu/openvidu_sample_app/session_manager/SessionController.java @@ -39,12 +39,12 @@ public class SessionController { private Map lessonIdSession = new ConcurrentHashMap<>(); private Map> sessionIdUserIdToken = new ConcurrentHashMap<>(); - private final String OPENVIDU_URL = "https://localhost:8443/"; - + private String OPENVIDU_URL; private String SECRET; - public SessionController(@Value("${openvidu.secret}") String secret){ + public SessionController(@Value("${openvidu.secret}") String secret, @Value("${openvidu.url}") String openviduUrl){ this.SECRET = secret; + this.OPENVIDU_URL = openviduUrl; this.openVidu = new OpenVidu(OPENVIDU_URL, SECRET); } diff --git a/openvidu-sample-app/src/main/resources/application-container.properties b/openvidu-sample-app/src/main/resources/application-container.properties new file mode 100644 index 00000000..68c3bd7e --- /dev/null +++ b/openvidu-sample-app/src/main/resources/application-container.properties @@ -0,0 +1,15 @@ +spring.profiles.active=container + +server.port: 5000 + +spring.datasource.url: jdbc:mysql://mysql:3306/openvidu_sample_app +spring.datasource.username: op-root +spring.datasource.password: pass +spring.datasource.driverClassName: com.mysql.jdbc.Driver +spring.datasource.platform: mysql +spring.jpa.database: MYSQL +spring.jpa.hibernate.ddl-auto: create-drop + +openvidu.url: https://service-openvidu-server-kms:8443/ +openvidu.secret: MY_SECRET + diff --git a/openvidu-sample-app/src/main/resources/application.properties b/openvidu-sample-app/src/main/resources/application.properties index aa7e7065..452655bc 100644 --- a/openvidu-sample-app/src/main/resources/application.properties +++ b/openvidu-sample-app/src/main/resources/application.properties @@ -7,4 +7,5 @@ spring.datasource.driverClassName: com.mysql.jdbc.Driver spring.jpa.database: MYSQL spring.jpa.hibernate.ddl-auto: create-drop +openvidu.url: https://localhost:8443/ openvidu.secret: MY_SECRET