Skip to main content

Overview

The User API provides endpoints for user registration and authentication. All endpoints return user objects with secure password handling.
Passwords must meet the following requirements:
  • Minimum 8 characters
  • Maximum 64 characters
  • Must contain at least one letter and one number

Register User


User Login


Data Models

UsuarioPOJO

The user domain model used across all user endpoints.
FieldTypeDescription
idLongUnique identifier
usuarioStringUsername
contrasenaContrasenaVOPassword value object

ContrasenaVO

Value object for password handling with built-in validation. Validation Rules:
  • Cannot be null or empty
  • Minimum length: 8 characters
  • Maximum length: 64 characters
  • Must contain at least one letter (A-Z, a-z)
  • Must contain at least one digit (0-9)
Security:
  • The toString() method returns "****" to prevent password leakage in logs
  • Passwords are never returned in plain text in API responses

Implementation Details

Architecture

The User API follows Clean Architecture principles:
  • Controller Layer: UsuarioRestController (src/main/java/com/example/demo/usuario/infrastructure/controllers/UsuarioRestController.java:1)
  • Application Layer: Command and Query handlers
    • RegistrarUsuarioHandler for registration
    • LoginUsuarioHandler for authentication
  • Domain Layer: UsuarioPOJO and ContrasenaVO value objects

Request Processing Flow

  1. Registration (POST /registro):
    • Receives RegistrarUsuarioRequest with username and password
    • Creates RegistrarUsuarioCommand with validated ContrasenaVO
    • Handler processes command and persists user
    • Returns created UsuarioPOJO
  2. Login (GET /login/{usuario}/{contrasena}):
    • Extracts credentials from path parameters
    • Creates LoginUsuarioQuery
    • Handler validates credentials and retrieves user
    • Returns authenticated UsuarioPOJO

Build docs developers (and LLMs) love