fix: Fixes uncaught exception on malformed jwt.
Does not skip passing jwt even when malformed to allow getting the error, terminating the connection and showing the warning. We were not passing jwt when malformed and were successfully joining a conference for deployments where no token is allowed.
This commit is contained in:
parent
713ae817c0
commit
cdd782a82f
|
@ -82,7 +82,7 @@ function checkForAttachParametersAndConnect(id, password, connection) {
|
||||||
*/
|
*/
|
||||||
function connect(id, password, roomName) {
|
function connect(id, password, roomName) {
|
||||||
const connectionConfig = Object.assign({}, config);
|
const connectionConfig = Object.assign({}, config);
|
||||||
const { issuer, jwt } = APP.store.getState()['features/base/jwt'];
|
const { jwt } = APP.store.getState()['features/base/jwt'];
|
||||||
|
|
||||||
// Use Websocket URL for the web app if configured. Note that there is no 'isWeb' check, because there's assumption
|
// Use Websocket URL for the web app if configured. Note that there is no 'isWeb' check, because there's assumption
|
||||||
// that this code executes only on web browsers/electron. This needs to be changed when mobile and web are unified.
|
// that this code executes only on web browsers/electron. This needs to be changed when mobile and web are unified.
|
||||||
|
@ -94,11 +94,7 @@ function connect(id, password, roomName) {
|
||||||
// in future). It's included for the time being for Jitsi Meet and lib-jitsi-meet versions interoperability.
|
// in future). It's included for the time being for Jitsi Meet and lib-jitsi-meet versions interoperability.
|
||||||
connectionConfig.serviceUrl = connectionConfig.bosh = serviceUrl;
|
connectionConfig.serviceUrl = connectionConfig.bosh = serviceUrl;
|
||||||
|
|
||||||
const connection
|
const connection = new JitsiMeetJS.JitsiConnection(null, jwt, connectionConfig);
|
||||||
= new JitsiMeetJS.JitsiConnection(
|
|
||||||
null,
|
|
||||||
jwt && issuer && issuer !== 'anonymous' ? jwt : undefined,
|
|
||||||
connectionConfig);
|
|
||||||
|
|
||||||
if (config.iAmRecorder) {
|
if (config.iAmRecorder) {
|
||||||
connection.addFeature(DISCO_JIBRI_FEATURE);
|
connection.addFeature(DISCO_JIBRI_FEATURE);
|
||||||
|
@ -211,10 +207,9 @@ export function openConnection({ id, password, retry, roomName }) {
|
||||||
|
|
||||||
return connect(id, password, roomName).catch(err => {
|
return connect(id, password, roomName).catch(err => {
|
||||||
if (retry) {
|
if (retry) {
|
||||||
const { issuer, jwt } = APP.store.getState()['features/base/jwt'];
|
const { jwt } = APP.store.getState()['features/base/jwt'];
|
||||||
|
|
||||||
if (err === JitsiConnectionErrors.PASSWORD_REQUIRED
|
if (err === JitsiConnectionErrors.PASSWORD_REQUIRED && !jwt) {
|
||||||
&& (!jwt || issuer === 'anonymous')) {
|
|
||||||
return AuthHandler.requestAuth(roomName, connect);
|
return AuthHandler.requestAuth(roomName, connect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,12 +80,8 @@ export function connect(id: ?string, password: ?string) {
|
||||||
const state = getState();
|
const state = getState();
|
||||||
const options = _constructOptions(state);
|
const options = _constructOptions(state);
|
||||||
const { locationURL } = state['features/base/connection'];
|
const { locationURL } = state['features/base/connection'];
|
||||||
const { issuer, jwt } = state['features/base/jwt'];
|
const { jwt } = state['features/base/jwt'];
|
||||||
const connection
|
const connection = new JitsiMeetJS.JitsiConnection(options.appId, jwt, options);
|
||||||
= new JitsiMeetJS.JitsiConnection(
|
|
||||||
options.appId,
|
|
||||||
jwt && issuer && issuer !== 'anonymous' ? jwt : undefined,
|
|
||||||
options);
|
|
||||||
|
|
||||||
connection[JITSI_CONNECTION_URL_KEY] = locationURL;
|
connection[JITSI_CONNECTION_URL_KEY] = locationURL;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
// @flow
|
||||||
|
|
||||||
|
import { getLogger } from '../logging/functions';
|
||||||
|
|
||||||
|
export default getLogger('features/base/jwt');
|
|
@ -13,6 +13,7 @@ import { MiddlewareRegistry } from '../redux';
|
||||||
import { SET_JWT } from './actionTypes';
|
import { SET_JWT } from './actionTypes';
|
||||||
import { setJWT } from './actions';
|
import { setJWT } from './actions';
|
||||||
import { parseJWTFromURLParams } from './functions';
|
import { parseJWTFromURLParams } from './functions';
|
||||||
|
import logger from './logger';
|
||||||
|
|
||||||
declare var APP: Object;
|
declare var APP: Object;
|
||||||
|
|
||||||
|
@ -133,7 +134,13 @@ function _setJWT(store, next, action) {
|
||||||
|
|
||||||
action.isGuest = !enableUserRolesBasedOnToken;
|
action.isGuest = !enableUserRolesBasedOnToken;
|
||||||
|
|
||||||
const jwtPayload = jwtDecode(jwt);
|
let jwtPayload;
|
||||||
|
|
||||||
|
try {
|
||||||
|
jwtPayload = jwtDecode(jwt);
|
||||||
|
} catch (e) {
|
||||||
|
logger.error(e);
|
||||||
|
}
|
||||||
|
|
||||||
if (jwtPayload) {
|
if (jwtPayload) {
|
||||||
const { context, iss } = jwtPayload;
|
const { context, iss } = jwtPayload;
|
||||||
|
|
Loading…
Reference in New Issue