Browse Source

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

dev1
paweldomas 9 years ago
parent
commit
83b50e54b0
5 changed files with 16 additions and 36 deletions
  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 View File

52
  */
52
  */
53
 JitsiConference.prototype.join = function (password) {
53
 JitsiConference.prototype.join = function (password) {
54
     if(this.room)
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 View File

1
 var JitsiConference = require("./JitsiConference");
1
 var JitsiConference = require("./JitsiConference");
2
 var XMPP = require("./modules/xmpp/xmpp");
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
  * Creates new connection object for the Jitsi Meet server side video conferencing service. Provides access to the
5
  * Creates new connection object for the Jitsi Meet server side video conferencing service. Provides access to the
17
  * JitsiConference interface.
6
  * JitsiConference interface.
18
  * @param appID identification for the provider of Jitsi Meet video conferencing services.
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
  * @param options Object with properties / settings related to connection with the server.
9
  * @param options Object with properties / settings related to connection with the server.
25
  * @constructor
10
  * @constructor
26
  */
11
  */
27
-function JitsiConnection(appID, tokenPassword, options) {
12
+function JitsiConnection(appID, token, options) {
28
     this.appID = appID;
13
     this.appID = appID;
29
-    this.tokenPassword = tokenPassword;
14
+    this.token = token;
30
     this.options = options;
15
     this.options = options;
31
     this.xmpp = new XMPP(options);
16
     this.xmpp = new XMPP(options);
32
     this.conferences = {};
17
     this.conferences = {};
40
     if(!options)
25
     if(!options)
41
         options = {};
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
     this.xmpp.connect(options.id, options.password);
28
     this.xmpp.connect(options.id, options.password);
52
 }
29
 }
53
 
30
 

+ 3
- 1
libs/strophe/strophe.js View File

2640
             }
2640
             }
2641
 
2641
 
2642
             if (!acceptable) {
2642
             if (!acceptable) {
2643
+                console.error("req: ", elem, "Resp:", stanza);
2643
                 throw {
2644
                 throw {
2644
                     name: "StropheError",
2645
                     name: "StropheError",
2645
                     message: "Got answer to IQ from wrong jid:" + from +
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 View File

112
     });
112
     });
113
 };
113
 };
114
 
114
 
115
-ChatRoom.prototype.join = function (password, tokenPassword) {
115
+ChatRoom.prototype.join = function (password) {
116
     if(password)
116
     if(password)
117
         this.password = password;
117
         this.password = password;
118
     var self = this;
118
     var self = this;
119
     this.moderator.allocateConferenceFocus(function()
119
     this.moderator.allocateConferenceFocus(function()
120
     {
120
     {
121
-        self.sendPresence(tokenPassword);
121
+        self.sendPresence();
122
     }.bind(this));
122
     }.bind(this));
123
 };
123
 };
124
 
124
 
125
-ChatRoom.prototype.sendPresence = function (tokenPassword) {
125
+ChatRoom.prototype.sendPresence = function () {
126
     if (!this.presMap['to']) {
126
     if (!this.presMap['to']) {
127
         // Too early to send presence - not initialized
127
         // Too early to send presence - not initialized
128
         return;
128
         return;
142
         pres.c('c', this.connection.caps.generateCapsAttrs()).up();
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
     parser.JSON2packet(this.presMap.nodes, pres);
145
     parser.JSON2packet(this.presMap.nodes, pres);
151
     this.connection.send(pres);
146
     this.connection.send(pres);
152
 };
147
 };

+ 6
- 0
modules/xmpp/xmpp.js View File

14
 function createConnection(bosh) {
14
 function createConnection(bosh) {
15
     bosh = bosh || '/http-bind';
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
     return new Strophe.Connection(bosh);
23
     return new Strophe.Connection(bosh);
18
 };
24
 };
19
 
25
 

Loading…
Cancel
Save