Files
git.stella-ops.org/src/Signer/__Libraries/StellaOps.Signer.KeyManagement/KeyManagementDbContext.cs
master 8bbfe4d2d2 feat(rate-limiting): Implement core rate limiting functionality with configuration, decision-making, metrics, middleware, and service registration
- Add RateLimitConfig for configuration management with YAML binding support.
- Introduce RateLimitDecision to encapsulate the result of rate limit checks.
- Implement RateLimitMetrics for OpenTelemetry metrics tracking.
- Create RateLimitMiddleware for enforcing rate limits on incoming requests.
- Develop RateLimitService to orchestrate instance and environment rate limit checks.
- Add RateLimitServiceCollectionExtensions for dependency injection registration.
2025-12-17 18:02:37 +02:00

60 lines
1.6 KiB
C#

using Microsoft.EntityFrameworkCore;
using StellaOps.Signer.KeyManagement.Entities;
namespace StellaOps.Signer.KeyManagement;
/// <summary>
/// DbContext for key management entities.
/// </summary>
public class KeyManagementDbContext : DbContext
{
public KeyManagementDbContext(DbContextOptions<KeyManagementDbContext> options)
: base(options)
{
}
/// <summary>
/// Key history entries.
/// </summary>
public DbSet<KeyHistoryEntity> KeyHistory => Set<KeyHistoryEntity>();
/// <summary>
/// Key audit log entries.
/// </summary>
public DbSet<KeyAuditLogEntity> KeyAuditLog => Set<KeyAuditLogEntity>();
/// <summary>
/// Trust anchors.
/// </summary>
public DbSet<TrustAnchorEntity> TrustAnchors => Set<TrustAnchorEntity>();
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.HasDefaultSchema("signer");
modelBuilder.Entity<KeyHistoryEntity>(entity =>
{
entity.HasKey(e => e.HistoryId);
entity.HasIndex(e => new { e.AnchorId, e.KeyId }).IsUnique();
entity.HasIndex(e => e.AnchorId);
});
modelBuilder.Entity<KeyAuditLogEntity>(entity =>
{
entity.HasKey(e => e.LogId);
entity.HasIndex(e => e.AnchorId);
entity.HasIndex(e => e.CreatedAt).IsDescending();
});
modelBuilder.Entity<TrustAnchorEntity>(entity =>
{
entity.HasKey(e => e.AnchorId);
entity.HasIndex(e => e.PurlPattern);
entity.HasIndex(e => e.IsActive);
});
}
}