Files
opengenesislinkserver/addons/OGLAssetService/OGLAssetServiceAdminHostConfiguration.cs
T
OpenGenesis (MPL 2.0) 9295b28179 feat(ogl-assets): integrate safe FSAssets-compatible Gen 1 addon (#237)
Distribute the opt-in OGL AssetService, isolated build/ROBUST/DB/HTTP and cache/atomic migration tests, and staged admin infrastructure. Preserve existing AssetService/HGAssetService configuration and authoritative FSAssets storage. Fix SSD cache reuse across ROBUST restarts. No production cutover; distributed caches, atomic updates and admin listener remain disabled. Real-data staging and rollback required before activation.
2026-10-23 03:16:20 +02:00

46 lines
2.1 KiB
C#

using System;
using Nini.Config;
using OpenSim.Framework.ServiceAuth;
using OpenSim.Framework.Servers.HttpServer;
namespace OpenGenesisLINK.Addons.AssetService
{
/// <summary>
/// Explicit opt-in binding for a dedicated ROBUST administrative listener.
/// The caller selects the listener; this class does not open a port.
/// </summary>
public static class OGLAssetServiceAdminHostConfiguration
{
public const string Section = "OGLAssetServiceAdmin";
public static bool RegisterIfEnabled(IConfigSource config, IHttpServer server,
OGLAssetConnector connector, OGLAssetServiceAdminAuditJournal journal)
{
if (config == null) throw new ArgumentNullException(nameof(config));
IConfig section = config.Configs[Section];
if (section == null || !section.GetBoolean("Enabled", false))
return false;
if (server == null) throw new ArgumentNullException(nameof(server));
if (connector == null) throw new ArgumentNullException(nameof(connector));
if (journal == null)
throw new InvalidOperationException("Persistent audit journal is required.");
// One authoritative security preflight for direct registration and
// host-managed listener startup. Never bypass placeholder checks.
OGLAssetServiceAdminPreflight.Check(config, server);
string username = section.GetString("HttpAuthUsername", "");
string password = section.GetString("HttpAuthPassword", "");
string role = section.GetString("Role", "");
string serviceName = section.GetString("ServiceName", "");
// Credentials are read only from this dedicated section.
// A dedicated host listener must enforce TLS and network ACLs.
IServiceAuth auth = new OGLAssetServiceDedicatedAuth(username, password);
OGLAssetServiceAdminHttpRegistration.RegisterRobustServiceAccount(
server, connector, auth, serviceName, role == "Administrator", journal);
return true;
}
}
}