Procházet zdrojové kódy

Add utility method for constructing JWT login service URL

dev1
paweldomas před 9 roky
rodič
revize
fc995e5aa0
2 změnil soubory, kde provedl 36 přidání a 1 odebrání
  1. 3
    1
      JitsiMeetJS.js
  2. 33
    0
      modules/util/AuthUtil.js

+ 3
- 1
JitsiMeetJS.js Zobrazit soubor

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

+ 33
- 0
modules/util/AuthUtil.js Zobrazit soubor

@@ -0,0 +1,33 @@
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;

Načítá se…
Zrušit
Uložit