2026-10-28 21:43:17 +01:00
|
|
|
using Helpdesk.Domain.Auth;
|
|
|
|
|
using Helpdesk.Domain.Catalogs;
|
2026-11-18 18:32:59 +01:00
|
|
|
using Helpdesk.Domain.Issues;
|
2026-11-18 21:58:33 +01:00
|
|
|
using Helpdesk.Domain.Notifications;
|
|
|
|
|
using Helpdesk.Domain.Proposals;
|
2026-10-28 21:43:17 +01:00
|
|
|
using Helpdesk.Domain.Users;
|
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
2026-11-18 21:58:33 +01:00
|
|
|
using Microsoft.EntityFrameworkCore.Storage;
|
2026-10-28 21:43:17 +01:00
|
|
|
|
|
|
|
|
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; }
|
2026-11-18 18:32:59 +01:00
|
|
|
DbSet<Issue> Issues { get; }
|
|
|
|
|
DbSet<IssueEvent> IssueEvents { get; }
|
|
|
|
|
DbSet<Attachment> Attachments { get; }
|
2026-11-18 21:58:33 +01:00
|
|
|
DbSet<Proposal> Proposals { get; }
|
|
|
|
|
DbSet<ProposalEvent> ProposalEvents { get; }
|
|
|
|
|
DbSet<ProposalVote> ProposalVotes { get; }
|
|
|
|
|
DbSet<ProposalScore> ProposalScores { get; }
|
|
|
|
|
DbSet<Notification> Notifications { get; }
|
2026-11-18 18:32:59 +01:00
|
|
|
DbSet<NotificationDelivery> NotificationDeliveries { get; }
|
|
|
|
|
DbSet<PushDevice> PushDevices { get; }
|
2026-10-28 21:43:17 +01:00
|
|
|
|
|
|
|
|
Task<int> SaveChangesAsync(CancellationToken cancellationToken = default);
|
2026-11-18 21:58:33 +01:00
|
|
|
Task<IDbContextTransaction> BeginProposalWriteAsync(CancellationToken ct);
|
|
|
|
|
Task<Proposal?> LockProposalAsync(int id, CancellationToken ct);
|
2026-10-28 21:43:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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; }
|
|
|
|
|
}
|