Skip to content

A personal project to have a similar function to the pterodactyl panel and other random things.

License

Notifications You must be signed in to change notification settings

Daftscientist/project-1

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Project 1

License Build Status Coverage Status

A project to replace pterodactyl and be a showcase of my Python and React skills.

  • This project does not follow Open Authorization specification. Read the documentation.

Works with ⛓️

TODO

Done? Idea
✔️ Make it possible when @inject_user is called user.cache are attributes
✔️ Rewrite the whole codebase to use global app context for all common functions.
✔️ Write a cache system - option to use SQLite
✔️ Implement the use of the new session system.
✔️ Rewrite the session system to not rely on python dictionaries.
✔️ Move the authentication routes to /auth/...
✔️ Decorator for authenticated routes.
🖊️ View and edit user data via API.
Add create server routes.
Replace sanic_dantic with my own solution.
✔️ Add email verification with code/link for signup.
✔️ Add option to login with email code/link.
✔️ Add 2FA and Oauth2
Regen backup codes...
Create the entire plugin system from scratch.

Table of Contents

Features

Made with compatibility in mind

  • Built with SQLAlchemy, allowing for connections to SQLite, Postgresql, MySQL, Oracle, MS-SQL, Firebird, Sybase.

Plugin system

Contributor focused

  • Built with documentation, comments and moduled. This allows for easy contribution.

Installation

Download the files:

git clone https://github.com/Daftscientist/my-pterodactyl

Unzip the downloaded files:

Ubuntu: unzip my-pterodactyl-main.zip -d my-pterodactyl-main
Windows: zip file. tar -xf my-pterodactyl-main.zip

Make sure your in the backend folder:

cd backend

Check if python is installed:

python –version
OR
python3 -version

Make sure PIP package manager is installed:

python -m pip --version
OR
python3 -m pip --version

Install required dependencies:

pip install -r requirements.txt
OR
pip3 install -r requirements.txt

Run the backend API:

sanic main

Use ctrl+c to stop the backend running.

Development tips

Creating virtual environments:

python -m venv
OR
python3 -m venv

Entering the virtual environment:

Unix or MacOS - bash shell: source /venv/bin/activate
Unix or MacOS - csh shell: source /venv/bin/activate.csh
Unix or MacOS - fish shell: source /venv/bin/activate.fish
Windows - Command Prompt: venv\Scripts\activate.bat
Windows - PowerShell: venv\Scripts\Activate.ps1

Running the backend API with live reloading:

sanic main --reload

Running the backend API in debug mode:

sanic main --debug

You can combine sanic main --dev for development.

Usage

Creating a user:

import requests

API_URL = "http://localhost:8080/api/v1"

response = requests.post(API_URL + "/user/create", json={
  "username": "example_username",
  "email": "user@example.com",
  "password": "password1",
  "repeated_password": "password1"
})
print(response.json())

Logging in:

import requests

API_URL = "http://localhost:8080/api/v1"

response = requests.post(API_URL + "/user/login", json={
  "email": "user@example.com",
  "password": "password1"
})
print(response.json())
print(response.cookies.get_dict().session)

Logging out (cookies from login must be included in the request):

import requests

API_URL = "http://localhost:8080/api/v1"

response = requests.post(API_URL + "/user/logout", cookies={'session': 'jwt-encoded-string'})
print(response.json())

Responses

Example error:

{
  "error": "Page not found",
  "status": 404,
  "path": "/api/v1/user/nothing",
  "request_id": "request-id",
  "timestamp": "May 10, 2023, 12:00:00 AM"
 }

Exceptions in production

When stumbling across an exception during a production installation of this project, this rarity will be written to the log file. This file, located in backend/localstorage/exceptions.log, will provide the error ID (provided to the user in the UI), message, HTTP code and timestamp.

An excerpt from a real file:

ID: 9ac65dcb-fbe3-4ce0-af0e-5136c70fe2f1 - Message: 'Invalid response type <coroutine object Success at 0x0000024A20732960> (need HTTPResponse)' - Code: 500 - Timestamp: 2023-05-23 20:38:26.521845

Once this information is gathered, check through all open and already solved GitHub issues before reporting it to the development team.

Contributing

We welcome contributions from the community! To contribute to this project, please follow the guidelines below:

Fork the repository and create your branch. Set up the development environment. Make your changes and test thoroughly. Submit a pull request, clearly describing the changes you've made. Please make sure to follow our code of conduct and be respectful to all contributors.

License

This project is licensed under the Apache License 2.0.

About

A personal project to have a similar function to the pterodactyl panel and other random things.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages