Stechuhr-Server allows you to use _multiple_ configuration files, each overriding the previous one either in full or partly. In any case a default configuration is used, which might or might not fit your purpose (probably not).
To maintain control a helper script exists at `stechuhr_server/config.py` which allows you to create a new config, print the currently used ones, etc. If your system python has the `toml` dependency installed run it using `python3 stechuhr_server/config.py` and it will display the help. If you _don't_ have the toml dependency installed you can:
1. Install it
2. Use the python in env (see installation above): `path/to/env/bin/python stechuhr_server/config.py`
3. Use python poetry: `poetry run config`
### Config section: application
Application related settings. Here the database can be exposed via a GET request for debugging purposes. Make sure this is off in production, or make sure no such http requests can be made from the public internet.
### Database
### Config section: database.path
Set the path to change where the database file is stored. Make sure that the path is writeable by the service user
### ID verification
### Config section: database.id_patterns
in `config.toml` you can add a list of regex patterns that stechuhr (*both on server and on client!*) uses to verify the Card IDs. These two patterns for example allow upper/lowercase hex strings with lengths either between 6 and 16 characters OR exactly 24 characters:
...
...
@@ -111,3 +119,7 @@ id_patterns = [
```
If in doubt consider [testing your regexes here](https://regexplained.com/)
### Config section: retention
You might not be allowed to keep the collected data around for later. Here you can specify the number of days you wanna keep the data around (in Germany this might be 28 days, but inform yourself). You will additionally need to [install the data retention script](#Data Retention)
# If more than one command is given, display the help
print_help()
deftest():
"""
Runs the config initialization as it would in production, prints out the
order in which the config files are read and spits out the final resulting
toml config
Reads all configs like it would in production, prints out the order in which the config files are read and spits out the final resulting toml config
"""
importpprint
config=initialize_config()
...
...
@@ -265,11 +304,15 @@ def test():
defprint_default():
"""
Print default config
Prints the default config.toml
"""
print(DEFAULT_CONFIG)
defprint_paths():
"""
Prints the potential paths where a config could or should be. If environment variables are used to specify said path, this will be mentioned. If a file doesn't exist, it will be mentioned as well.
"""
paths=get_potential_config_file_paths()
ifpathsisnotNone:
forpinpaths:
...
...
@@ -286,6 +329,7 @@ def print_paths():
else:
print("There are no paths..")
defprint_directories():
"""
Prints a list of directories where configs are searched for.
...
...
@@ -301,9 +345,10 @@ def print_directories():
else:
print("There are no directories..")
defcreate_config():
"""
Interactivally create a config directory with a default config in it.
Interactivally create a config directory at a choice of different places with a default config in it.
"""
helptext="""Configs are read from the following directories (later overrides earlier):
1. DEFAULT_CONFIG (use config default to inspect)
...
...
@@ -389,8 +434,10 @@ def create_config():
print("Default Config has been written to {}".format(config_path))
defprint_help():
"""
Print the help
"""
helptext="""========= {} CONFIG =========
Helper tool for managing and installing a stechuhr-server config.
...
...
@@ -408,9 +455,13 @@ Commands:
directories . . . Prints which config directories are read
paths . . . . . . Prints which config files are read
test . . . . . . Read in the configs and print the resulting combined toml
Options:
-h, --help . . . Display the help message of a command