Authentication Service
This commit is contained in:
@@ -7,10 +7,11 @@ public sealed class Session
|
||||
{
|
||||
public ulong Id { get; set; }
|
||||
public ulong AccountId { get; set; }
|
||||
public string Token { get; set; } = ""; // 64-char base64url/hex
|
||||
public string TokenHash { get; set; } = ""; // 64-char base64url/hex
|
||||
public DateTime ExpiresAt { get; set; }
|
||||
public DateTime CreatedAt { get; set; }
|
||||
|
||||
public string? CreatedIp { get; set; }
|
||||
public string? UserAgent { get; set; }
|
||||
public Account? Account { get; set; }
|
||||
}
|
||||
|
||||
@@ -21,10 +22,16 @@ public sealed class SessionConfig : IEntityTypeConfiguration<Session>
|
||||
e.ToTable("sessions");
|
||||
e.HasKey(x => x.Id);
|
||||
e.Property(x => x.Id).ValueGeneratedOnAdd();
|
||||
e.HasIndex(x => x.Token).IsUnique();
|
||||
e.HasIndex(x => x.AccountId);
|
||||
e.Property(x => x.Token).HasMaxLength(64).IsRequired();
|
||||
e.Property(x => x.TokenHash).HasMaxLength(128).IsRequired();
|
||||
e.Property(x => x.CreatedIp).HasMaxLength(64);
|
||||
e.Property(x => x.UserAgent).HasMaxLength(256);
|
||||
e.Property(x => x.CreatedAt).HasDefaultValueSql("CURRENT_TIMESTAMP(6)");
|
||||
e.HasOne(x => x.Account).WithMany(a => a.Sessions).HasForeignKey(x => x.AccountId).OnDelete(DeleteBehavior.Cascade);
|
||||
e.HasIndex(x => x.AccountId);
|
||||
e.HasIndex(x => x.TokenHash).IsUnique();
|
||||
|
||||
e.HasOne(x => x.Account)
|
||||
.WithMany(a => a.Sessions)
|
||||
.HasForeignKey(x => x.AccountId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user