Základní backend: migrace, autentizace JWT, role, Swagger
- Helpdesk.Migrator (DbUp) aplikuje db/migrations, evidence v schema_version - Domain/Application/Infrastructure/Api podle Clean Architecture - registrace, ověření e-mailu, login, refresh s rotací, logout, reset hesla - JWT podle RFC 7519 evidované jen podle jti v auth_token - správa uživatelů a rolí, číselníky, ProblemDetails, Swagger UI - Docker Compose (db, migrator, api), oddělené DB účty - notifikace mají cizí klíče na issue a proposal - unit testy domény a zabezpečení Closes #1, closes #2, closes #3, closes #4, closes #5, closes #9
This commit is contained in:
1 parent
fc76be7d69
commit
a51d386278
64 files changed
+4394
-1
No files matched your search
@@ -0,0 +1,56 @@
|
||||
using Helpdesk.Domain.Auth;
|
||||
using Helpdesk.Domain.Catalogs;
|
||||
using Helpdesk.Domain.Users;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Helpdesk.Application.Abstractions;
|
||||
|
||||
public interface IAppDbContext
|
||||
{
|
||||
DbSet<User> Users { get; }
|
||||
DbSet<AuthToken> AuthTokens { get; }
|
||||
DbSet<Building> Buildings { get; }
|
||||
DbSet<IssueCategory> IssueCategories { get; }
|
||||
DbSet<ProposalCategory> ProposalCategories { get; }
|
||||
|
||||
Task<int> SaveChangesAsync(CancellationToken cancellationToken = default);
|
||||
}
|
||||
|
||||
public interface IPasswordHasher
|
||||
{
|
||||
string Hash(string password);
|
||||
bool Verify(string password, string passwordHash);
|
||||
}
|
||||
|
||||
/// <summary>Vydaný JWT: serializovaný token a záznam pro tabulku <c>auth_token</c>.</summary>
|
||||
public sealed record IssuedToken(string Token, AuthToken Record);
|
||||
|
||||
/// <summary>Ověřený token: identifikátor <c>jti</c> a uživatel (<c>sub</c>).</summary>
|
||||
public sealed record ValidatedToken(string Jti, int UserId);
|
||||
|
||||
public interface ITokenService
|
||||
{
|
||||
IssuedToken Issue(User user, TokenType type);
|
||||
|
||||
/// <summary>Ověří podpis, <c>typ</c>, <c>iss</c>, <c>aud</c> a <c>exp</c> (RFC 7519, kap. 7.2). Neplatný token → <c>null</c>.</summary>
|
||||
Task<ValidatedToken?> ValidateAsync(string token, TokenType expectedType);
|
||||
}
|
||||
|
||||
/// <summary>Paměťová evidence zneplatněných access tokenů, které ještě nevypršely (kap. 10.1).</summary>
|
||||
public interface IRevokedTokenStore
|
||||
{
|
||||
bool IsRevoked(string jti);
|
||||
void Add(string jti, DateTime expiresAt);
|
||||
}
|
||||
|
||||
public interface IEmailSender
|
||||
{
|
||||
Task SendAsync(string to, string subject, string body, CancellationToken cancellationToken = default);
|
||||
}
|
||||
|
||||
/// <summary>Přihlášený uživatel aktuálního požadavku (claimy access tokenu).</summary>
|
||||
public interface ICurrentUser
|
||||
{
|
||||
int Id { get; }
|
||||
string TokenId { get; }
|
||||
}
|
||||
Reference in new issue
Block a user