This project involves the development of a web application enabling user interaction with a VM terminal and a Python environment in real-time.
- Implemented user authentication using Keycloak, with registration, login, and logout capabilities.
- Integrated this system into both the frontend and backend.
- Utilized Django for backend development.
- Created API endpoints for interacting with the VM terminal and Python environment.
- Ensured secure and efficient backend-to-terminal communication.
- Developed a React-based frontend.
- Featured two interactive windows for real-time VM and Python terminal interactions.
- Designed an intuitive interface for these functionalities.
- Utilized WebSocket for live interaction between the frontend and terminals.
- Facilitated immediate command execution and response display.
Before you begin, ensure you have the following software installed on your machine:
- Git
- Docker Desktop
To get started with VmProject, follow these steps:
- Clone the repository to your local machine:
git clone https://github.com/FerminAlvarez/VmProject- Change into the project directory:
cd VmProject- Build the Docker images:
docker-compose buildStart the project:
docker-compose upThe application should now be running. You can access it by navigating to http://localhost:5173/ in your web browser.
This endpoint facilitates user authorization through Basic Authentication and returns an authentication token upon successful validation of credentials
http://localhost:8000/auth
| Param | value | Type |
|---|---|---|
| Username | usernameExample | string |
| Password | passwordExample | string |
β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β
An authenticated endpoint designed for testing purposes, requiring a Bearer Token in the request header for access validation. This ensures that only authorized users with a valid token can interact with this testing resource
http://localhost:8000/hello/
| Param | value | Type |
|---|---|---|
| token | yourtoken | string |
β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β
An endpoint for running commands on a non-persistent virtual machine. Requires a Bearer Token in the request header for authentication and security. Use this endpoint to execute specific commands or scripts on the virtual machine without persistence.
http://localhost:8000/execute-command-vm
{
"command":"pwd"
}| Param | value | Type |
|---|---|---|
| token | yourtoken | string |
{
"output": [
"/home/vm"
]
}β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β
Executes Python commands or scripts on the virtual machine. Utilize this endpoint to run Python commands. Authentication is required using a Bearer Token provided in the request header for secure access.
http://localhost:8000/execute-command-python
{
"command": "print(7+2)"
}| Param | value | Type |
|---|---|---|
| token | yourtoken | string |
{
"output": [
"9"
]
}β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β
Allows the upload of a Python file for execution on the virtual machine. Submit a Python script file via a POST request, and the endpoint will execute the script, providing the result as a response. Authentication is required with a Bearer Token in the request header for secure access. Use this endpoint for sending Python scripts, executing them, and retrieving the output.
http://localhost:8000/file-python
| Param | value | Type |
|---|---|---|
| file | /C:/archivo.py | file |
| Param | value | Type |
|---|---|---|
| token | yourtoken | string |
{
"output": [
"9"
]
}β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β
Facilitates testing of a Google Cloud Function. Upload a script or code snippet to execute on the function and retrieve the result. Submit the content via a POST request, and authentication is required with a Bearer Token in the request header for secure access. This endpoint is designed for testing and experimenting with Google Cloud Functions.
https://us-central1-vmproject-411814.cloudfunctions.net/ExecutePythonCode
{
"output": [
"A",
"2",
"3",
]
}β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β
This WebSocket facilitates the execution of commands on a persistent virtual machine and retreive messages in real-time. To ensure authentication and security, a Bearer Token must be included in the url. Utilize this websocket to run specific commands or scripts on the virtual machine with persistence.
ws://localhost:8000/vm/?token=Bearer token
Linux vmproject 5.10.0-27-cloud-amd64 #1 SMP Debian 5.10.205-2 (2023-12-31) x86_64
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Thu Jan 25 21:24:14 2024 from 181.197.251.115
vm@vmproject:~$
{
"command":"pwd"
}
pwd
/home/vm
vm@vmproject:~$
β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β
This WebSocket is designed for executing python commands on a persistent virtual machine and retreive messages in real-time. Authentication and security are maintained by including a Bearer Token in the URL. Employ this WebSocket to execute specific Python commands or scripts on the virtual machine with persistence.
ws://localhost:8000/python/?token=Bearer token
>>>
{
"command":"print('A')"
}
print('A')
A
>>>
Powered By: postman-to-markdown