Description
Authenticates a user with username and password credentials. Returns a JWT token valid for 2 hours upon successful authentication.
Authentication
No authentication required (public endpoint).
Request Body
Username for authentication. Maximum length: 100 characters.
Response
JWT token for authenticating subsequent requests. Valid for 2 hours.
Indicates successful authentication. Returns true on success.
Status message. Returns “Login successful” on success or error message on failure.
Examples
Successful Login
curl -X POST https://api.example.com/api/auth/login \
-H "Content-Type: application/json" \
-d '{
"NombreUsuario": "admin",
"password": "SecurePassword123"
}'
Failed Login
curl -X POST https://api.example.com/api/auth/login \
-H "Content-Type: application/json" \
-d '{
"NombreUsuario": "admin",
"password": "WrongPassword"
}'
JWT Token Claims
The generated JWT token includes the following claims:
- Name: User’s username (NombreUsuario)
- Role: User’s role (Rol)
- JTI: Unique token identifier (GUID)
Token Configuration
- Expires: 2 hours from issuance
- Algorithm: HMAC SHA256
- Issuer: Configured in
JWT:Issuer
- Audience: Configured in
JWT:Audience