Config Subsystem

From floodzilla-wiki
Jump to navigation Jump to search

Floodzilla Config Subsystem

The Floodzilla Config Subsystem (FzConfig) is used to store configuration-related information across the various services. The implementation lives in FzCommon.

Design

Floodzilla uses Azure's App Configuration system as its primary data store. Additionally, mechanisms exist for local "Developer mode" overrides of configuration.

To bootstrap the configuration process, FzConfig expects to find a file called appconfig.settings.json in the executable directory of the current process. This file should have one value, "AzureAppConfiguration", which contains the connection string for the App Configuration store:

{
  "AzureAppConfiguration": "Endpoint=https://floodzillaconfig.azconfig.io;Id=xxx;Secret=xxx"
}

In the following order, json files are checked for configuration overrides:

  1. developer.settings.json
  2. local.settings.json
  3. appsettings.json

An example of a local override file might be:

{
    "LocalSmtpHost": "localhost",
    "LocalSmtpUser": "fzemailtest@fzemailtest.org",
    "LocalSmtpPass": "fzemailtest",
}

Usage

To retrieve configuration data, use FzConfig.Config[]:

   BlobServiceClient bsc = new BlobServiceClient(FzConfig.Config[FzConfig.Keys.AzureStorageConnectionString]);

To add a new configuration element:

  1. (optional but recommended) Add a value to FzConfig.Keys
  2. Access the FloodZillaConfig App Configuration in the Azure Portal; use Configuration Explorer to create a new key-value pair.
  3. (optional) if appropriate add a local override to your developer.settings.json for testing

Notes

Secrets: Currently, the App Configuration store is used to store secrets, such as the SQL Server password and various secret keys for third party services like Google Auth and Facebook Login. Although this is probably secure (Azure claims that configuration entries are encrypted), it is apparently not recommended. Azure best practices seems to recommend Azure Key Vault, which seems to have a lot more setup and maintenance overhead.

Issues

appconfig.settings.json has a secret, and is currently checked in to the private GitHub repository! When open-sourcing the project, care must be taken to not check this file into the new repository.

Not all code has been updated to use this system, so existing configuration elements, including secrets, exist in the code.

The Azure configuration store name is miscapitalized. Sorry!