Overview
Justina uses a secure JWT-based authentication system with role-based access control. The platform supports two primary user roles: Surgeons (ROLE_SURGEON) and AI Systems (ROLE_IA).Default Credentials
The platform comes with pre-configured default accounts for testing:| Username | Password | Role |
|---|---|---|
surgeon_master | justina2024 | ROLE_SURGEON |
ia_justina | ia_secret_2024 | ROLE_IA |
Registering a New Account
Navigate to Registration
From the login page, click on the “Registrarse” (Register) link at the bottom of the form.
Enter Your Credentials
Provide a unique username and a secure password. The system will validate your input.
Registration API Endpoint
The registration process uses the following REST endpoint:Logging In
Login Implementation
The frontend login form uses Next.js Server Actions:Login API Endpoint
JWT Token Details
Token Storage
Justina stores JWT tokens in two ways:-
HTTP-Only Cookie (server-side security)
- Name:
jwt-token - Max Age: 86400 seconds (24 hours)
- Secure: Enabled in production
- SameSite: None (for cross-origin requests)
- Name:
-
Response Body (client-side access)
- Returned in the login response for manual handling
Using the Token
Include the JWT token in API requests using the Authorization header:Token Expiration
Tokens expire after 24 hours. When a token expires, you’ll receive a401 Unauthorized response and need to log in again.
Role-Based Access Control
Justina implements role-based permissions:Surgeon Role
- Access personal surgical simulations
- Start and complete procedures
- View own simulation results
- Cannot access other surgeons’ data
AI Role
- Receive notifications of completed surgeries
- Access all surgery trajectories
- Submit AI analysis and scoring
- Read-only access to simulation data
Protected Endpoints
Example of role-based security configuration:Retrieving Current User Information
Once authenticated, you can fetch your user profile:Security Features
Password Hashing
All passwords are hashed using BCrypt before storage. Plain text passwords are never stored in the database.
Secure Cookies
JWT tokens are stored in HttpOnly cookies to prevent XSS attacks. The Secure flag is enabled in production.
CORS Protection
Cross-Origin Resource Sharing (CORS) is configured to allow only trusted frontend origins.
Token Validation
Every protected endpoint validates the JWT signature and expiration before processing requests.
Troubleshooting
Invalid Credentials Error
If you see “Correo o contraseña incorrectos”:- Double-check your username and password
- Ensure caps lock is off
- Try using the default credentials to verify system access
Token Not Found
If WebSocket connections fail with “Token JWT no encontrado”:- Ensure you’re logged in
- Check that cookies are enabled in your browser
- Clear browser cache and log in again
401 Unauthorized
If API requests return 401:- Your token may have expired (24-hour limit)
- Log out and log back in to get a fresh token
- Verify the Authorization header is properly formatted
Next Steps
Dashboard
Explore the main dashboard interface
Run Simulations
Start your first surgical simulation