This commit is contained in:
2026-10-04 18:11:46 +03:30
parent 0f0e078c8e
commit b7fba89157
2 changed files with 57 additions and 3 deletions
+33
View File
@@ -0,0 +1,33 @@
namespace xIds.Configurations
{
/// <summary>
/// Configuration settings for API Key management, including expiration, rate limiting, and audit logging.
/// </summary>
public class XApiKeyConfiguration
{
/// <summary>
/// Default expiration in minutes (e.g., 43200 = 30 days)
/// </summary>
public int DefaultExpirationMinutes { get; set; } = 43200;
/// <summary>
/// Maximum allowed expiration in minutes (e.g., 525600 = 1 year)
/// </summary>
public int MaxExpirationMinutes { get; set; } = 525600;
/// <summary>
/// Maximum ApiKeys per Application
/// </summary>
public int MaxKeysPerApplication { get; set; } = 10;
/// <summary>
/// Enable audit logging
/// </summary>
public bool EnableAuditLog { get; set; } = true;
/// <summary>
/// Default rate limit (requests per minute)
/// </summary>
public int DefaultRateLimit { get; set; } = 60;
}
}
+24 -3
View File
@@ -1,9 +1,9 @@
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using xIdentityModels;
using xIdentityModels.Models;
using xIdentityModels.Navigations;
using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
namespace xIds.DbContext
{
@@ -13,7 +13,10 @@ namespace xIds.DbContext
#region Props/DbSets ...
public DbSet<XToken> Tokens { get; set; }
public DbSet<XDevice> Devices { get; set; }
public DbSet<XApiKey> ApiKeys { get; set; }
public DbSet<XProfileImage> Avatars { get; set; }
public DbSet<XApiKeyUsage> ApiKeyUsage { get; set; }
public DbSet<XApplication> Applications { get; set; }
public DbSet<XBannedDevice> BannedDevices { get; set; }
public DbSet<XFriendshipFollower> Followers { get; set; }
public DbSet<XFriendshipFollowing> Followings { get; set; }
@@ -52,6 +55,24 @@ namespace xIds.DbContext
.HasForeignKey(ur => ur.UserId)
.IsRequired();
});
//
// Configure XApplication ...
modelBuilder.Entity<XApplication>(e =>
{
e.HasIndex(a => a.Name).IsUnique();
e.HasMany(a => a.ApiKeys)
.WithOne(k => k.Application)
.HasForeignKey(k => k.ApplicationId);
});
//
// Configure XApiKey ...
modelBuilder.Entity<XApiKey>(e =>
{
e.HasIndex(k => k.KeyHash).IsUnique();
e.HasIndex(k => k.ExpiresAt);
});
}
}
}