Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/marchena96/Paradigma-lab1/llms.txt

Use this file to discover all available pages before exploring further.

POST /login is the only public authentication endpoint in the LibraryService API. Submit a valid email and password in the request body to receive a signed JWT Bearer token. The token is valid for 1 hour from the time of issuance and must be included as a Bearer token in the Authorization header of any subsequent requests to protected endpoints.

Endpoint

POST /login

Authentication

No authentication is required ([AllowAnonymous]). This endpoint is intentionally open so that clients can obtain a token.

Request Body

email
string
required
The user’s email address or username used to authenticate.
password
string
required
The user’s password.
role
string
The user’s role. Optional — included for compatibility with the User DTO shape but not evaluated during login.

Status Codes

StatusMeaning
200 OKCredentials are valid; the response body contains the signed JWT token.
401 UnauthorizedThe supplied email or password is incorrect.

Response Fields

token
string
The signed JWT Bearer token. Include this value in the Authorization: Bearer <token> header for all authenticated requests.

Example Request

curl -X POST https://localhost:7098/login \
  -H "Content-Type: application/json" \
  -d '{"email": "admin", "password": "1234"}'

Example Response

{"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."}

Token Properties

PropertyValue
AlgorithmHS256 (HMAC SHA-256)
Expiry1 hour from issuance
ClaimsNameIdentifier (user ID), Email, Role
The default credentials (admin / 1234) are hardcoded directly inside AuthenticationService. This configuration is only suitable for development and lab environments — do not deploy these credentials to production.

Controller Source

[HttpPost("/login")]
[AllowAnonymous]
public async Task<IActionResult> Login(User user)
{
    var validuser = await authenticationService.AuthenticateAsync(user.Email, user.Password);
    if (validuser is null)
        return Unauthorized();

    var token = TokenGenerator.GenerateToken(validuser, jwtSettings);

    return Ok(new TokenResponse(token));
}

Build docs developers (and LLMs) love