瀏覽代碼

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.
master
damencho 4 年之前
父節點
當前提交
cdd782a82f

+ 4
- 9
connection.js 查看文件

@@ -82,7 +82,7 @@ function checkForAttachParametersAndConnect(id, password, connection) {
82 82
  */
83 83
 function connect(id, password, roomName) {
84 84
     const connectionConfig = Object.assign({}, config);
85
-    const { issuer, jwt } = APP.store.getState()['features/base/jwt'];
85
+    const { jwt } = APP.store.getState()['features/base/jwt'];
86 86
 
87 87
     // Use Websocket URL for the web app if configured. Note that there is no 'isWeb' check, because there's assumption
88 88
     // 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) {
94 94
     //  in future). It's included for the time being for Jitsi Meet and lib-jitsi-meet versions interoperability.
95 95
     connectionConfig.serviceUrl = connectionConfig.bosh = serviceUrl;
96 96
 
97
-    const connection
98
-        = new JitsiMeetJS.JitsiConnection(
99
-            null,
100
-            jwt && issuer && issuer !== 'anonymous' ? jwt : undefined,
101
-            connectionConfig);
97
+    const connection = new JitsiMeetJS.JitsiConnection(null, jwt, connectionConfig);
102 98
 
103 99
     if (config.iAmRecorder) {
104 100
         connection.addFeature(DISCO_JIBRI_FEATURE);
@@ -211,10 +207,9 @@ export function openConnection({ id, password, retry, roomName }) {
211 207
 
212 208
     return connect(id, password, roomName).catch(err => {
213 209
         if (retry) {
214
-            const { issuer, jwt } = APP.store.getState()['features/base/jwt'];
210
+            const { jwt } = APP.store.getState()['features/base/jwt'];
215 211
 
216
-            if (err === JitsiConnectionErrors.PASSWORD_REQUIRED
217
-                    && (!jwt || issuer === 'anonymous')) {
212
+            if (err === JitsiConnectionErrors.PASSWORD_REQUIRED && !jwt) {
218 213
                 return AuthHandler.requestAuth(roomName, connect);
219 214
             }
220 215
         }

+ 2
- 6
react/features/base/connection/actions.native.js 查看文件

@@ -80,12 +80,8 @@ export function connect(id: ?string, password: ?string) {
80 80
         const state = getState();
81 81
         const options = _constructOptions(state);
82 82
         const { locationURL } = state['features/base/connection'];
83
-        const { issuer, jwt } = state['features/base/jwt'];
84
-        const connection
85
-            = new JitsiMeetJS.JitsiConnection(
86
-                options.appId,
87
-                jwt && issuer && issuer !== 'anonymous' ? jwt : undefined,
88
-                options);
83
+        const { jwt } = state['features/base/jwt'];
84
+        const connection = new JitsiMeetJS.JitsiConnection(options.appId, jwt, options);
89 85
 
90 86
         connection[JITSI_CONNECTION_URL_KEY] = locationURL;
91 87
 

+ 5
- 0
react/features/base/jwt/logger.js 查看文件

@@ -0,0 +1,5 @@
1
+// @flow
2
+
3
+import { getLogger } from '../logging/functions';
4
+
5
+export default getLogger('features/base/jwt');

+ 8
- 1
react/features/base/jwt/middleware.js 查看文件

@@ -13,6 +13,7 @@ import { MiddlewareRegistry } from '../redux';
13 13
 import { SET_JWT } from './actionTypes';
14 14
 import { setJWT } from './actions';
15 15
 import { parseJWTFromURLParams } from './functions';
16
+import logger from './logger';
16 17
 
17 18
 declare var APP: Object;
18 19
 
@@ -133,7 +134,13 @@ function _setJWT(store, next, action) {
133 134
 
134 135
             action.isGuest = !enableUserRolesBasedOnToken;
135 136
 
136
-            const jwtPayload = jwtDecode(jwt);
137
+            let jwtPayload;
138
+
139
+            try {
140
+                jwtPayload = jwtDecode(jwt);
141
+            } catch (e) {
142
+                logger.error(e);
143
+            }
137 144
 
138 145
             if (jwtPayload) {
139 146
                 const { context, iss } = jwtPayload;

Loading…
取消
儲存