I give up

This commit is contained in:
2024-12-15 12:16:42 -05:00
parent 4e8a65fcb7
commit e8754fb514
3 changed files with 57 additions and 1048 deletions
+9 -17
View File
@@ -4,7 +4,6 @@ import { fileURLToPath } from 'url';
import session from 'express-session';
import expressWs from 'express-ws';
import { spawn } from 'node-pty';
import linuxpam from 'node-linux-pam';
import json from './secrets/config.json' with { type: 'json' };
const __dirname = path.dirname(fileURLToPath(import.meta.url)),
@@ -53,22 +52,15 @@ app.post('/login', async (req, res) => {
if (!username) return res.status(400).send('Username is required');
if (!password) return res.status(400).send('Password is required');
// authenticate using PAM
linuxpam.pamAuthenticate({
username,
password,
serviceName: 'login',
}, (err, success) => {
console.log(err);
if (err.message.includes('User not known')) res.sendStatus(404);
else if (err.message.includes('Authentication failure')) res.sendStatus(401);
else if (success) {
req.session.authenticated = true;
req.session.username = username;
return res.redirect('/shell');
}
else console.error("what?", err, success);
});
const { uname, upass } = json;
if (username !== uname) return res.sendStatus(404);
else if (password !== upass) return res.sendStatus(401);
req.session.authenticated = true;
req.session.username = username;
return res.redirect('/shell');
} catch (err) {
console.error(err);
res.status(500).send('Internal server error');
+44 -1029
View File
File diff suppressed because it is too large Load Diff
+4 -2
View File
@@ -11,11 +11,13 @@
"dependencies": {
"@xterm/addon-fit": "^0.10.0",
"@xterm/xterm": "^5.5.0",
"authenticate-pam": "^1.0.5",
"express": "^4.21.2",
"express-session": "^1.18.1",
"express-ws": "^5.0.2",
"node-linux-pam": "^0.2.1",
"node-pty": "^1.0.0"
"node-pty": "^1.0.0",
"passport": "^0.7.0",
"passport-local": "^1.0.0"
},
"type": "module"
}