mirror of
https://github.com/linuxserver/gclient.git
synced 2026-02-20 02:54:19 +08:00
adding cloud command authed through pam for remote file upload/download and management
This commit is contained in:
parent
4899ae16ef
commit
ab9ea40d9e
41
app.js
41
app.js
@ -6,6 +6,10 @@ var ejs = require('ejs');
|
||||
var express = require('express');
|
||||
var app = require('express')();
|
||||
var http = require('http').Server(app);
|
||||
var cloudcmd = require('cloudcmd');
|
||||
var io = require('socket.io');
|
||||
var bodyParser = require('body-parser');
|
||||
var { pamAuthenticate, pamErrors } = require('node-linux-pam');
|
||||
var CUSTOM_PORT = process.env.CUSTOM_PORT || 3000;
|
||||
|
||||
///// Guac Websocket Tunnel ////
|
||||
@ -70,7 +74,42 @@ app.get("/", function (req, res) {
|
||||
}
|
||||
res.render(__dirname + '/rdp.ejs', {token : connectionstring});
|
||||
});
|
||||
|
||||
//// Web File Browser ////
|
||||
app.use(bodyParser.urlencoded({ extended: true }));
|
||||
var socket = io(http, {path: 'files/socket.io'});
|
||||
app.get('/files', function (req, res) {
|
||||
res.send('Unauthorized');
|
||||
res.end();
|
||||
});
|
||||
app.post('/files', function(req, res, next){
|
||||
var password = req.body.password;
|
||||
var options = {
|
||||
username: 'abc',
|
||||
password: password,
|
||||
};
|
||||
pamAuthenticate(options, function(err, code) {
|
||||
if (!err) {
|
||||
next();
|
||||
} else {
|
||||
res.send('Unauthorized');
|
||||
res.end();
|
||||
}
|
||||
});
|
||||
});
|
||||
app.use('/files', cloudcmd({
|
||||
socket,
|
||||
config: {
|
||||
root: '/config',
|
||||
prefix: '/files',
|
||||
terminal: false,
|
||||
console: false,
|
||||
configDialog: false,
|
||||
contact: false,
|
||||
auth: false,
|
||||
name: 'Files',
|
||||
log: false,
|
||||
}
|
||||
}))
|
||||
|
||||
// Spin up application on CUSTOM_PORT with fallback to port 3000
|
||||
http.listen(CUSTOM_PORT, function(){
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "GClient",
|
||||
"version": "0.0.2",
|
||||
"version": "0.1.0",
|
||||
"description": "LinuxServer Guacamole Client",
|
||||
"main": "app.js",
|
||||
"scripts": {
|
||||
@ -14,8 +14,12 @@
|
||||
"license": "GPLV3",
|
||||
"homepage": "https://www.linuxserver.io/",
|
||||
"dependencies": {
|
||||
"body-parser": "^1.19.0",
|
||||
"cloudcmd": "^15.9.4",
|
||||
"ejs": "^2.7.1",
|
||||
"express": "^4.17.1",
|
||||
"guacamole-lite": "^0.6.3"
|
||||
"guacamole-lite": "^0.6.3",
|
||||
"node-linux-pam": "0.0.1",
|
||||
"socket.io": "^4.0.1"
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user