2021-12-03 17:37:25 +00:00
Configuration
#############
2024-11-20 13:10:35 +00:00
Load the configuration
======================
2024-05-13 14:44:02 +00:00
Canaille can be configured either by a environment variables, environment file, or by a configuration file.
2021-12-03 17:37:25 +00:00
2024-05-13 14:44:02 +00:00
Configuration file
2024-11-20 13:10:35 +00:00
~~~~~~~~~~~~~~~~~~
2021-12-03 17:37:25 +00:00
2024-05-13 14:44:02 +00:00
The configuration can be written in `toml` configuration file which path is passed in the :envvar: `CONFIG` environment variable.
.. code-block :: toml
:caption: config.toml
2023-06-15 16:29:12 +00:00
2023-12-18 17:06:03 +00:00
SECRET_KEY = "very-secret"
2023-06-15 16:29:12 +00:00
2023-12-18 17:06:03 +00:00
[CANAILLE]
NAME = "My organization"
2021-12-03 17:37:25 +00:00
2023-12-18 17:06:03 +00:00
[CANAILLE_SQL]
DATABASE_URI = "postgresql://user:password@localhost/database"
...
2021-12-03 17:37:25 +00:00
2024-05-13 14:44:02 +00:00
You can have a look at the :ref: `example file <references/configuration:Example file>` for inspiration.
2021-12-03 17:37:25 +00:00
2023-12-18 17:06:03 +00:00
Environment variables
2024-11-20 13:10:35 +00:00
~~~~~~~~~~~~~~~~~~~~~
2023-07-01 16:46:11 +00:00
2023-12-18 17:06:03 +00:00
In addition, parameters that have not been set in the configuration file can be read from environment variables.
The way environment variables are parsed can be read from the `pydantic-settings documentation <https://docs.pydantic.dev/latest/concepts/pydantic_settings/#parsing-environment-variable-values> `_ .
2023-07-01 16:46:11 +00:00
2024-09-13 13:41:42 +00:00
.. tip ::
For environment vars, the separator between sections and variables is a double underscore: `` __ `` .
For instance, the `` NAME `` var in the `` CANAILLE `` section shown above is `` CANAILLE__NAME `` .
2024-05-13 14:44:02 +00:00
Environment file
2024-11-20 13:10:35 +00:00
~~~~~~~~~~~~~~~~
2024-05-13 14:44:02 +00:00
2024-12-05 14:13:53 +00:00
Any environment variable can also be written in an environment file, which path should be passed in the `` ENV_FILE `` environment variable.
For instance, set `` ENV_FILE=.env `` to load a `` .env `` file.
2021-12-03 17:37:25 +00:00
2024-09-13 13:41:42 +00:00
.. code-block :: bash
:caption: .env
SECRET_KEY="very-secret"
CANAILLE__NAME="My organization"
CANAILLE_SQL__DATABASE_URI="postgresql://user:password@localhost/database"
2024-03-29 12:57:00 +00:00
.. TODO: Uncomment this when pydantic-settings implements nested secrets directories
https://github.com/pydantic/pydantic-settings/issues/154
2021-12-03 17:37:25 +00:00
2024-05-13 14:44:02 +00:00
Secret parameters
=================
2021-12-03 17:37:25 +00:00
2024-05-13 14:44:02 +00:00
A :envvar: `SECRETS_DIR` environment variable can be passed as an environment variable, being a path to a directory in which are stored files named after the configuration settings.
2024-03-29 12:57:00 +00:00
2024-05-13 14:44:02 +00:00
For instance, you can set `` SECRETS_DIR=/run/secrets `` and put your secret key in the file `` /run/secrets/SECRET_KEY `` .
2021-12-03 17:37:25 +00:00
2024-12-05 09:36:26 +00:00
Configuration methods priority
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If a same configuration option is defined by different ways, here is how Canaille will choose which one to use:
- environment vars have priority over the environment file and the configuration file;
- environment file will have priority over the configuration file.
2023-12-18 17:06:03 +00:00
Parameters
==========
2021-12-03 17:37:25 +00:00
2023-12-18 17:06:03 +00:00
.. autopydantic_settings :: canaille.app.configuration.RootSettings
2023-05-29 18:16:59 +00:00
2023-12-18 17:06:03 +00:00
.. autopydantic_settings :: canaille.core.configuration.CoreSettings
.. autopydantic_settings :: canaille.core.configuration.SMTPSettings
2024-11-29 09:32:17 +00:00
.. autopydantic_settings :: canaille.core.configuration.SMPPSettings
2023-12-18 17:06:03 +00:00
.. autopydantic_settings :: canaille.core.configuration.ACLSettings
2024-05-14 07:32:32 +00:00
.. autoclass :: canaille.core.configuration.Permission
2024-05-14 07:05:46 +00:00
:members:
2023-07-03 21:26:39 +00:00
2023-12-18 17:06:03 +00:00
.. autopydantic_settings :: canaille.oidc.configuration.OIDCSettings
2023-06-23 14:26:38 +00:00
2023-12-18 17:06:03 +00:00
.. autopydantic_settings :: canaille.oidc.configuration.JWTSettings
.. autopydantic_settings :: canaille.oidc.configuration.JWTMappingSettings
2021-12-03 17:37:25 +00:00
2023-12-18 17:06:03 +00:00
.. autopydantic_settings :: canaille.backends.sql.configuration.SQLSettings
.. autopydantic_settings :: canaille.backends.ldap.configuration.LDAPSettings
2023-08-15 14:17:19 +00:00
2023-12-18 17:06:03 +00:00
Example file
============
2023-07-20 16:43:28 +00:00
2023-12-18 17:06:03 +00:00
Here is a configuration file example:
2022-04-05 07:49:45 +00:00
2024-05-13 14:44:02 +00:00
.. literalinclude :: ../../canaille/config.sample.toml
2023-12-18 17:06:03 +00:00
:language: toml
2024-05-13 14:44:02 +00:00
:caption: config.toml