2026-02-27 17:57:42 +00:00
|
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
|
|
|
using IdentityShroud.Core.Contracts;
|
|
|
|
|
using IdentityShroud.Core.Security;
|
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
2026-02-28 08:18:30 +01:00
|
|
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
2026-02-27 17:57:42 +00:00
|
|
|
|
|
|
|
|
namespace IdentityShroud.Core.Model;
|
|
|
|
|
|
|
|
|
|
public record RealmKey
|
|
|
|
|
{
|
|
|
|
|
public required Guid Id { get; init; }
|
|
|
|
|
public required string KeyType { get; init; }
|
|
|
|
|
public required EncryptedDek Key { get; init; }
|
|
|
|
|
public required DateTime CreatedAt { get; init; }
|
|
|
|
|
public DateTime? RevokedAt { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Key with highest priority will be used. While there is not really a use case for this I know some users
|
|
|
|
|
/// are more comfortable replacing keys by using priority then directly deactivating the old key.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public int Priority { get; set; } = 10;
|
2026-02-28 08:18:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class RealmKeyConfiguration : IEntityTypeConfiguration<RealmKey>
|
|
|
|
|
{
|
|
|
|
|
public void Configure(EntityTypeBuilder<RealmKey> b)
|
|
|
|
|
{
|
|
|
|
|
b.ToTable("realm_key");
|
|
|
|
|
b.HasKey(e => e.Id);
|
2026-02-27 17:57:42 +00:00
|
|
|
|
2026-02-28 08:18:30 +01:00
|
|
|
b.ComplexProperty(e => e.Key, e => e.IsRequired());
|
|
|
|
|
}
|
2026-02-27 17:57:42 +00:00
|
|
|
}
|