last ...
This commit is contained in:
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
using Microsoft.AspNetCore.Identity;
|
|
||||||
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using xIdentityModels;
|
using xIdentityModels;
|
||||||
using xIdentityModels.Models;
|
using xIdentityModels.Models;
|
||||||
using xIdentityModels.Navigations;
|
using xIdentityModels.Navigations;
|
||||||
|
using Microsoft.AspNetCore.Identity;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
|
||||||
|
|
||||||
namespace xIds.DbContext
|
namespace xIds.DbContext
|
||||||
{
|
{
|
||||||
@@ -13,7 +13,10 @@ namespace xIds.DbContext
|
|||||||
#region Props/DbSets ...
|
#region Props/DbSets ...
|
||||||
public DbSet<XToken> Tokens { get; set; }
|
public DbSet<XToken> Tokens { get; set; }
|
||||||
public DbSet<XDevice> Devices { get; set; }
|
public DbSet<XDevice> Devices { get; set; }
|
||||||
|
public DbSet<XApiKey> ApiKeys { get; set; }
|
||||||
public DbSet<XProfileImage> Avatars { 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<XBannedDevice> BannedDevices { get; set; }
|
||||||
public DbSet<XFriendshipFollower> Followers { get; set; }
|
public DbSet<XFriendshipFollower> Followers { get; set; }
|
||||||
public DbSet<XFriendshipFollowing> Followings { get; set; }
|
public DbSet<XFriendshipFollowing> Followings { get; set; }
|
||||||
@@ -52,6 +55,24 @@ namespace xIds.DbContext
|
|||||||
.HasForeignKey(ur => ur.UserId)
|
.HasForeignKey(ur => ur.UserId)
|
||||||
.IsRequired();
|
.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);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user