Spaces:
Sleeping
Sleeping
techedstudios commited on
Commit ·
e02e62e
1
Parent(s): 9702d78
Fix: WebSocket auth rejected deterministic tokens resulting in blank console
Browse files
server.js
CHANGED
|
@@ -1185,12 +1185,20 @@ app.post('/api/servers/:id/modrinth/uninstall', (req, res) => {
|
|
| 1185 |
}
|
| 1186 |
});
|
| 1187 |
|
| 1188 |
-
// --- WebSocket Gateway Connection Handler ---
|
| 1189 |
-
wss.on('connection', (ws, req) => {
|
| 1190 |
try {
|
| 1191 |
const parsedUrl = new URL(req.url, 'http://localhost');
|
| 1192 |
const token = parsedUrl.searchParams.get('token');
|
| 1193 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1194 |
ws.close(4001, 'Unauthorized');
|
| 1195 |
return;
|
| 1196 |
}
|
|
|
|
| 1185 |
}
|
| 1186 |
});
|
| 1187 |
|
| 1188 |
+
// --- WebSocket Gateway Connection Handler ---
|
| 1189 |
+
wss.on('connection', async (ws, req) => {
|
| 1190 |
try {
|
| 1191 |
const parsedUrl = new URL(req.url, 'http://localhost');
|
| 1192 |
const token = parsedUrl.searchParams.get('token');
|
| 1193 |
+
|
| 1194 |
+
// Use the same deterministic token logic as HTTP routes
|
| 1195 |
+
const config = await getAuthConfig();
|
| 1196 |
+
if (!token || !config || !config.passwordHash) {
|
| 1197 |
+
ws.close(4001, 'Unauthorized');
|
| 1198 |
+
return;
|
| 1199 |
+
}
|
| 1200 |
+
const expectedToken = generateStableToken(config.passwordHash, config.salt);
|
| 1201 |
+
if (token !== expectedToken) {
|
| 1202 |
ws.close(4001, 'Unauthorized');
|
| 1203 |
return;
|
| 1204 |
}
|