Fix authentication for namespaces #95

Try to get the token from query string, which is stored in the sockets "handshake" object.

This should fix #95 and be a more elegant (say valid) approach.
This commit is contained in:
Root-Core 2016-11-22 14:27:04 +01:00 committed by GitHub
parent 90f431741b
commit 640e8d0ef0

View File

@ -133,6 +133,7 @@ function authorize(options, onConnection) {
return function(data, accept){
var token, error;
var req = data.request || data;
var handshake = data.handshake;
var authorization_header = (req.headers || {}).authorization;
if (authorization_header) {
@ -152,8 +153,11 @@ function authorize(options, onConnection) {
}
}
//get the token from query string
if (req._query && req._query.token) {
//get the token from handshake or query string
if (handshake && handshake.query.token){
token = handshake.query.token;
}
else if (req._query && req._query.token) {
token = req._query.token;
}
else if (req.query && req.query.token) {