refactor: relocate options classes to dedicated Options folders

Move configuration options from Core/DataAccess/DataSync/ExcelIO to
dedicated Options folders within each project for better organization.
Update all references and tests accordingly.
This commit is contained in:
Joseph Doherty
2026-01-03 08:55:08 -05:00
parent 3cb73eb09f
commit ec4c8fab87
52 changed files with 4628 additions and 202 deletions
@@ -2,7 +2,7 @@ using System.DirectoryServices.Protocols;
using System.Net;
using JdeScoping.Core.Interfaces;
using JdeScoping.Core.Models;
using JdeScoping.Core.Options;
using JdeScoping.Infrastructure.Options;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
@@ -16,16 +16,13 @@ public sealed class LdapAuthService : IAuthService
private const string LdapLookupFormat = "(sAMAccountName={0})";
private readonly LdapOptions _options;
private readonly AuthOptions _authOptions;
private readonly ILogger<LdapAuthService> _logger;
public LdapAuthService(
IOptions<LdapOptions> options,
IOptions<AuthOptions> authOptions,
ILogger<LdapAuthService> logger)
{
_options = options.Value;
_authOptions = authOptions.Value;
_logger = logger;
}
@@ -41,7 +38,7 @@ public sealed class LdapAuthService : IAuthService
}
// Check if user is in admin bypass list
var isAdminBypass = _authOptions.AdminBypassUsers
var isAdminBypass = _options.AdminBypassUsers
.Any(u => string.Equals(u, username, StringComparison.OrdinalIgnoreCase));
// Try each configured LDAP server
@@ -0,0 +1,22 @@
namespace JdeScoping.Infrastructure.Options;
/// <summary>
/// Configuration options for data source selection (Oracle vs file-based).
/// </summary>
public class DataSourceOptions
{
/// <summary>
/// Configuration section name in appsettings.json.
/// </summary>
public const string SectionName = "DataSource";
/// <summary>
/// Use file-based data sources instead of Oracle for development.
/// </summary>
public bool UseFileDataSource { get; set; } = false;
/// <summary>
/// Directory containing JSON data files for file-based data source.
/// </summary>
public string FileDirectory { get; set; } = "DevData";
}
@@ -0,0 +1,47 @@
namespace JdeScoping.Infrastructure.Options;
/// <summary>
/// LDAP configuration options for authentication
/// </summary>
public class LdapOptions
{
/// <summary>
/// Configuration section name
/// </summary>
public const string SectionName = "Ldap";
/// <summary>
/// LDAP server URLs (supports multiple for failover).
/// Example: ["ldap.corp.example.com", "ldap2.corp.example.com"]
/// </summary>
public string[] ServerUrls { get; set; } = [];
/// <summary>
/// Distinguished name of required group for access.
/// Example: "CN=ScopingTool-Users,OU=Groups,DC=corp,DC=example,DC=com"
/// </summary>
public string GroupDn { get; set; } = string.Empty;
/// <summary>
/// LDAP search base for user lookups.
/// Example: "DC=corp,DC=example,DC=com"
/// </summary>
public string SearchBase { get; set; } = string.Empty;
/// <summary>
/// Connection timeout in seconds.
/// </summary>
public int ConnectionTimeoutSeconds { get; set; } = 30;
/// <summary>
/// Enable fake authentication for development.
/// When true, any credentials are accepted.
/// </summary>
public bool UseFakeAuth { get; set; } = false;
/// <summary>
/// Optional list of usernames that bypass group check.
/// Use sparingly for admin/testing purposes.
/// </summary>
public string[] AdminBypassUsers { get; set; } = [];
}
@@ -3,7 +3,7 @@ using System.Text.Json;
using JdeScoping.Core.Interfaces;
using JdeScoping.Core.Models;
using JdeScoping.Core.Models.Quality;
using JdeScoping.Core.Options;
using JdeScoping.Infrastructure.Options;
using Microsoft.Extensions.Options;
namespace JdeScoping.Infrastructure.Sources.Cms;
@@ -5,7 +5,7 @@ using JdeScoping.Core.Models;
using JdeScoping.Core.Models.Inventory;
using JdeScoping.Core.Models.Organization;
using JdeScoping.Core.Models.WorkOrders;
using JdeScoping.Core.Options;
using JdeScoping.Infrastructure.Options;
using Microsoft.Extensions.Options;
namespace JdeScoping.Infrastructure.Sources.Jde;