Skip to content

Setup scaffolding for dynamic global settings #664

@josecelano

Description

@josecelano

Parent issue: #657

Context

Configuration injected when the Index starts is the only way to configure/customise the application. See below an example configuration injected via a config file and env vars.

Given that:

  • We want to add many new options. See Index administration #657.
  • We wanted to move some config options from the static configuration to the dynamic one.

Many configuration values were originally added to the file configuration because it was easy. However, there are some issues with that approach:

  • You need to restart the service to apply the new configuration.
  • It can only be done by sysadmin

It would be good to allow the admins (platform admin, not sysadmin responsible for the infrastructure) to change some settings. In fact, the admin is responsible for many of the current settings we put in the config file.

Naming

  • dynamic global settings = runtime settings = admin settings
  • static global settings = starting settings

Proposal

We need to add a new module/context for dynamic settings.

  1. Add the new settings to this new module.
  2. Migrate some static settings to dynamic settings. We have to do it without breaking changes. For example, we can insert in the database the values from the static config and priorize static settings. The sysadmin must remove the setting from the config file/env vars to start using the one in the database.

I see only these types of values:

  • Boolean
  • Plain text (UTF-8)
  • Markdown

Some can be grouped, but that can be implemented in a second iteration.

We can have a new table, torrust_global_settings. The implementation details should go on the Index repo.

Example configuration in JSON

{
  "metadata": {
    "app": "torrust-index",
    "purpose": "configuration",
    "schema_version": "2.0.0"
  },
  "logging": {
    "threshold": "info"
  },
  "website": {
    "name": "Torrust",
    "demo": {
      "warning": "⚠️ Please be aware: This demo resets all data weekly. Torrents not complying with our Usage Policies will be removed immediately without notice. We encourage the responsible use of this software in compliance with all legal requirements."
    },
    "terms": {
      "page": {
        "title": "Usage Policies and Content Restrictions",
        "content": "\n# Usage Policies and Content Restrictions\n\nOur software is designed to support the distribution of legal, authorized content only. Users may only upload or share files that fall under the following categories:\n\n- **Open-Source Licenses:** Content licensed under recognized open-source licenses, allowing for free distribution and modification.\n- **Creative Commons Licenses:** Content released under Creative Commons licenses that permit sharing and distribution.\n- **Public Domain:** Content that is free of copyright restrictions and available for public use.\n\n**Prohibited Content:** Any content that infringes copyright, is subject to copyright protection, or is illegal under applicable laws is strictly prohibited. This includes but is not limited to copyrighted movies, music, software, books, and any other media.\n\n**Enforcement:** We reserve the right to remove any content that does not comply with these policies without notice. We may also take additional steps, including reporting violations to the relevant authorities, if necessary.\n\n"
      },
      "upload": {
        "content_upload_agreement": "I confirm that the content I am uploading is authorized, and I have read and agree to the terms."
      }
    }
  },
  "tracker": {
    "api_url": "http://localhost:1212/",
    "listed": false,
    "private": false,
    "token": "***",
    "token_valid_seconds": 7257600,
    "url": "udp://localhost:6969"
  },
  "net": {
    "base_url": null,
    "bind_address": "0.0.0.0:3001",
    "tsl": null
  },
  "auth": {
    "user_claim_token_pepper": "***",
    "password_constraints": {
      "max_password_length": 64,
      "min_password_length": 6
    }
  },
  "database": {
    "connect_url": "sqlite://data.db?mode=rwc"
  },
  "mail": {
    "from": "[email protected]",
    "reply_to": "[email protected]",
    "smtp": {
      "port": 25,
      "server": "",
      "credentials": {
        "password": "***",
        "username": ""
      }
    }
  },
  "image_cache": {
    "capacity": 128000000,
    "entry_size_limit": 4000000,
    "max_request_timeout_ms": 1000,
    "user_quota_bytes": 64000000,
    "user_quota_period_seconds": 3600
  },
  "api": {
    "default_torrent_page_size": 10,
    "max_torrent_page_size": 30
  },
  "registration": {
    "email": {
      "required": false,
      "verification_required": false
    }
  },
  "tracker_statistics_importer": {
    "port": 3002,
    "torrent_info_update_interval": 3600
  },
  "unstable": null
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions