Просмотр исходного кода

Merge pull request #168 from jitsi/jwt-login-service-2

Jwt login service 2
dev1
hristoterezov 9 лет назад
Родитель
Сommit
6f5bcf70b3
3 измененных файлов: 39 добавлений и 2 удалений
  1. 3
    1
      JitsiMeetJS.js
  2. 33
    0
      modules/util/AuthUtil.js
  3. 3
    1
      modules/xmpp/xmpp.js

+ 3
- 1
JitsiMeetJS.js Просмотреть файл

1
 var logger = require("jitsi-meet-logger").getLogger(__filename);
1
 var logger = require("jitsi-meet-logger").getLogger(__filename);
2
+var AuthUtil = require("./modules/util/AuthUtil");
2
 var JitsiConnection = require("./JitsiConnection");
3
 var JitsiConnection = require("./JitsiConnection");
3
 var JitsiMediaDevices = require("./JitsiMediaDevices");
4
 var JitsiMediaDevices = require("./JitsiMediaDevices");
4
 var JitsiConferenceEvents = require("./JitsiConferenceEvents");
5
 var JitsiConferenceEvents = require("./JitsiConferenceEvents");
236
      */
237
      */
237
     util: {
238
     util: {
238
         ScriptUtil: ScriptUtil,
239
         ScriptUtil: ScriptUtil,
239
-        RTCUIHelper: RTCUIHelper
240
+        RTCUIHelper: RTCUIHelper,
241
+        AuthUtil: AuthUtil
240
     }
242
     }
241
 };
243
 };
242
 
244
 

+ 33
- 0
modules/util/AuthUtil.js Просмотреть файл

1
+var AuthUtil = {
2
+    /**
3
+     * Creates the URL pointing to JWT token authentication service. It is
4
+     * formatted from the 'urlPattern' argument which can contain the following
5
+     * constants:
6
+     * '{room}' - name of the conference room passed as <tt>roomName</tt>
7
+     * argument to this method.
8
+     * '{roleUpgrade}' - will contain 'true' if the URL will be used for
9
+     * the role upgrade scenario, where user connects from anonymous domain and
10
+     * then gets upgraded to the moderator by logging-in from the popup window.
11
+     *
12
+     * @param urlPattern a URL pattern pointing to the login service
13
+     * @param roomName the name of the conference room for which the user will
14
+     * be authenticated
15
+     * @param {bool} roleUpgrade <tt>true</tt> if the URL will be used for role
16
+     * upgrade scenario, where the user logs-in from the popup window in order
17
+     * to have the moderator rights granted
18
+     *
19
+     * @returns {string|null} the URL pointing to JWT login service or
20
+     * <tt>null</tt> if 'urlPattern' is not a string and the URL can not be
21
+     * constructed.
22
+     */
23
+    getTokenAuthUrl: function (urlPattern, roomName, roleUpgrade) {
24
+        var url = urlPattern;
25
+        if (typeof url !== "string") {
26
+            return null;
27
+        }
28
+        return url.replace("{room}", roomName)
29
+            .replace("{roleUpgrade}", roleUpgrade === true);
30
+    }
31
+};
32
+
33
+module.exports = AuthUtil;

+ 3
- 1
modules/xmpp/xmpp.js Просмотреть файл

223
         var configDomain
223
         var configDomain
224
             = this.options.hosts.anonymousdomain || this.options.hosts.domain;
224
             = this.options.hosts.anonymousdomain || this.options.hosts.domain;
225
         // Force authenticated domain if room is appended with '?login=true'
225
         // Force authenticated domain if room is appended with '?login=true'
226
+        // or if we're joining with the token
226
         if (this.options.hosts.anonymousdomain
227
         if (this.options.hosts.anonymousdomain
227
-                && window.location.search.indexOf("login=true") !== -1) {
228
+                && (window.location.search.indexOf("login=true") !== -1
229
+                    || this.options.token)) {
228
             configDomain = this.options.hosts.domain;
230
             configDomain = this.options.hosts.domain;
229
         }
231
         }
230
         jid = configDomain || window.location.hostname;
232
         jid = configDomain || window.location.hostname;

Загрузка…
Отмена
Сохранить