Skip to content

Configuration is read-only when env var is used #144

@josecelano

Description

@josecelano

Hi @da2ce7 @WarmBeer, I've just realised that we cannot update the settings when we use the environment variable instead of the config.toml file.

There is an API endpoint to remotely update the settings. But you can use an env var TORRUST_IDX_BACK_CONFIG instead of the config.toml file. The env var was introduced to simplify running the app with docker since you do not need to mount the config file.

If we use the env var, there is no file. The main problem is that the config env var was added as a read-only way to inject configuration.

From my point of view, we should move the settings we want to allow the admin to change (via the admin panel) to the database or a different file.

I would keep in the config.toml file only the settings that:

  • Are needed to start the services.
  • Are read-only.
  • Do not change very often.
  • Can't be changed by the user directly.

If we want the admin to change everything, we have to make some changes because, for example, you cannot change the app port or IP without restarting the socket (gracefully). It's possible to change everything dynamically but I think some it does not make sense to change some options like the socket address.

For the time being, I would only allow changing these settings:

[website]
name = "Torrust"

[auth]
email_on_signup = "Optional"

[mail]
email_verification_enabled = false

And I would move them to a new table in the database (with default values).

But I do not think they are very useful. They could be useful if we have an installer and the end user does the final customization.

If we do not want to make those changes now, I would totally disable the ability to update the settings from the control panel.

Alternatively, we can keep it as it is, which means if you start the app with an env var the app will panic if you try to update the settings. Maybe we should disable that endpoint in this case.

Originally posted by @josecelano in #141 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugIncorrect Behavior

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions