Merge branch 'master' into commercial

This commit is contained in:
AJ ONeal 2018-06-29 22:14:10 +00:00
commit 4bef0187f1
1 changed files with 11 additions and 9 deletions

View File

@ -240,9 +240,9 @@ var Server = {
return result || srv.socketId; return result || srv.socketId;
} }
, onAuth: function onAuth(state, srv, newAuth, grant) { , onAuth: function onAuth(state, srv, rawAuth, grant) {
console.log('\n[relay.js] onAuth'); console.log('\n[relay.js] onAuth');
console.log(newAuth); console.log(rawAuth);
//console.log(grant); //console.log(grant);
//var stringauth; //var stringauth;
var err; var err;
@ -253,8 +253,8 @@ var Server = {
return state.Promise.reject(err); return state.Promise.reject(err);
} }
if ('string' !== typeof newAuth) { if ('string' !== typeof rawAuth) {
newAuth = JSON.stringify(newAuth); rawAuth = JSON.stringify(rawAuth);
} }
// TODO don't fire the onAuth event on non-authz updates // TODO don't fire the onAuth event on non-authz updates
@ -266,7 +266,7 @@ var Server = {
console.log('[onAuth] check for upgrade token'); console.log('[onAuth] check for upgrade token');
//console.log(grant); //console.log(grant);
if (grant.jwt) { if (grant.jwt) {
if (newAuth !== grant.jwt) { if (rawAuth !== grant.jwt) {
console.log('[onAuth] new token to send back'); console.log('[onAuth] new token to send back');
} }
// TODO only send token when new // TODO only send token when new
@ -277,7 +277,7 @@ var Server = {
, null , null
, [ 3 , [ 3
, 'access_token' , 'access_token'
, { jwt: grant.jwt || grant.access_token } , { jwt: grant.jwt }
] ]
, 'control' , 'control'
); );
@ -356,7 +356,7 @@ var Server = {
} }
grant.ports.forEach(openPort); grant.ports.forEach(openPort);
srv.grants[newAuth] = grant; srv.grants[rawAuth] = grant;
console.info("[ws] authorized", srv.socketId, "for", grant.currentDesc); console.info("[ws] authorized", srv.socketId, "for", grant.currentDesc);
console.log('notify of grants', grant.domains, grant.ports); console.log('notify of grants', grant.domains, grant.ports);
@ -450,11 +450,13 @@ var Server = {
state.srvs[validatedTokenData.id] = {}; state.srvs[validatedTokenData.id] = {};
} }
if (!state.srvs[validatedTokenData.id].updateAuth) { if (!state.srvs[validatedTokenData.id].updateAuth) {
state.srvs[validatedTokenData.id].updateAuth = function (validatedTokenData) { // be sure to always pass latest srv since the connection may change
// and reuse the same token
state.srvs[validatedTokenData.id].updateAuth = function (srv, validatedTokenData) {
return Server.onAuth(state, srv, rawAuth, validatedTokenData); return Server.onAuth(state, srv, rawAuth, validatedTokenData);
}; };
} }
state.srvs[validatedTokenData.id].updateAuth(validatedTokenData); state.srvs[validatedTokenData.id].updateAuth(srv, validatedTokenData);
}); });
} }
, removeToken: function removeToken(state, srv, jwtoken) { , removeToken: function removeToken(state, srv, jwtoken) {