瀏覽代碼

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

+ 4
- 9
connection.js 查看文件

82
  */
82
  */
83
 function connect(id, password, roomName) {
83
 function connect(id, password, roomName) {
84
     const connectionConfig = Object.assign({}, config);
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
     // Use Websocket URL for the web app if configured. Note that there is no 'isWeb' check, because there's assumption
87
     // Use Websocket URL for the web app if configured. Note that there is no 'isWeb' check, because there's assumption
88
     // that this code executes only on web browsers/electron. This needs to be changed when mobile and web are unified.
88
     // that this code executes only on web browsers/electron. This needs to be changed when mobile and web are unified.
94
     //  in future). It's included for the time being for Jitsi Meet and lib-jitsi-meet versions interoperability.
94
     //  in future). It's included for the time being for Jitsi Meet and lib-jitsi-meet versions interoperability.
95
     connectionConfig.serviceUrl = connectionConfig.bosh = serviceUrl;
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
     if (config.iAmRecorder) {
99
     if (config.iAmRecorder) {
104
         connection.addFeature(DISCO_JIBRI_FEATURE);
100
         connection.addFeature(DISCO_JIBRI_FEATURE);
211
 
207
 
212
     return connect(id, password, roomName).catch(err => {
208
     return connect(id, password, roomName).catch(err => {
213
         if (retry) {
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
                 return AuthHandler.requestAuth(roomName, connect);
213
                 return AuthHandler.requestAuth(roomName, connect);
219
             }
214
             }
220
         }
215
         }

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

80
         const state = getState();
80
         const state = getState();
81
         const options = _constructOptions(state);
81
         const options = _constructOptions(state);
82
         const { locationURL } = state['features/base/connection'];
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
         connection[JITSI_CONNECTION_URL_KEY] = locationURL;
86
         connection[JITSI_CONNECTION_URL_KEY] = locationURL;
91
 
87
 

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

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
 import { SET_JWT } from './actionTypes';
13
 import { SET_JWT } from './actionTypes';
14
 import { setJWT } from './actions';
14
 import { setJWT } from './actions';
15
 import { parseJWTFromURLParams } from './functions';
15
 import { parseJWTFromURLParams } from './functions';
16
+import logger from './logger';
16
 
17
 
17
 declare var APP: Object;
18
 declare var APP: Object;
18
 
19
 
133
 
134
 
134
             action.isGuest = !enableUserRolesBasedOnToken;
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
             if (jwtPayload) {
145
             if (jwtPayload) {
139
                 const { context, iss } = jwtPayload;
146
                 const { context, iss } = jwtPayload;

Loading…
取消
儲存