Files
the-biergarten-app/web/backend/Infrastructure/Infrastructure.Jwt/ITokenInfrastructure.cs
2026-08-04 06:30:44 -04:00

21 lines
730 B
C#

using System.Security.Claims;
namespace Infrastructure.Jwt;
/// <summary>
/// Service for generating and validating JSON Web Tokens (JWTs) used for authentication.
/// </summary>
public interface ITokenInfrastructure
{
/// <summary>
/// Generates a signed JWT for the given user.
/// </summary>
string GenerateJwt(Guid userId, string username, DateTime expiry, string secret);
/// <summary>
/// Validates a JWT and returns the resulting claims principal.
/// </summary>
/// <exception cref="Domain.Exceptions.UnauthorizedException">Thrown when the token is invalid, expired, or fails validation.</exception>
Task<ClaimsPrincipal> ValidateJwtAsync(string token, string secret);
}