2026-02-27 17:57:42 +00:00
|
|
|
using IdentityShroud.Core.Security;
|
2026-03-16 19:15:04 +01:00
|
|
|
using IdentityShroud.Core.Security.Keys;
|
2026-02-27 17:57:42 +00:00
|
|
|
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;
|
|
|
|
|
|
2026-03-16 19:15:04 +01:00
|
|
|
public record RealmSigningKey
|
2026-02-27 17:57:42 +00:00
|
|
|
{
|
2026-03-16 19:15:04 +01:00
|
|
|
public required RealmSigningKeyId Id { get; init; }
|
|
|
|
|
public required KeyType KeyType { get; init; }
|
2026-02-27 17:57:42 +00:00
|
|
|
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-03-16 19:15:04 +01:00
|
|
|
|
|
|
|
|
public Dictionary<string, string>? PublicKeyParameters { get; set; }
|
2026-02-28 08:18:30 +01:00
|
|
|
}
|
|
|
|
|
|
2026-03-16 19:15:04 +01:00
|
|
|
public class RealmKeyConfiguration : IEntityTypeConfiguration<RealmSigningKey>
|
2026-02-28 08:18:30 +01:00
|
|
|
{
|
2026-03-16 19:15:04 +01:00
|
|
|
public void Configure(EntityTypeBuilder<RealmSigningKey> b)
|
2026-02-28 08:18:30 +01:00
|
|
|
{
|
|
|
|
|
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-03-16 19:15:04 +01:00
|
|
|
b.Property(e => e.PublicKeyParameters).HasColumnType("jsonb");
|
2026-02-28 08:18:30 +01:00
|
|
|
}
|
2026-03-16 19:15:04 +01:00
|
|
|
}
|