Adds support for token authentication.
This commit is contained in:
parent
23e5cb8836
commit
b6ea819b2d
|
@ -1,5 +1,16 @@
|
|||
var JitsiConference = require("./JitsiConference");
|
||||
var XMPP = require("./modules/xmpp/xmpp");
|
||||
var RandomUtil = require("./modules/util/RandomUtil");
|
||||
|
||||
/**
|
||||
* Utility method that generates user name based on random hex values.
|
||||
* Eg. 12345678-1234-1234-12345678
|
||||
* @returns {string}
|
||||
*/
|
||||
function generateUserName() {
|
||||
return RandomUtil.random8digitsHex() + "-" + RandomUtil.random4digitsHex() + "-" +
|
||||
RandomUtil.random4digitsHex() + "-" + RandomUtil.random8digitsHex();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates new connection object for the Jitsi Meet server side video conferencing service. Provides access to the
|
||||
|
@ -25,6 +36,15 @@ function JitsiConnection(appID, token, options) {
|
|||
JitsiConnection.prototype.connect = function (options) {
|
||||
if(!options)
|
||||
options = {};
|
||||
|
||||
// If we have token provided use it as a password and generate random username
|
||||
if (this.token) {
|
||||
options.password = this.token;
|
||||
if (!options.id) {
|
||||
options.id = generateUserName() + "@" + this.options.hosts.domain;
|
||||
}
|
||||
}
|
||||
|
||||
this.xmpp.connect(options.id, options.password);
|
||||
}
|
||||
|
||||
|
|
|
@ -87,16 +87,17 @@ ChatRoom.prototype.initPresenceMap = function () {
|
|||
});
|
||||
};
|
||||
|
||||
ChatRoom.prototype.join = function (password) {
|
||||
ChatRoom.prototype.join = function (password, token) {
|
||||
if(password)
|
||||
this.password = password;
|
||||
var self = this;
|
||||
this.moderator.allocateConferenceFocus(function()
|
||||
{
|
||||
this.sendPresence();
|
||||
self.sendPresence(token);
|
||||
}.bind(this));
|
||||
}
|
||||
};
|
||||
|
||||
ChatRoom.prototype.sendPresence = function () {
|
||||
ChatRoom.prototype.sendPresence = function (auth_token) {
|
||||
if (!this.presMap['to']) {
|
||||
// Too early to send presence - not initialized
|
||||
return;
|
||||
|
@ -116,6 +117,11 @@ ChatRoom.prototype.sendPresence = function () {
|
|||
pres.c('c', this.connection.caps.generateCapsAttrs()).up();
|
||||
}
|
||||
|
||||
if (auth_token) {
|
||||
pres.c('token', { xmlns: 'http://jitsi.org/jitmeet/auth-token'})
|
||||
.t(auth_token).up();
|
||||
}
|
||||
|
||||
parser.JSON2packet(this.presMap.nodes, pres);
|
||||
this.connection.send(pres);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue