A backend system for laboratory inventory management, built with Spring Boot, MySQL, and secured with Spring Security & JWT authentication.
LabOrganized is a backend API designed for laboratories to manage their reagent inventory efficiently.
✅ User authentication with JWT tokens
✅ Role-based authorization (ADMIN & USER)
✅ CRUD operations for reagent stock management
✅ Secured endpoints with Spring Security
✅ Admin-exclusive endpoints for user management
To set up and run LabOrganized locally, follow these steps.
1️⃣ Clone the repository
git clone https://github.com/martiyen/laborganized.git
cd laborganized2️⃣ Navigate to src/main/resources/ and create a certs folder
mkdir src/main/resources/certs
cd src/main/resources/certs3️⃣ Generate an RSA key pair for JWT authentication
# Generate RSA key pair
openssl genrsa -out keypair.pem 2048
# Extract public key
openssl rsa -in keypair.pem -pubout -out public.pem
# Convert private key to PKCS#8 format
openssl pkcs8 -topk8 -inform PEM -outform PEM -nocrypt -in keypair.pem -out private.pem4️⃣ Remove the unnecessary keypair.pem file
rm keypair.pem1️⃣ Start the Application
Run the project from your preferred IDE or execute:
./mvnw spring-boot:runBy default, the server runs at http://localhost:8080.
2️⃣ User Authentication
- Register a new account via
POST /register - Obtain a JWT token by sending a
POSTrequest to/tokenwith Basic Authentication
3️⃣ Default Test Users (Preloaded in the database)
| Username | Password | Role |
|---|---|---|
admin |
password |
ADMIN |
jdoe |
password |
USER |
asmith |
password |
USER |
4️⃣ Using the API
- All endpoints (except
/register) require authentication - Include the JWT token as a Bearer Token in requests
- Admin-only actions require ROLE_ADMIN authorization
📌 Example: Login & Retrieve JWT Token
curl -X POST "http://localhost:8080/token" -u "jdoe:password"This returns a token, which should be used in all further requests:
curl -X GET "http://localhost:8080/api/v1/reagents" -H "Authorization: Bearer YOUR_TOKEN_HERE"📧 Martin Doyen - doyenmartin@gmail.com