Skip to content

Commit

Permalink
Secret declared in insecure tutorials for better understanding
Browse files Browse the repository at this point in the history
  • Loading branch information
pabloFuente committed Jul 23, 2018
1 parent a45b905 commit a8700eb
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
5 changes: 3 additions & 2 deletions openvidu-getaroom/web/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ function updateLayout() {
*/

var OPENVIDU_SERVER_URL = "https://" + location.hostname + ":4443";
var OPENVIDU_SERVER_SECRET = "MY_SECRET";

function getToken(mySessionId) {
return createSession(mySessionId).then(sId => createToken(sId));
Expand All @@ -279,7 +280,7 @@ function createSession(sId) {
url: OPENVIDU_SERVER_URL + "/api/sessions",
data: JSON.stringify({ customSessionId: sId }),
headers: {
"Authorization": "Basic " + btoa("OPENVIDUAPP:MY_SECRET"),
"Authorization": "Basic " + btoa("OPENVIDUAPP:" + OPENVIDU_SERVER_SECRET),
"Content-Type": "application/json"
},
success: response => resolve(response.id),
Expand All @@ -305,7 +306,7 @@ function createToken(sId) {
url: OPENVIDU_SERVER_URL + "/api/tokens",
data: JSON.stringify({ session: sId }),
headers: {
"Authorization": "Basic " + btoa("OPENVIDUAPP:MY_SECRET"),
"Authorization": "Basic " + btoa("OPENVIDUAPP:" + OPENVIDU_SERVER_SECRET),
"Content-Type": "application/json"
},
success: response => resolve(response.token),
Expand Down
5 changes: 3 additions & 2 deletions openvidu-hello-world/web/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ window.onbeforeunload = function () {
*/

var OPENVIDU_SERVER_URL = "https://" + location.hostname + ":4443";
var OPENVIDU_SERVER_SECRET = "MY_SECRET";

function getToken(mySessionId) {
return createSession(mySessionId).then(sessionId => createToken(sessionId));
Expand All @@ -66,7 +67,7 @@ function createSession(sessionId) {
url: OPENVIDU_SERVER_URL + "/api/sessions",
data: JSON.stringify({ customSessionId: sessionId }),
headers: {
"Authorization": "Basic " + btoa("OPENVIDUAPP:MY_SECRET"),
"Authorization": "Basic " + btoa("OPENVIDUAPP:" + OPENVIDU_SERVER_SECRET),
"Content-Type": "application/json"
},
success: response => resolve(response.id),
Expand All @@ -92,7 +93,7 @@ function createToken(sessionId) {
url: OPENVIDU_SERVER_URL + "/api/tokens",
data: JSON.stringify({ session: sessionId }),
headers: {
"Authorization": "Basic " + btoa("OPENVIDUAPP:MY_SECRET"),
"Authorization": "Basic " + btoa("OPENVIDUAPP:" + OPENVIDU_SERVER_SECRET),
"Content-Type": "application/json"
},
success: response => resolve(response.token),
Expand Down
5 changes: 3 additions & 2 deletions openvidu-insecure-angular/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { OpenVidu, Session, StreamManager, Publisher, Subscriber, StreamEvent }
export class AppComponent implements OnDestroy {

OPENVIDU_SERVER_URL = 'https://' + location.hostname + ':4443';
OPENVIDU_SERVER_SECRET = 'MY_SECRET';

// OpenVidu objects
OV: OpenVidu;
Expand Down Expand Up @@ -170,7 +171,7 @@ export class AppComponent implements OnDestroy {
const body = JSON.stringify({ customSessionId: sessionId });
const options = {
headers: new HttpHeaders({
'Authorization': 'Basic ' + btoa('OPENVIDUAPP:MY_SECRET'),
'Authorization': 'Basic ' + btoa('OPENVIDUAPP:' + this.OPENVIDU_SERVER_SECRET),
'Content-Type': 'application/json'
})
};
Expand Down Expand Up @@ -203,7 +204,7 @@ export class AppComponent implements OnDestroy {
const body = JSON.stringify({ session: sessionId });
const options = {
headers: new HttpHeaders({
'Authorization': 'Basic ' + btoa('OPENVIDUAPP:MY_SECRET'),
'Authorization': 'Basic ' + btoa('OPENVIDUAPP:' + this.OPENVIDU_SERVER_SECRET),
'Content-Type': 'application/json'
})
};
Expand Down
5 changes: 3 additions & 2 deletions openvidu-insecure-js/web/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ function initMainVideo(videoElement, userData) {
*/

var OPENVIDU_SERVER_URL = "https://" + location.hostname + ":4443";
var OPENVIDU_SERVER_SECRET = "MY_SECRET";

function getToken(mySessionId) {
return createSession(mySessionId).then(sessionId => createToken(sessionId));
Expand All @@ -199,7 +200,7 @@ function createSession(sessionId) {
url: OPENVIDU_SERVER_URL + "/api/sessions",
data: JSON.stringify({ customSessionId: sessionId }),
headers: {
"Authorization": "Basic " + btoa("OPENVIDUAPP:MY_SECRET"),
"Authorization": "Basic " + btoa("OPENVIDUAPP:" + OPENVIDU_SERVER_SECRET),
"Content-Type": "application/json"
},
success: response => resolve(response.id),
Expand All @@ -225,7 +226,7 @@ function createToken(sessionId) {
url: OPENVIDU_SERVER_URL + "/api/tokens",
data: JSON.stringify({ session: sessionId }),
headers: {
"Authorization": "Basic " + btoa("OPENVIDUAPP:MY_SECRET"),
"Authorization": "Basic " + btoa("OPENVIDUAPP:" + OPENVIDU_SERVER_SECRET),
"Content-Type": "application/json"
},
success: response => resolve(response.token),
Expand Down
5 changes: 3 additions & 2 deletions openvidu-webcomponent/web/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ function joinSession() {
*/

var OPENVIDU_SERVER_URL = 'https://' + location.hostname + ':4443';
var OPENVIDU_SERVER_SECRET = "MY_SECRET";

function getToken(sessionName) {
return createSession(sessionName).then((sessionId) => createToken(sessionId));
Expand All @@ -50,7 +51,7 @@ function createSession(sessionName) {
url: OPENVIDU_SERVER_URL + '/api/sessions',
data: JSON.stringify({ customSessionId: sessionName }),
headers: {
Authorization: 'Basic ' + btoa('OPENVIDUAPP:MY_SECRET'),
Authorization: 'Basic ' + btoa('OPENVIDUAPP:' + OPENVIDU_SERVER_SECRET),
'Content-Type': 'application/json',
},
success: (response) => resolve(response.id),
Expand Down Expand Up @@ -84,7 +85,7 @@ function createToken(sessionId) {
url: OPENVIDU_SERVER_URL + '/api/tokens',
data: JSON.stringify({ session: sessionId }),
headers: {
Authorization: 'Basic ' + btoa('OPENVIDUAPP:MY_SECRET'),
Authorization: 'Basic ' + btoa('OPENVIDUAPP:' + OPENVIDU_SERVER_SECRET),
'Content-Type': 'application/json',
},
success: (response) => resolve(response.token),
Expand Down

0 comments on commit a8700eb

Please sign in to comment.