浏览代码

Adopts to new JWT impl where the token goes as BOSH URL param.

dev1
paweldomas 9 年前
父节点
当前提交
83b50e54b0
共有 5 个文件被更改,包括 16 次插入36 次删除
  1. 1
    1
      JitsiConference.js
  2. 3
    26
      JitsiConnection.js
  3. 3
    1
      libs/strophe/strophe.js
  4. 3
    8
      modules/xmpp/ChatRoom.js
  5. 6
    0
      modules/xmpp/xmpp.js

+ 1
- 1
JitsiConference.js 查看文件

@@ -52,7 +52,7 @@ function JitsiConference(options) {
52 52
  */
53 53
 JitsiConference.prototype.join = function (password) {
54 54
     if(this.room)
55
-        this.room.join(password, this.connection.tokenPassword);
55
+        this.room.join(password);
56 56
 };
57 57
 
58 58
 /**

+ 3
- 26
JitsiConnection.js 查看文件

@@ -1,32 +1,17 @@
1 1
 var JitsiConference = require("./JitsiConference");
2 2
 var XMPP = require("./modules/xmpp/xmpp");
3
-var RandomUtil = require("./modules/util/RandomUtil");
4
-
5
-/**
6
- * Utility method that generates user name based on random hex values.
7
- * Eg. 12345678-1234-1234-12345678
8
- * @returns {string}
9
- */
10
-function generateUserName() {
11
-    return RandomUtil.random8digitsHex() + "-" + RandomUtil.random4digitsHex() + "-" +
12
-        RandomUtil.random4digitsHex() + "-" + RandomUtil.random8digitsHex();
13
-}
14 3
 
15 4
 /**
16 5
  * Creates new connection object for the Jitsi Meet server side video conferencing service. Provides access to the
17 6
  * JitsiConference interface.
18 7
  * @param appID identification for the provider of Jitsi Meet video conferencing services.
19
- * @param tokenPassword secret generated by the provider of Jitsi Meet video conferencing services.
20
- * The token will be send to the provider from the Jitsi Meet server deployment for authorization of the current client.
21
- * The format is:
22
- * passwordToken = token + "_" + roomName + "_" + ts
23
- * See doc/tokens.md for more info on how tokens are generated.
8
+ * @param token the JWT token used to authenticate with the server(optional)
24 9
  * @param options Object with properties / settings related to connection with the server.
25 10
  * @constructor
26 11
  */
27
-function JitsiConnection(appID, tokenPassword, options) {
12
+function JitsiConnection(appID, token, options) {
28 13
     this.appID = appID;
29
-    this.tokenPassword = tokenPassword;
14
+    this.token = token;
30 15
     this.options = options;
31 16
     this.xmpp = new XMPP(options);
32 17
     this.conferences = {};
@@ -40,14 +25,6 @@ JitsiConnection.prototype.connect = function (options) {
40 25
     if(!options)
41 26
         options = {};
42 27
 
43
-    // If we have token provided use it as a password and generate random username
44
-    if (this.tokenPassword) {
45
-        options.password = this.tokenPassword;
46
-        if (!options.id) {
47
-            options.id = generateUserName() + "@" + this.options.hosts.domain;
48
-        }
49
-    }
50
-
51 28
     this.xmpp.connect(options.id, options.password);
52 29
 }
53 30
 

+ 3
- 1
libs/strophe/strophe.js 查看文件

@@ -2640,10 +2640,12 @@ Strophe.Connection.prototype = {
2640 2640
             }
2641 2641
 
2642 2642
             if (!acceptable) {
2643
+                console.error("req: ", elem, "Resp:", stanza);
2643 2644
                 throw {
2644 2645
                     name: "StropheError",
2645 2646
                     message: "Got answer to IQ from wrong jid:" + from +
2646
-                             "\nExpected jid: " + expectedFrom
2647
+                             "\nExpected jid: " + expectedFrom +"" +
2648
+                             "\n stanza to String: " + stanza.toString()
2647 2649
                 };
2648 2650
             }
2649 2651
 

+ 3
- 8
modules/xmpp/ChatRoom.js 查看文件

@@ -112,17 +112,17 @@ ChatRoom.prototype.updateDeviceAvailability = function (devices) {
112 112
     });
113 113
 };
114 114
 
115
-ChatRoom.prototype.join = function (password, tokenPassword) {
115
+ChatRoom.prototype.join = function (password) {
116 116
     if(password)
117 117
         this.password = password;
118 118
     var self = this;
119 119
     this.moderator.allocateConferenceFocus(function()
120 120
     {
121
-        self.sendPresence(tokenPassword);
121
+        self.sendPresence();
122 122
     }.bind(this));
123 123
 };
124 124
 
125
-ChatRoom.prototype.sendPresence = function (tokenPassword) {
125
+ChatRoom.prototype.sendPresence = function () {
126 126
     if (!this.presMap['to']) {
127 127
         // Too early to send presence - not initialized
128 128
         return;
@@ -142,11 +142,6 @@ ChatRoom.prototype.sendPresence = function (tokenPassword) {
142 142
         pres.c('c', this.connection.caps.generateCapsAttrs()).up();
143 143
     }
144 144
 
145
-    if (tokenPassword) {
146
-        pres.c('token', { xmlns: 'http://jitsi.org/jitmeet/auth-token'})
147
-            .t(tokenPassword).up();
148
-    }
149
-
150 145
     parser.JSON2packet(this.presMap.nodes, pres);
151 146
     this.connection.send(pres);
152 147
 };

+ 6
- 0
modules/xmpp/xmpp.js 查看文件

@@ -14,6 +14,12 @@ var authenticatedUser = false;
14 14
 function createConnection(bosh) {
15 15
     bosh = bosh || '/http-bind';
16 16
 
17
+    // Append token as URL param
18
+    if (this.token) {
19
+        bosh += bosh.indexOf('?') == -1 ?
20
+                '?token=' + this.token : '&token=' + this.token;
21
+    }
22
+
17 23
     return new Strophe.Connection(bosh);
18 24
 };
19 25
 

正在加载...
取消
保存