web: přihlášení přes API a automatická obnova tokenů
Typovaný klient REST API, tokeny v šifrované HttpOnly cookie, obnova access tokenu před vypršením se sloučením souběžných obnov (ochrana proti REUSE_DETECTED), odhlášení a společné zpracování chyb API. Refs #21
This commit is contained in:
1 parent
abd075287c
commit
d3a1b1cb17
22 files changed
+697
-1
No files matched your search
@@ -0,0 +1,47 @@
|
||||
namespace Helpdesk.Web.Api;
|
||||
|
||||
// Kontrakt REST API /api/v1 tak, jak ho web používá. Web je tenký klient a na projekty
|
||||
// backendu nemá referenci – DTO jsou zde zrcadlem dokumentace ve Swaggeru.
|
||||
|
||||
public sealed record UserDto(
|
||||
int Id,
|
||||
string Email,
|
||||
string FirstName,
|
||||
string LastName,
|
||||
string? Phone,
|
||||
string Role,
|
||||
bool EmailNotificationsEnabled)
|
||||
{
|
||||
public string FullName => $"{FirstName} {LastName}";
|
||||
}
|
||||
|
||||
public sealed record AuthResponse(
|
||||
string AccessToken,
|
||||
DateTimeOffset AccessTokenExpiresAt,
|
||||
string RefreshToken,
|
||||
DateTimeOffset RefreshTokenExpiresAt,
|
||||
UserDto User)
|
||||
{
|
||||
public TokenSet Tokens => new(AccessToken, AccessTokenExpiresAt, RefreshToken, RefreshTokenExpiresAt);
|
||||
}
|
||||
|
||||
/// <summary>Pár tokenů uložený v autentizační cookie webu.</summary>
|
||||
public sealed record TokenSet(
|
||||
string AccessToken,
|
||||
DateTimeOffset AccessTokenExpiresAt,
|
||||
string RefreshToken,
|
||||
DateTimeOffset RefreshTokenExpiresAt);
|
||||
|
||||
public sealed record LoginRequest(string Email, string Password);
|
||||
|
||||
public sealed record RegisterRequest(string Email, string Password, string FirstName, string LastName);
|
||||
|
||||
public sealed record RefreshTokenRequest(string RefreshToken);
|
||||
|
||||
public sealed record EmailTokenRequest(string Token);
|
||||
|
||||
public sealed record ForgotPasswordRequest(string Email);
|
||||
|
||||
public sealed record ResetPasswordRequest(string Token, string NewPassword);
|
||||
|
||||
public sealed record UpdateProfileRequest(string FirstName, string LastName, string? Phone, bool EmailNotificationsEnabled);
|
||||
Reference in new issue
Block a user