don't use old socket
This commit is contained in:
parent
cda10951d8
commit
db4e5c4f60
20
lib/relay.js
20
lib/relay.js
|
@ -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) {
|
||||||
|
|
Loading…
Reference in New Issue