mirror of
https://github.com/HeyPuter/puter
synced 2024-11-15 06:15:47 +00:00
fix(security): Move token for socket.io to request body
Currently this commit breaks websocket events and needs to be updated.
This commit is contained in:
parent
f042b095f1
commit
49b257ecff
@ -1146,8 +1146,8 @@ async function jwt_auth(req){
|
|||||||
else if(req.query && req.query.auth_token)
|
else if(req.query && req.query.auth_token)
|
||||||
token = req.query.auth_token;
|
token = req.query.auth_token;
|
||||||
// Socket
|
// Socket
|
||||||
else if(req.handshake && req.handshake.query && req.handshake.query.auth_token)
|
else if(req.handshake && req.handshake.auth && req.handshake.auth.auth_token)
|
||||||
token = req.handshake.query.auth_token;
|
token = req.handshake.auth.auth_token;
|
||||||
|
|
||||||
if(!token || token === 'null')
|
if(!token || token === 'null')
|
||||||
throw('No auth token found');
|
throw('No auth token found');
|
||||||
|
@ -158,7 +158,7 @@ class WebServerService extends BaseService {
|
|||||||
|
|
||||||
// Socket.io middleware for authentication
|
// Socket.io middleware for authentication
|
||||||
socketio.use(async (socket, next) => {
|
socketio.use(async (socket, next) => {
|
||||||
if (socket.handshake.query.auth_token) {
|
if (socket.handshake.auth.auth_token) {
|
||||||
try {
|
try {
|
||||||
let auth_res = await jwt_auth(socket);
|
let auth_res = await jwt_auth(socket);
|
||||||
// successful auth
|
// successful auth
|
||||||
@ -168,7 +168,7 @@ class WebServerService extends BaseService {
|
|||||||
socket.join(socket.user.id);
|
socket.join(socket.user.id);
|
||||||
next();
|
next();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('socket auth err');
|
console.log('socket auth err', e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -65,7 +65,7 @@ class FileSystem{
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.socket = io(this.APIOrigin, {
|
this.socket = io(this.APIOrigin, {
|
||||||
query: {
|
auth: {
|
||||||
auth_token: this.authToken,
|
auth_token: this.authToken,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -43,7 +43,7 @@ async function UIDesktop(options){
|
|||||||
|
|
||||||
// connect socket.
|
// connect socket.
|
||||||
window.socket = io(window.gui_origin + '/', {
|
window.socket = io(window.gui_origin + '/', {
|
||||||
query: {
|
auth: {
|
||||||
auth_token: window.auth_token
|
auth_token: window.auth_token
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user