[server]
interface=127.0.0.1                                                                            # required value
port=8000                                                                                      # required value

debug=false                                                                                    # Export the full server configuration and get error messages on HTTP errors pages [NEVER true in production]
security=true                                                                                  # Add security HTTP headers
force_file_permissions=true                                                                    # Don't load file if permissions are not secure

accept_unknow_user=false                                                                       # Don't force a user to re-authenticate
accept_unauthenticated_user=false                                                              # Don't force authentication for new user
active_auth=true                                                                               # Active auth page
auth_script=auth.py                                                                            # Change it to use a custom authentication script
auth_failures_to_blacklist=3                                                                   # Number of authentication failures to blacklist an IP address or user
blacklist_time=30                                                                              # Blacklist time in seconds
admin_groups=1000                                                                              # Integer list to defines Adminitrators groups
exclude_auth_paths=/static/,/js/                                                               # Start of paths where the unauthenticated user gets access
exclude_auth_pages=/api/,/auth/,/web/auth/                                                     # Specific page where the unauthenticated user has access
session_max_time=3600                                                                          # Maximum time in seconds of sessions (recommended value: 3600)
csrf_max_time=300                                                                              # Maximum time in seconds of csrf tokens (recommended value: 300)

urls_section=urls                                                                              # Defined the URL routing section

scripts_path=./scripts/rss,./scripts/account,./scripts/passwords,./scripts/uploads             # Add scripts from location
json_scripts_config=./config/scripts/*.json,./config/nt/scripts/*.json                         # Add server configuration (syntax: json)
ini_scripts_config=./config/scripts/*.ini,./config/nt/scripts/*.ini                            # Add server configuration (syntax: cfg, ini)
documentations_path=./doc/*.html                                                               # Add path to search documentation scripts
# modules                                                                                      # Add custom modules (names) to the server
# modules_path                                                                                 # Add directory to import custom modules
modules=error_pages,share,cgi,rss,JsonRpc,notification
modules_path=./modules
js_path=./static/js/*.js                                                                       # Add glob syntax files to get javascript files
statics_path=./static/html/*.html,./static/css/*.css,./static/images/*.png,./static/images/*.jpg,./static/pdf/*.pdf  # Add glob syntax files to get static files

log_level=DEBUG                                                                                # Set your custom log level {"DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"}
log_filename=./logs/root.logs                                                                  # Write your custom logs in this filename
log_format=%(asctime)s %(levelname)s %(message)s (%(funcName)s -> %(filename)s:%(lineno)d)     # Format for your custom logs (https://docs.python.org/3/library/logging.html#id2)
log_date_format=%d/%m/%Y %H:%M:%S                                                              # Format date for your custom logs (https://docs.python.org/3/library/time.html#time.strftime)
log_encoding=utf-8                                                                             # Encoding for your custom log file

smtp_server                                                                                    # SMTP configuration is used to send notifications, the server name or the IP address of the SMTP server
smtp_starttls=false                                                                            # Using starttls to secure the connection
smtp_password                                                                                  # Password for email account (username is the notification_address configuration), if password is None the client send email without authentication
smtp_port=25                                                                                   # SMTP port
smtp_ssl=false                                                                                 # Using SSL (not starttls) to secure the connection
admin_adresses=admin1@webscripts.local,admin2@webscripts.local                                 # Administrators email addresses to receive the notification
notification_address=notification@webscripts.local                                             # Notification address to send the notification (the sender email address)

webproxy_number=0                                                                              # Number of web proxies in front of the WebScripts server (this is the security configuration to block IP address spoofing: proxies add a header to send the client's IP address and proxies use different headers, there is no way to know which header is the right IP but it is possible to check the number of IPs in the headers). This configuration impact the bruteforce protection and the IP filtering authentication. Without this configuration the IP spoofing protection will be disabled (the bruteforce protection and IP filtering in authentication will be ineffective).

data_dir=data                                                                                  # Configure data directory
cgi_path=cgi-bin                                                                               # CGI path to find scripts

[urls]
/authentication/=/web/auth/                                                                    # Routing the URL -> /authentication/ 'redirect' to /web/auth/
/cgi-bin/=/cgi/bin/                                                                            # Routing the URL -> /cgi-bin/ 'redirect' to /cgi/bin/
/cgi/=/cgi/bin/                                                                                # Routing the URL -> /cgi/ 'redirect' to /cgi/bin/
/bin/=/cgi/bin/                                                                                # Routing the URL -> /bin/ 'redirect' to /cgi/bin/

[scripts]
auth.py=config_auth                                                                            # Define the configuration section ("config_auth") for script named "auth.py"
show_license.py=config_show_licence                                                            # Same as previous for "show_license.py" with "config_show_licence"
change_my_password.py=config_change_my_password                                                # Same as previous for "change_my_password.py" with "config_change_my_password"
test_config.py=config_test_config                                                              # Little script to test arguments and script configurations

[config_auth]
launcher=python                                                                                # Define the launcher for this script (if script is executable this line is not necessary)
path=./scripts/account/auth.py                                                                 # Only necessary if the location of the script is not in "scripts_path"
documentation_file=./doc/auth.html                                                             # Only needed if the location of the documentation does not match the paths defined in "documentations_path"
content_type=text/plain                                                                        # Define the script output content-type (HTTP headers/javascript interpretation)
documentation_content_type=text/html                                                           # Define the documentation content-type
minimum_access=0                                                                               # If a user's group is greater than "minimum_access", the user can use this script
access_groups=0,1                                                                              # If a user's group is in "access_groups", the user can use this script
access_users=0,1,2                                                                             # If the user ID is in "access_users", the user can use this script
args=auth_args                                                                                 # The arguments are defined in section named "auth_args"
description=This script authenticates users.                                                   # Short description to help users
category=My Account                                                                            # Add a link on the index page in the "My Account" section
timeout=15                                                                                     # Timeout for process execution (in seconds)
command_generate_documentation=python "%(dirname)s/../doc/py_doc.py" "%(path)s"                # Command line to generate the documentation file

# Script "auth.py" is in "./scripts/account" and this path is defined in "scripts_path" so is not necessary to add the "path" in configuration section
# Documentation for "auth.py" is "./doc/auth.html" and this path match with "./doc/*.html" (defined in "documentations_path") so is not necessary to add "documentation_file" in configuration section
# The default "Content-Type" is "text/plain" so is not necessary to add "content_type" in configuration section
# The default "Content-Type" for documentation is "text/html" so is not necessary to add "documentation_content_type" in configuration section
# You can add access to a script with:
#     - minimum_access: check all user groups, if a group is greater than "minimum_access", the user can use this script
#     - access_groups: check all user groups, if a group is in "access_groups", the user can use this script
#     - access_users: if the user ID is in "access_users", the user can use this script
#     - if script configuration don't have "minimum_access", "access_groups" and "access_users" anyone can use the script
# The "args" configuration is not necessary if you have no arguments for this script
# "description" is recommended but not required
# If this script does not have a "category", this script will not be visible in the index page (WEB interface only)
# Without "timeout", the script can run indefinitely
# You can run a command line to generate the documentation before printing it, with the "command_generate_documentation" configuration

[auth_args]
--username=arg_username                                                                        # Add a configuration section ("arg_username") for the argument named "--username"
--password=arg_password                                                                        # Add a configuration section ("arg_password") for the argument named "--password"

# If the name of the argument starts with "-", it will be added in the command line otherwise only the value is added

[arg_username]
html_type=text                                                                                 # Define the HTML input type for this argument
description=Your username (to log in)                                                          # Short description to help users
default_value                                                                                  # Add default value
predefined_values                                                                              # To build a list box (<select> in HTML) with a list of values
example=user                                                                                   # Add example (placeholder in HTML)
list=false                                                                                     # Only one username, if true the user can add usernames (as much as the user wants)
input=false                                                                                    # To send the argument in STDIN (interactive mode)

# The default "html_type" is "text" and is therefore not required for this argument
# "description" is recommended but not required
# You can build a list box when an argument value must be in a list of predifined values (html_type will have no consequences)
# "example" is recommended but not required
# When your argument can have multiple values (a list of values) in the same run, list must be true
# When your script has an interactive mode, you can use the "input" configuration to send the argument to STDIN

[arg_password]
html_type=password                                                                             # Define the HTML input type for this argument
description=Your password (to log in)                                                          # Short description to help users
example=password                                                                               # Add example (placeholder in HTML)

[config_change_my_password]
configuration_file=./config/nt/files/change_my_password.json                                    # Define script configuration in a specific file

[config_test_config]
configuration_file=./config/nt/files/test_config.json

[config_show_licence]
timeout=15                                                                                     # Timeout for process execution (in seconds)
launcher=python                                                                                # Define the launcher for this script (if script is executable this line is not necessary)
category=License                                                                               # Add a link on the index page in the "License" section
no_password=false                                                                              # Log the execution command line (must be false if a password is in arguments)
args=args_show_license                                                                         # The arguments are defined in section named "args_show_license"
path=./scripts/py/show_license.py                                                              # Only necessary if the location of the script is not in "scripts_path"
description=This file display the license and copyright of WebScripts.                         # Short description to help users
command_generate_documentation=python  ./scripts/doc/py_doc.py ./scripts/py/show_license.py    # Command line to generate the documentation file

[args_show_license]
license=arg_license                                                                            # Add a configuration section ("arg_license") for the argument named "license"
copyright=arg_copyright                                                                        # Add a configuration section ("arg_copyright") for the argument named "copyright"
codeheader=arg_codeheader                                                                      # Add a configuration section ("arg_codeheader") for the argument named "codeheader"

[arg_license]
html_type=checkbox                                                                             # Define the HTML input type for this argument
description=Display the header of the WebScripts code                                          # Short description to help users

[arg_copyright]
html_type=checkbox                                                                             # Define the HTML input type for this argument
description=View full license                                                                  # Short description to help users

[arg_codeheader]
html_type=checkbox                                                                             # Define the HTML input type for this argument
description=See copyright                                                                      # Short description to help users

################
# ! CAUTION !
# Priority level for server configuration is:
#    1. Command line arguments
#    2. Configuration files
#
# Priority level for configuration files is: 
#    1. your customs configuration JSON files
#    2. your customs configuration INI files
#    3. default JSON configuration file (./config/server.json)
#    4. default INI configuration file (this file: ./config/server.ini)