From 0d464cdf566a752d8bd3504247f8067a1ac96846 Mon Sep 17 00:00:00 2001 From: Karmaa Date: Thu, 6 Mar 2025 17:52:27 -0600 Subject: [PATCH] Added RSA support for authentication. Furthered preparations for release. --- README.md | 7 ++-- src/AddHostModal.jsx | 94 +++++++++++++++++++++++++++++++++++++----- src/App.jsx | 9 ++-- src/backend/server.cjs | 5 ++- 4 files changed, 95 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 9d372d91..da81863b 100644 --- a/README.md +++ b/README.md @@ -13,21 +13,20 @@

- Termimx Banner + Termix Banner

# Overview Termix is an open-source forever free self-hosted SSH (other protocols planned, see [Planned Features](#planned-features)) server management panel inspired by [Nexterm](https://github.com/gnmyt/Nexterm). Its purpose is to provide an all-in-one docker-hosted web solution to manage your servers in one easy place. I'm using this project to help me learn [React](https://github.com/facebook/react), [Vite](https://github.com/vitejs/vite-plugin-react), and [Docker](https://www.docker.com) but also because I could never settle on a server management software that I enjoyed to use. > [!WARNING] -> This app is in the VERY early stages of development. Expect bugs, data loss, and unexplainable issues! For that reason, I recommend you securely tunnel your connection through a VPN. +> This app is in the VERY early stages of development. Expect bugs, data loss, and unexplainable issues! For that reason, I recommend you securely tunnel your connection to Termix through a VPN. # Features -- SSH (password auth only) +- SSH - Split Screen (Up to 4) & Tab System # Planned Features -- Key Auth for SSH - VNC - RDP - SFTP (build in file transfer) diff --git a/src/AddHostModal.jsx b/src/AddHostModal.jsx index 5e3d976e..b7c65dc6 100644 --- a/src/AddHostModal.jsx +++ b/src/AddHostModal.jsx @@ -1,9 +1,32 @@ import PropTypes from 'prop-types'; import { CssVarsProvider } from '@mui/joy/styles'; -import { Modal, Button, FormControl, FormLabel, Input, Stack, DialogTitle, DialogContent, ModalDialog } from '@mui/joy'; +import { Modal, Button, FormControl, FormLabel, Input, Stack, DialogTitle, DialogContent, ModalDialog, Select, Option } from '@mui/joy'; import theme from './theme'; const AddHostModal = ({ isHidden, form, setForm, handleAddHost, setIsAddHostHidden }) => { + const handleFileChange = (e) => { + const file = e.target.files[0]; + if (file) { + if (file.name.endsWith('.rsa') || file.name.endsWith('.key') || file.name.endsWith('.pem') || file.name.endsWith('.der') || file.name.endsWith('.p8') || file.name.endsWith('.ssh')) { + const reader = new FileReader(); + reader.onload = (event) => { + setForm({ ...form, rsaKey: event.target.result }); + }; + reader.readAsText(file); + } else { + alert("Please upload a valid RSA private key file."); + } + } + }; + + const isFormValid = () => { + if (form.authMethod === 'Select Auth') return false; + if (!form.ip || !form.user || !form.port) return false; + if (form.authMethod === 'rsaKey' && !form.rsaKey) return false; + if (form.authMethod === 'password' && !form.password) return false; + return true; + }; + return ( setIsAddHostHidden(true)}> @@ -22,7 +45,7 @@ const AddHostModal = ({ isHidden, form, setForm, handleAddHost, setIsAddHostHidd
{ event.preventDefault(); - handleAddHost(); + if (isFormValid()) handleAddHost(); }} > @@ -44,6 +67,7 @@ const AddHostModal = ({ isHidden, form, setForm, handleAddHost, setIsAddHostHidd value={form.ip} onChange={(e) => setForm({ ...form, ip: e.target.value })} required + error={!form.ip ? "Please provide an IP address" : ""} sx={{ backgroundColor: theme.palette.general.primary, color: theme.palette.text.primary, @@ -56,6 +80,7 @@ const AddHostModal = ({ isHidden, form, setForm, handleAddHost, setIsAddHostHidd value={form.user} onChange={(e) => setForm({ ...form, user: e.target.value })} required + error={form.user ? "" : "Please provide a username"} sx={{ backgroundColor: theme.palette.general.primary, color: theme.palette.text.primary, @@ -63,18 +88,64 @@ const AddHostModal = ({ isHidden, form, setForm, handleAddHost, setIsAddHostHidd /> - Host Password - setForm({ ...form, password: e.target.value })} + Authentication Method + + {form.authMethod === 'password' && ( + + Host Password + setForm({ ...form, password: e.target.value })} + required + error={form.password ? "" : "Please provide a password"} + sx={{ + backgroundColor: theme.palette.general.primary, + color: theme.palette.text.primary, + }} + /> + + )} + {form.authMethod === 'rsaKey' && ( + + RSA Key + + + )} Host Port