Some cleanup.
parent
cacc9abf7c
commit
bb8cf02c23
|
|
@ -321,12 +321,7 @@ export default class RoomClient
|
||||||
|
|
||||||
const { displayName, picture } = data;
|
const { displayName, picture } = data;
|
||||||
|
|
||||||
if (store.getState().room.joined || store.getState().room.inLobby)
|
store.dispatch(stateActions.setDisplayName(displayName));
|
||||||
{
|
|
||||||
this.changeDisplayName(displayName);
|
|
||||||
this.changeProfilePicture(picture);
|
|
||||||
}
|
|
||||||
|
|
||||||
store.dispatch(stateActions.setPicture(picture));
|
store.dispatch(stateActions.setPicture(picture));
|
||||||
store.dispatch(stateActions.loggedIn());
|
store.dispatch(stateActions.loggedIn());
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,18 +12,24 @@ class Peer extends EventEmitter
|
||||||
|
|
||||||
this._id = id;
|
this._id = id;
|
||||||
|
|
||||||
|
this._authId = null;
|
||||||
|
|
||||||
this._socket = socket;
|
this._socket = socket;
|
||||||
|
|
||||||
this._closed = false;
|
this._closed = false;
|
||||||
|
|
||||||
this._joined = false;
|
this._joined = false;
|
||||||
|
|
||||||
|
this._inLobby = false;
|
||||||
|
|
||||||
this._authenticated = false;
|
this._authenticated = false;
|
||||||
|
|
||||||
this._displayName = false;
|
this._displayName = false;
|
||||||
|
|
||||||
this._picture = null;
|
this._picture = null;
|
||||||
|
|
||||||
|
this._email = null;
|
||||||
|
|
||||||
this._device = null;
|
this._device = null;
|
||||||
|
|
||||||
this._rtpCapabilities = null;
|
this._rtpCapabilities = null;
|
||||||
|
|
@ -71,20 +77,10 @@ class Peer extends EventEmitter
|
||||||
|
|
||||||
this.socket.on('request', (request, cb) =>
|
this.socket.on('request', (request, cb) =>
|
||||||
{
|
{
|
||||||
logger.debug(
|
|
||||||
'Peer "request" event [method:"%s", peer:"%s"]',
|
|
||||||
request.method, this.id);
|
|
||||||
|
|
||||||
if (this._closed)
|
if (this._closed)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
this._handleSocketRequest(request, cb)
|
this._handleSocketRequest(request, cb).catch(cb);
|
||||||
.catch((error) =>
|
|
||||||
{
|
|
||||||
logger.error('request failed [error:"%o"]', error);
|
|
||||||
|
|
||||||
cb(error);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.socket.on('disconnect', () =>
|
this.socket.on('disconnect', () =>
|
||||||
|
|
@ -100,12 +96,6 @@ class Peer extends EventEmitter
|
||||||
|
|
||||||
async _handleSocketRequest(request, cb)
|
async _handleSocketRequest(request, cb)
|
||||||
{
|
{
|
||||||
logger.debug(
|
|
||||||
'_handleSocketRequest [peer:"%s"], [request:"%s"]',
|
|
||||||
this.id,
|
|
||||||
request.method
|
|
||||||
);
|
|
||||||
|
|
||||||
if (this._closed)
|
if (this._closed)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
@ -121,14 +111,45 @@ class Peer extends EventEmitter
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case 'changeProfilePicture':
|
||||||
|
{
|
||||||
|
const { picture } = request.data;
|
||||||
|
|
||||||
|
this.picture = picture;
|
||||||
|
|
||||||
|
cb();
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_checkAuthentication()
|
_checkAuthentication()
|
||||||
{
|
{
|
||||||
this.authenticated =
|
if (
|
||||||
Boolean(this.socket.handshake.session.passport) &&
|
Boolean(this.socket.handshake.session.passport) &&
|
||||||
Boolean(this.socket.handshake.session.passport.user);
|
Boolean(this.socket.handshake.session.passport.user)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
const {
|
||||||
|
id,
|
||||||
|
displayName,
|
||||||
|
picture,
|
||||||
|
email
|
||||||
|
} = this.socket.handshake.session.passport.user;
|
||||||
|
|
||||||
|
id && (this.authId = id);
|
||||||
|
displayName && (this.displayName = displayName);
|
||||||
|
picture && (this.picture = picture);
|
||||||
|
email && (this.email = email);
|
||||||
|
|
||||||
|
this.authenticated = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.authenticated = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
get id()
|
get id()
|
||||||
|
|
@ -141,6 +162,16 @@ class Peer extends EventEmitter
|
||||||
this._id = id;
|
this._id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get authId()
|
||||||
|
{
|
||||||
|
return this._authId;
|
||||||
|
}
|
||||||
|
|
||||||
|
set authId(authId)
|
||||||
|
{
|
||||||
|
this._authId = authId;
|
||||||
|
}
|
||||||
|
|
||||||
get socket()
|
get socket()
|
||||||
{
|
{
|
||||||
return this._socket;
|
return this._socket;
|
||||||
|
|
@ -166,6 +197,16 @@ class Peer extends EventEmitter
|
||||||
this._joined = joined;
|
this._joined = joined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get inLobby()
|
||||||
|
{
|
||||||
|
return this._inLobby;
|
||||||
|
}
|
||||||
|
|
||||||
|
set inLobby(inLobby)
|
||||||
|
{
|
||||||
|
this._inLobby = inLobby;
|
||||||
|
}
|
||||||
|
|
||||||
get authenticated()
|
get authenticated()
|
||||||
{
|
{
|
||||||
return this._authenticated;
|
return this._authenticated;
|
||||||
|
|
@ -217,6 +258,16 @@ class Peer extends EventEmitter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get email()
|
||||||
|
{
|
||||||
|
return this._email;
|
||||||
|
}
|
||||||
|
|
||||||
|
set email(email)
|
||||||
|
{
|
||||||
|
this._email = email;
|
||||||
|
}
|
||||||
|
|
||||||
get device()
|
get device()
|
||||||
{
|
{
|
||||||
return this._device;
|
return this._device;
|
||||||
|
|
|
||||||
|
|
@ -263,10 +263,7 @@ class Room extends EventEmitter
|
||||||
// checks both room and lobby
|
// checks both room and lobby
|
||||||
checkEmpty()
|
checkEmpty()
|
||||||
{
|
{
|
||||||
if ((this._peers.size == 0) && (this._lobby.checkEmpty()))
|
return (this._peers.size == 0) && (this._lobby.checkEmpty());
|
||||||
return true;
|
|
||||||
else
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_parkPeer(parkPeer)
|
_parkPeer(parkPeer)
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@
|
||||||
"body-parser": "^1.19.0",
|
"body-parser": "^1.19.0",
|
||||||
"colors": "^1.4.0",
|
"colors": "^1.4.0",
|
||||||
"compression": "^1.7.4",
|
"compression": "^1.7.4",
|
||||||
|
"connect-redis": "^4.0.3",
|
||||||
"cookie-parser": "^1.4.4",
|
"cookie-parser": "^1.4.4",
|
||||||
"debug": "^4.1.1",
|
"debug": "^4.1.1",
|
||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
|
|
@ -21,6 +22,7 @@
|
||||||
"mediasoup": "^3.0.12",
|
"mediasoup": "^3.0.12",
|
||||||
"openid-client": "^3.7.3",
|
"openid-client": "^3.7.3",
|
||||||
"passport": "^0.4.0",
|
"passport": "^0.4.0",
|
||||||
|
"redis": "^2.8.0",
|
||||||
"socket.io": "^2.3.0",
|
"socket.io": "^2.3.0",
|
||||||
"spdy": "^4.0.1"
|
"spdy": "^4.0.1"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,11 @@ const helmet = require('helmet');
|
||||||
const httpHelper = require('./httpHelper');
|
const httpHelper = require('./httpHelper');
|
||||||
// auth
|
// auth
|
||||||
const passport = require('passport');
|
const passport = require('passport');
|
||||||
|
const redis = require('redis');
|
||||||
|
const client = redis.createClient();
|
||||||
const { Issuer, Strategy } = require('openid-client');
|
const { Issuer, Strategy } = require('openid-client');
|
||||||
const expressSession = require('express-session');
|
const expressSession = require('express-session');
|
||||||
|
const RedisStore = require('connect-redis')(expressSession);
|
||||||
const sharedSession = require('express-socket.io-session');
|
const sharedSession = require('express-socket.io-session');
|
||||||
|
|
||||||
/* eslint-disable no-console */
|
/* eslint-disable no-console */
|
||||||
|
|
@ -67,6 +70,7 @@ const session = expressSession({
|
||||||
secret : config.cookieSecret,
|
secret : config.cookieSecret,
|
||||||
resave : true,
|
resave : true,
|
||||||
saveUninitialized : true,
|
saveUninitialized : true,
|
||||||
|
store : new RedisStore({ client }),
|
||||||
cookie : {
|
cookie : {
|
||||||
secure : true,
|
secure : true,
|
||||||
httpOnly : true
|
httpOnly : true
|
||||||
|
|
@ -171,10 +175,9 @@ async function setupAuth(oidcIssuer)
|
||||||
// resolved from the issuer configuration, instead of true you may provide
|
// resolved from the issuer configuration, instead of true you may provide
|
||||||
// any of the supported values directly, i.e. "S256" (recommended) or "plain"
|
// any of the supported values directly, i.e. "S256" (recommended) or "plain"
|
||||||
const usePKCE = false;
|
const usePKCE = false;
|
||||||
const client = oidcClient;
|
|
||||||
|
|
||||||
oidcStrategy = new Strategy(
|
oidcStrategy = new Strategy(
|
||||||
{ client, params, passReqToCallback, usePKCE },
|
{ oidcClient, params, passReqToCallback, usePKCE },
|
||||||
(tokenset, userinfo, done) =>
|
(tokenset, userinfo, done) =>
|
||||||
{
|
{
|
||||||
const user =
|
const user =
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue