Merge pull request #10574 from jfsiebel/fix-reconnect-flow

Fix reconnection flow
This commit is contained in:
Anton Georgiev 2020-10-01 15:10:19 -04:00 committed by GitHub
commit 9f349d8ee4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 32 deletions

View File

@ -8,7 +8,6 @@ import toggleUserLock from './methods/toggleUserLock';
import setUserEffectiveConnectionType from './methods/setUserEffectiveConnectionType';
import userActivitySign from './methods/userActivitySign';
import userLeftMeeting from './methods/userLeftMeeting';
import checkSessionToken from './methods/checkSessionToken';
Meteor.methods({
setEmojiStatus,
@ -20,5 +19,4 @@ Meteor.methods({
setUserEffectiveConnectionType,
userActivitySign,
userLeftMeeting,
checkSessionToken,
});

View File

@ -1,28 +0,0 @@
import Users from '/imports/api/users';
import Logger from '/imports/startup/server/logger';
import BannedUsers from '../store/bannedUsers';
export default function checkSessionToken(meetingId, requesterUserId, requesterToken, externalId) {
// Check if externalId is banned from the meeting
if (externalId) {
if (BannedUsers.has(meetingId, externalId)) {
Logger.warn(`A banned user with extId ${externalId} tried to enter in meeting ${meetingId}`);
return { invalid: true, reason: 'User has been banned' };
}
}
// Prevent users who have left or been ejected to use the same sessionToken again.
const isUserInvalid = Users.findOne({
meetingId,
userId: requesterUserId,
authToken: requesterToken,
$or: [{ ejected: true }, { loggedOut: true }],
});
if (isUserInvalid) {
Logger.warn(`An invalid sessionToken tried to validateAuthToken meetingId=${meetingId} authToken=${requesterToken}`);
return { invalid: true, reason: 'User has an invalid sessionToken' };
}
return { invalid: false };
}

View File

@ -2,12 +2,35 @@ import { Meteor } from 'meteor/meteor';
import RedisPubSub from '/imports/startup/server/redis';
import Logger from '/imports/startup/server/logger';
import pendingAuthenticationsStore from '../store/pendingAuthentications';
import BannedUsers from '../store/bannedUsers';
import Users from '/imports/api/users';
export default function validateAuthToken(meetingId, requesterUserId, requesterToken) {
export default function validateAuthToken(meetingId, requesterUserId, requesterToken, externalId) {
const REDIS_CONFIG = Meteor.settings.private.redis;
const CHANNEL = REDIS_CONFIG.channels.toAkkaApps;
const EVENT_NAME = 'ValidateAuthTokenReqMsg';
// Check if externalId is banned from the meeting
if (externalId) {
if (BannedUsers.has(meetingId, externalId)) {
Logger.warn(`A banned user with extId ${externalId} tried to enter in meeting ${meetingId}`);
return { invalid: true, reason: 'User has been banned' };
}
}
// Prevent users who have left or been ejected to use the same sessionToken again.
const isUserInvalid = Users.findOne({
meetingId,
userId: requesterUserId,
authToken: requesterToken,
$or: [{ ejected: true }, { loggedOut: true }],
});
if (isUserInvalid) {
Logger.warn(`An invalid sessionToken tried to validateAuthToken meetingId=${meetingId} authToken=${requesterToken}`);
return { invalid: true, reason: 'User has an invalid sessionToken' };
}
// Store reference of methodInvocationObject ( to postpone the connection userId definition )
pendingAuthenticationsStore.add(meetingId, requesterUserId, requesterToken, this);

View File

@ -218,7 +218,7 @@ class Auth {
});
}, CONNECTION_TIMEOUT);
const result = await makeCall('checkSessionToken', this.meetingID, this.userID, this.token, this.externUserID);
const result = await makeCall('validateAuthToken', this.meetingID, this.userID, this.token, this.externUserID);
if (result && result.invalid) {
clearTimeout(validationTimeout);