Class SecurityKeyInstaller
- Namespace
- FishMMO.Installer
- Assembly
- FishMMO-Installer.dll
Generates cryptographic keys for FishMMO deployments and stores them directly in the database using a superuser connection. No env files to copy between machines — every server loads its keys from the DB at startup.
Keys managed:
- Gate secret → deployment_secrets table (key='client_gate_secret')
- Connection token HMAC key → connection_token_keys table (key_id='shared')
- Signing key KEK → deployment_secrets table (key='signing_key_kek')
Client build files (ClientApiSecret.generated.cs, etc.) are generated separately from within the Unity Editor (FishMMO > Security > Fetch Client Secrets).
Uses a superuser NpgsqlConnection — matching the pattern established by InstallFishMMODatabase and GrantUserPermissions. The caller is responsible for obtaining the superuser credentials (via HandleWithSuperuser or the FISHMMO_PG_SUPERUSER_PASSWORD environment variable).
public static class SecurityKeyInstaller
- Inheritance
-
SecurityKeyInstaller
- Inherited Members
Methods
ConfigureDatabaseKeysAsync(string, string, AppSettings, bool)
Generates all deployment keys and stores them in the database using a superuser connection.
This is the primary entry point — called from the Database menu (option 9) and from the CLI --configure-server-secrets path.
Uses raw NpgsqlConnection + SQL upserts, matching the pattern used by InstallFishMMODatabase(string, string, AppSettings).
public static Task ConfigureDatabaseKeysAsync(string superUsername, string superPassword, AppSettings appSettings, bool acceptDefaults = false)
Parameters
superUsernamestringPostgreSQL superuser name.
superPasswordstringPostgreSQL superuser password.
appSettingsAppSettingsApplication settings.
acceptDefaultsboolIf true, generate all keys without prompting.
Returns
GenerateBase64Key(int)
Generates a cryptographically random key, base64-encoded. Uses RandomNumberGenerator.Fill (CSPRNG). Round-trip validates. Key material zeroed in finally block.
public static string GenerateBase64Key(int byteLength = 32)
Parameters
byteLengthint