JavaUserService is a microservice for user management and authentication. The service provides registration, JWT-based authentication, and administrative functions.
| Service | Port |
|---|---|
| Users Service API | 8092 |
| PostgreSQL Database | 5433 |
Base URL: http://localhost:8092/api/auth/
POST /login
Content-Type: application/jsonRequest Body:
{
"email": "user@example.com",
"password": "your_password"
}Response:
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"type": "Bearer"
}Important: Save the received JWT token and use it in the Authorization: Bearer <token> header for all subsequent requests requiring authentication.
POST /register
Content-Type: application/jsonRequest Body:
{
"nickname": "john_doe",
"email": "john@example.com",
"password": "secure_password123"
}POST /logout
Authorization: Bearer <your_jwt_token>Headers:
Authorization: Bearer <your_jwt_token>— JWT token received during login
Base URL: http://localhost:8092/api/admin/
Requirements: All administrative endpoints require an administrator JWT token in the Authorization header.
GET /getAll
Authorization: Bearer <admin_jwt_token>GET /getById/{id}
Authorization: Bearer <admin_jwt_token>Path Parameters:
id— unique user identifier
GET /getByEmail/{email}
Authorization: Bearer <admin_jwt_token>Path Parameters:
email— user's email address
GET /getByName/{name}
Authorization: Bearer <admin_jwt_token>Path Parameters:
name— user's nickname
GET /search?name=value&email=value&role=value
Authorization: Bearer <admin_jwt_token>Query Parameters:
name— search by nickname (partial match)email— search by email (partial match)role— search by role (partial match)
Example:
GET /search?role=ADMIN&name=john
POST /registerAsAdmin
Content-Type: application/jsonRequest Body:
{
"nickname": "admin_user",
"email": "admin@example.com",
"password": "admin_secure_password"
}Note: This endpoint is used to create the first administrator during initial system setup.
PUT /update/{id}
Authorization: Bearer <admin_jwt_token>
Content-Type: application/jsonPath Parameters:
id— identifier of the user to update
Request Body:
{
"nickname": "updated_nickname",
"email": "updated@example.com",
"password": "new_password"
}DELETE /delete/{id}
Authorization: Bearer <admin_jwt_token>Path Parameters:
id— identifier of the user to delete
| Field | Type | Description |
|---|---|---|
id |
Long | Unique identifier |
nickname |
String | Username |
email |
String | Email address |
password |
String | Password (hashed) |
role |
String | Role (USER, ADMIN) |
| Field | Type | Description |
|---|---|---|
token |
String | JWT token for authentication |
type |
String | Token type (usually "Bearer") |
- All passwords are hashed before being stored in the database
- JWT tokens are used for authentication and authorization
- Administrative endpoints are protected by role verification
- Tokens have a limited validity period
- The first administrator should be created via the
/api/admin/registerAsAdmin/endpoint on first launch - JWT token must be passed in the
Authorization: Bearer <token>header for protected endpoints - Search fields support partial matching (case-insensitive)