This is a university project developed with Python (Flask) and MongoDB, as a part of the Non-Relational Database Solutions course.
-
Create a virtual python environment
-
Install required packages
Run the command listed below to install all of the required packages.pip install -r requirements.txt
-
Run the Setup Wizard
The setup wizard will guide you through configuring the.env
file for the API.py setup_wizard.py
-
Run the API
API will be available athttps://localhost:5000
.py app.py
-
Check out the Project's Wiki
For detailed documentation, visit the wiki.
List of basic endpoints:
Endpoint | Description |
---|---|
GET / |
A way to check if the API works |
GET /users POST /users |
CRUD operations for users GET : List users POST : Create a user (Other methods: PUT , DELETE ) |
GET /licenses POST /licenses |
CRUD operations for licenses GET : List licenses POST : Create a license (Other methods: PUT , DELETE ) |
GET /checksums POST /checksums |
CRUD operations for checksums GET : List checksums POST : Create a checksum (Other methods: PUT , DELETE ) |
POST /auth |
Authentication endpoint |
POST /activate |
Endpoint to activate a software license |
All endpoints are documented in the wiki:
- Most endpoints are available only to authenticated users.
- Secrets are stored in a
.env
file. - Each user authenticates using a JWT token which holds the user ID and an expiry date.
- Users acquire JWT tokens using the
/auth
endpoint by providing a valid username and password.- On top of that, admin user has to provide a one-time password when 2FA is enabled.
- Most CRUD operations are not available to normal users.
- Only the admin user created using the setup wizard can perform full CRUD operations.
Project uses RSA 2048-bit cryptography keys for generating and veryfing signatures which are treated as license files.
- Each license key is tied to a unique hardware ID, preventing use on other machines.
- API uses a private key to sign licenses, and a matching public key is used to verify them.
API | Application |
---|---|
Holds the PRIVATE KEY 🔑 | Holds the PUBLIC KEY 🔑 |
- Application sends a request to the
/activate
endpoint. This request includes:- License key
- Hardware information identifying the machine
- API validates the provided information and uses its PRIVATE KEY 🔑 to generate a signature for the hardware data.
- API creates a Base64-encoded hardware ID string composed of all the submitted parameters, joined by a pipe symbol (
|
):
spec1|spec2|spec3|spec4|spec5
Hardware ID string is stored in the database in its Base64-encoded form. - API generates a SHA256 (salt length of 32) signature for a string that combines the hardware ID string and the license key:
c3BlYzF8c3BlYzJ8c3BlYzN8c3BlYzR8c3BlYzUXYYUG-AANZN-77824-50018
- API creates a Base64-encoded hardware ID string composed of all the submitted parameters, joined by a pipe symbol (
- Application receives the signature and saves it in a license file.
- Application grabs the following:
- Signature from the license file
- License key
- Current hardware ID of the machine
- Application uses its PUBLIC KEY 🔑 to verify the signature against the current hardware ID. If the verification is successful, the software is considered licensed.
You can find a demo application written in C# to test the licensing system here: Demo .NET 8 C# Application