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,36 @@
|
||||
using Helpdesk.Domain.Users;
|
||||
|
||||
namespace Helpdesk.Application.Auth;
|
||||
|
||||
/// <summary>Konfigurace samoregistrace (sekce <c>Registration</c>).</summary>
|
||||
public sealed class RegistrationOptions
|
||||
{
|
||||
public const string Section = "Registration";
|
||||
|
||||
/// <summary>Domény e-mailu, ze kterých vzniká role <c>STUDENT</c> (např. <c>student.univerzita.cz</c>).</summary>
|
||||
public string[] StudentEmailDomains { get; set; } = [];
|
||||
|
||||
/// <summary>Domény e-mailu, ze kterých vzniká role <c>TEACHER</c> (např. <c>univerzita.cz</c>).</summary>
|
||||
public string[] TeacherEmailDomains { get; set; } = [];
|
||||
|
||||
/// <summary>Adresa webové aplikace pro odkazy v e-mailech (ověření e-mailu, reset hesla).</summary>
|
||||
public string WebBaseUrl { get; set; } = "https://helpdesk.localhost";
|
||||
|
||||
/// <summary>
|
||||
/// Role podle domény e-mailu (kap. 2.1). Porovnává se celá doména, takže
|
||||
/// <c>@student.univerzita.cz</c> nespadne pod <c>univerzita.cz</c>. Jiná doména → <c>null</c>.
|
||||
/// </summary>
|
||||
public UserRole? ResolveRole(string email)
|
||||
{
|
||||
var at = email.LastIndexOf('@');
|
||||
if (at < 0)
|
||||
return null;
|
||||
|
||||
var domain = email[(at + 1)..].Trim();
|
||||
if (StudentEmailDomains.Contains(domain, StringComparer.OrdinalIgnoreCase))
|
||||
return UserRole.Student;
|
||||
if (TeacherEmailDomains.Contains(domain, StringComparer.OrdinalIgnoreCase))
|
||||
return UserRole.Teacher;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user