Class DatabaseSecrets
- Namespace
- FishMMO.Database
- Assembly
- FishMMO-DB.dll
Secure resolver for database connection parameters.
Resolution order (first wins):
- Environment variables (FISHMMO_DB_*)
- Platform secrets file:
- Linux: /etc/fishmmo/db-secrets.env
- Windows: %ProgramData%\FishMMO\db-secrets.env
The secrets file is a simple KEY=VALUE format (one per line,
comments and blank lines ignored). On Linux it should be
chmod 600 owned by the service user.
appsettings.json MUST NOT contain Username or Password fields. Those fields have been removed from the configuration model entirely — there is no IConfiguration fallback for credentials.
public static class DatabaseSecrets
- Inheritance
-
DatabaseSecrets
- Inherited Members
Fields
DbNameEnvVar
Environment variable name for the database name.
public const string DbNameEnvVar = "FISHMMO_DB_NAME"
Field Value
HostEnvVar
Environment variable name for the database host.
public const string HostEnvVar = "FISHMMO_DB_HOST"
Field Value
PasswordEnvVar
Environment variable name for the database password.
public const string PasswordEnvVar = "FISHMMO_DB_PASSWORD"
Field Value
PortEnvVar
Environment variable name for the database port.
public const string PortEnvVar = "FISHMMO_DB_PORT"
Field Value
UsernameEnvVar
Environment variable name for the database username.
public const string UsernameEnvVar = "FISHMMO_DB_USERNAME"
Field Value
Properties
DefaultSecretsFilePath
Gets the platform-specific default path to the secrets file. Linux: /etc/fishmmo/db-secrets.env Windows: %ProgramData%\FishMMO\db-secrets.env
public static string DefaultSecretsFilePath { get; }
Property Value
Methods
TryResolveDbName(string?)
Resolves the database name.
public static string TryResolveDbName(string? secretsFilePath = null)
Parameters
secretsFilePathstring
Returns
- string
The resolved database name, or "fishmmo" if not configured.
TryResolveHost(string?)
Resolves the database host.
public static string TryResolveHost(string? secretsFilePath = null)
Parameters
secretsFilePathstring
Returns
- string
The resolved host, or "127.0.0.1" if not configured.
TryResolvePassword(string?)
Resolves the database password.
public static string? TryResolvePassword(string? secretsFilePath = null)
Parameters
secretsFilePathstringPath to the secrets file. If null, DefaultSecretsFilePath is used.
Returns
- string
The resolved password, or null if not configured.
TryResolvePort(string?)
Resolves the database port.
public static int TryResolvePort(string? secretsFilePath = null)
Parameters
secretsFilePathstring
Returns
- int
The resolved port, or 5432 if not configured.
TryResolveUsername(string?)
Resolves the database username.
public static string? TryResolveUsername(string? secretsFilePath = null)
Parameters
secretsFilePathstringPath to the secrets file. If null, DefaultSecretsFilePath is used.
Returns
- string
The resolved username, or null if not configured.